提交 0fff6ad1 编写于 作者: A Andrew Casey

Save the IVsInteractiveWindow when it is created

...not just when it is opened.  Otherwise, we won't know about it if VS
creates it for us (to persist it across sessions).

Fixes #6413
上级 d4d963b1
......@@ -73,9 +73,8 @@ int IVsToolWindowFactory.CreateToolWindow(ref Guid rguidPersistenceSlot, uint id
{
if (rguidPersistenceSlot == ToolWindowId)
{
var result = _interactiveWindowProvider.Create((int)id);
return (result != null) ? VSConstants.S_OK : VSConstants.E_FAIL;
_interactiveWindowProvider.Create((int)id);
return VSConstants.S_OK;
}
return VSConstants.E_FAIL;
......
......@@ -79,38 +79,37 @@ protected ImmutableArray<IInteractiveWindowCommand> Commands
}
}
public IVsInteractiveWindow Create(int instanceId)
public void Create(int instanceId)
{
var evaluator = CreateInteractiveEvaluator(_vsServiceProvider, _classifierAggregator, _contentTypeRegistry, _vsWorkspace);
Debug.Assert(this._vsInteractiveWindow == null);
// ForceCreate means that the window should be created if the persisted layout indicates that it is visible.
var vsWindow = _vsInteractiveWindowFactory.Create(Id, instanceId, Title, evaluator, __VSCREATETOOLWIN.CTW_fForceCreate);
vsWindow.SetLanguage(LanguageServiceGuid, evaluator.ContentType);
_vsInteractiveWindow = _vsInteractiveWindowFactory.Create(Id, instanceId, Title, evaluator, __VSCREATETOOLWIN.CTW_fForceCreate);
_vsInteractiveWindow.SetLanguage(LanguageServiceGuid, evaluator.ContentType);
vsWindow.InteractiveWindow.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.SuggestionMarginId, true);
var window = _vsInteractiveWindow.InteractiveWindow;
window.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.SuggestionMarginId, true);
EventHandler closeEventDelegate = null;
closeEventDelegate = (sender, e) =>
{
vsWindow.InteractiveWindow.TextView.Closed -= closeEventDelegate;
InteractiveWindow.InteractiveWindow intWindow = vsWindow.InteractiveWindow as InteractiveWindow.InteractiveWindow;
window.TextView.Closed -= closeEventDelegate;
InteractiveWindow.InteractiveWindow intWindow = window as InteractiveWindow.InteractiveWindow;
LogCloseSession(intWindow.LanguageBufferCounter);
evaluator.Dispose();
};
// the tool window now owns the engine:
vsWindow.InteractiveWindow.TextView.Closed += closeEventDelegate;
window.TextView.Closed += closeEventDelegate;
// vsWindow.AutoSaveOptions = true;
var window = vsWindow.InteractiveWindow;
// fire and forget:
window.InitializeAsync();
LogSession(LogMessage.Window, LogMessage.Create);
return vsWindow;
}
public IVsInteractiveWindow Open(int instanceId, bool focus)
......@@ -120,7 +119,7 @@ public IVsInteractiveWindow Open(int instanceId, bool focus)
if (_vsInteractiveWindow == null)
{
_vsInteractiveWindow = Create(instanceId);
Create(instanceId);
}
_vsInteractiveWindow.Show(focus);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册