Skip to content

Commit

Permalink
Loading drop down bars on first load
Browse files Browse the repository at this point in the history
[release]
  • Loading branch information
madskristensen committed Jan 11, 2022
1 parent 2285f6a commit 078bb71
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/Editor/DropdownBars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,23 @@ internal class DropdownBars : TypeAndMemberDropdownBars, IDisposable
public DropdownBars(IVsTextView textView, LanguageService languageService) : base(languageService)
{
_languageService = languageService;

_textView = textView.ToIWpfTextView();
_textView.Caret.PositionChanged += CaretPositionChanged;

_document = _textView.TextBuffer.GetDocument();
_document.Parsed += OnDocumentParsed;

//SynchronizeDropdowns();
InitializeAsync(textView).FireAndForget();
}

// This moves the caret to trigger initial drop down load
private Task InitializeAsync(IVsTextView textView)
{
return ThreadHelper.JoinableTaskFactory.StartOnIdle(() =>
{
textView.SendExplicitFocus();
_textView.Caret.MoveToNextCaretPosition();
_textView.Caret.PositionChanged += CaretPositionChanged;
_textView.Caret.MoveToPreviousCaretPosition();
}).Task;
}

private void CaretPositionChanged(object sender, CaretPositionChangedEventArgs e) => SynchronizeDropdowns();
Expand All @@ -45,10 +54,7 @@ private void SynchronizeDropdowns()

_ = ThreadHelper.JoinableTaskFactory.StartOnIdle(() =>
{
if (!_document.IsParsing)
{
_languageService.SynchronizeDropdowns();
}
_languageService.SynchronizeDropdowns();
}, VsTaskRunContext.UIThreadIdlePriority);
}

Expand Down

0 comments on commit 078bb71

Please sign in to comment.