diff --git a/src/Editor/DropdownBars.cs b/src/Editor/DropdownBars.cs index 2b4ca09..014a740 100644 --- a/src/Editor/DropdownBars.cs +++ b/src/Editor/DropdownBars.cs @@ -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(); @@ -45,10 +54,7 @@ private void SynchronizeDropdowns() _ = ThreadHelper.JoinableTaskFactory.StartOnIdle(() => { - if (!_document.IsParsing) - { - _languageService.SynchronizeDropdowns(); - } + _languageService.SynchronizeDropdowns(); }, VsTaskRunContext.UIThreadIdlePriority); }