提交 2e4a24be 编写于 作者: C CyrusNajmabadi 提交者: GitHub

Merge pull request #15260 from CyrusNajmabadi/projectionShutdown

Clear out our projection buffers when we shutdown the pr eview window to workaround an editor bug.
...@@ -553,8 +553,10 @@ private ITextBuffer CreateNewPlainTextBuffer(TextDocument document, Cancellation ...@@ -553,8 +553,10 @@ private ITextBuffer CreateNewPlainTextBuffer(TextDocument document, Cancellation
document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken).ToString(), contentType); document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken).ToString(), contentType);
} }
private async Task<object> CreateNewDifferenceViewerAsync(PreviewWorkspace leftWorkspace, PreviewWorkspace rightWorkspace, private async Task<object> CreateNewDifferenceViewerAsync(
IProjectionBuffer originalBuffer, IProjectionBuffer changedBuffer, double zoomLevel, CancellationToken cancellationToken) PreviewWorkspace leftWorkspace, PreviewWorkspace rightWorkspace,
IProjectionBuffer originalBuffer, IProjectionBuffer changedBuffer,
double zoomLevel, CancellationToken cancellationToken)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
...@@ -564,24 +566,27 @@ private ITextBuffer CreateNewPlainTextBuffer(TextDocument document, Cancellation ...@@ -564,24 +566,27 @@ private ITextBuffer CreateNewPlainTextBuffer(TextDocument document, Cancellation
Contract.ThrowIfTrue((leftWorkspace == null) && (rightWorkspace == null)); Contract.ThrowIfTrue((leftWorkspace == null) && (rightWorkspace == null));
var diffBuffer = _differenceBufferService.CreateDifferenceBuffer( var diffBuffer = _differenceBufferService.CreateDifferenceBuffer(
originalBuffer, changedBuffer, originalBuffer, changedBuffer,
new StringDifferenceOptions(), disableEditing: true); new StringDifferenceOptions(), disableEditing: true);
var diffViewer = _differenceViewerService.CreateDifferenceView(diffBuffer, _previewRoleSet); var diffViewer = _differenceViewerService.CreateDifferenceView(diffBuffer, _previewRoleSet);
diffViewer.Closed += (s, e) => diffViewer.Closed += (s, e) =>
{ {
if (leftWorkspace != null) // Workaround Editor bug. The editor has an issue where they sometimes crash when
{ // trying to apply changes to projection buffer. So, when the user actually invokes
leftWorkspace.Dispose(); // a SuggestedAction we may then edit a text buffer, which the editor will then
leftWorkspace = null; // try to propagate through the projections we have here over that buffer. To ensure
} // that that doesn't happen, we clear out the projections first so that this crash
// won't happen.
if (rightWorkspace != null) originalBuffer.DeleteSpans(0, originalBuffer.CurrentSnapshot.SpanCount);
{ changedBuffer.DeleteSpans(0, changedBuffer.CurrentSnapshot.SpanCount);
rightWorkspace.Dispose();
rightWorkspace = null; leftWorkspace?.Dispose();
} leftWorkspace = null;
rightWorkspace?.Dispose();
rightWorkspace = null;
}; };
const string DiffOverviewMarginName = "deltadifferenceViewerOverview"; const string DiffOverviewMarginName = "deltadifferenceViewerOverview";
...@@ -615,15 +620,8 @@ private ITextBuffer CreateNewPlainTextBuffer(TextDocument document, Cancellation ...@@ -615,15 +620,8 @@ private ITextBuffer CreateNewPlainTextBuffer(TextDocument document, Cancellation
// We use ConfigureAwait(true) to stay on the UI thread. // We use ConfigureAwait(true) to stay on the UI thread.
await diffViewer.SizeToFitAsync().ConfigureAwait(true); await diffViewer.SizeToFitAsync().ConfigureAwait(true);
if (leftWorkspace != null) leftWorkspace?.EnableDiagnostic();
{ rightWorkspace?.EnableDiagnostic();
leftWorkspace.EnableDiagnostic();
}
if (rightWorkspace != null)
{
rightWorkspace.EnableDiagnostic();
}
return new DifferenceViewerPreview(diffViewer); return new DifferenceViewerPreview(diffViewer);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册