-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delay starting the work to scan for todo-items #60654
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,13 +26,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.TodoComments | |
{ | ||
[Export(typeof(IVsTypeScriptTodoCommentService))] | ||
[ExportEventListener(WellKnownEventListeners.Workspace, WorkspaceKind.Host), Shared] | ||
internal class VisualStudioTodoCommentsService | ||
: ForegroundThreadAffinitizedObject, | ||
ITodoListProvider, | ||
IVsTypeScriptTodoCommentService, | ||
IEventListener<object>, | ||
IDisposable | ||
internal class VisualStudioTodoCommentsService : | ||
ITodoListProvider, | ||
IVsTypeScriptTodoCommentService, | ||
IEventListener<object>, | ||
IDisposable | ||
{ | ||
private readonly IThreadingContext _threadingContext; | ||
private readonly VisualStudioWorkspaceImpl _workspace; | ||
private readonly EventListenerTracker<ITodoListProvider> _eventListenerTracker; | ||
private readonly TodoCommentsListener _listener; | ||
|
@@ -42,13 +42,13 @@ internal class VisualStudioTodoCommentsService | |
[ImportingConstructor] | ||
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
public VisualStudioTodoCommentsService( | ||
IThreadingContext threadingContext, | ||
VisualStudioWorkspaceImpl workspace, | ||
IGlobalOptionService globalOptions, | ||
IThreadingContext threadingContext, | ||
IAsynchronousOperationListenerProvider asynchronousOperationListenerProvider, | ||
[ImportMany] IEnumerable<Lazy<IEventListener, EventListenerMetadata>> eventListeners) | ||
: base(threadingContext) | ||
{ | ||
_threadingContext = threadingContext; | ||
_workspace = workspace; | ||
_eventListenerTracker = new EventListenerTracker<ITodoListProvider>(eventListeners, WellKnownEventListeners.TodoListProvider); | ||
|
||
|
@@ -59,12 +59,7 @@ public VisualStudioTodoCommentsService( | |
onTodoCommentsUpdated: (documentId, oldComments, newComments) => | ||
{ | ||
if (TodoListUpdated != null && !oldComments.SequenceEqual(newComments)) | ||
{ | ||
TodoListUpdated?.Invoke( | ||
this, new TodoItemsUpdatedArgs( | ||
documentId, _workspace, _workspace.CurrentSolution, | ||
documentId.ProjectId, documentId, newComments)); | ||
} | ||
TodoListUpdated?.Invoke(this, new TodoItemsUpdatedArgs(documentId, _workspace.CurrentSolution, documentId, newComments)); | ||
}, | ||
threadingContext.DisposalToken); | ||
} | ||
|
@@ -77,15 +72,20 @@ public void Dispose() | |
void IEventListener<object>.StartListening(Workspace workspace, object _) | ||
{ | ||
if (workspace is VisualStudioWorkspace) | ||
_ = StartAsync(); | ||
_ = StartAsync(workspace); | ||
} | ||
|
||
private async Task StartAsync() | ||
private async Task StartAsync(Workspace workspace) | ||
{ | ||
// Have to catch all exceptions coming through here as this is called from a | ||
// fire-and-forget method and we want to make sure nothing leaks out. | ||
try | ||
{ | ||
// Don't bother doing anything until the workspace has actually loaded. We don't want to add to any | ||
// startup costs by doing work too early. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we consider not doing anything at all until someone opens the todo comment window? I don't think I've ever opened it, so for people like me it seems like there is no point in this even running. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. taht woudl make a ton of sense. let me see what we can do about that. |
||
var workspaceStatus = workspace.Services.GetRequiredService<IWorkspaceStatusService>(); | ||
await workspaceStatus.WaitUntilFullyLoadedAsync(_threadingContext.DisposalToken).ConfigureAwait(false); | ||
|
||
// Now that we've started, let the VS todo list know to start listening to us | ||
_eventListenerTracker.EnsureEventListener(_workspace, this); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why this was lazily created.