Clean up mac completion broker.

This commit is contained in:
N. Taylor Mullen 2018-03-13 10:04:29 -07:00
parent 6b2b47a8e6
commit 9fc6b8fcf5
1 changed files with 15 additions and 5 deletions

View File

@ -10,6 +10,8 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.Editor
{ {
internal class DefaultVisualStudioCompletionBroker : VisualStudioCompletionBroker internal class DefaultVisualStudioCompletionBroker : VisualStudioCompletionBroker
{ {
private const string IsCompletionActiveKey = "RoslynCompletionPresenterSession.IsCompletionActive";
public override bool IsCompletionActive(ITextView textView) public override bool IsCompletionActive(ITextView textView)
{ {
if (textView == null) if (textView == null)
@ -17,14 +19,22 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.Editor
throw new ArgumentNullException(nameof(textView)); throw new ArgumentNullException(nameof(textView));
} }
if (textView.HasAggregateFocus) if (!textView.HasAggregateFocus)
{ {
return CompletionWindowManager.IsVisible || // Text view does not have focus, if the completion window is visible it's for a different text view.
(textView.Properties.TryGetProperty<bool>("RoslynCompletionPresenterSession.IsCompletionActive", out var visible) return false;
&& visible); }
if (CompletionWindowManager.IsVisible)
{
return true;
}
if (textView.Properties.TryGetProperty<bool>(IsCompletionActiveKey, out var visible))
{
return visible;
} }
// Text view does not have focus, if the completion window is visible it's for a different text view.
return false; return false;
} }
} }