Skip to content

Commit

Permalink
Completion does not work in the Immediate Window after expression eva…
Browse files Browse the repository at this point in the history
…luation (#33875)
  • Loading branch information
ivanbasov committed Mar 6, 2019
1 parent e141e27 commit 7d31dd6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
Expand Down Expand Up @@ -180,29 +181,25 @@ protected override ITextView ConvertTextView()

internal void SetContext(AbstractDebuggerIntelliSenseContext context)
{
// We're never notified of being disabled in the immediate window, so the
// best we can do is only keep resources from one context alive at a time.
Dispose();

// If there was an old context, it must be cleaned before calling SetContext.
Debug.Assert(_context == null);
_context = context;
this.SetCommandHandlers(context.Buffer);
}

internal void RemoveContext()
{
Dispose();
_context = null;
if (_context != null)
{
_context.Dispose();
_context = null;
}
}

internal void SetContentType(bool install)
=> _context?.SetContentType(install);

public void Dispose()
{
if (_context != null)
{
_context.Dispose();
}
}
=> RemoveContext();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ int IVsImmediateStatementCompletion2.InstallStatementCompletion(int install, IVs
return VSConstants.E_FAIL;
}

// Clean the old context in any case upfront:
// even if we fail to initialize, the old context must be cleaned.
this.filters[textView].RemoveContext();

var context = CreateContext(view, textView, debuggerBuffer, contextBuffer, currentStatementSpan);
if (context.TryInitialize())
{
this.filters[textView].SetContext(context);
}
else
{
this.filters[textView].RemoveContext();
}
}

return VSConstants.S_OK;
Expand Down

0 comments on commit 7d31dd6

Please sign in to comment.