提交 e3d8b0bd 编写于 作者: C CyrusNajmabadi

Hide text changes.

上级 2340d881
...@@ -32,7 +32,7 @@ private abstract class AddImportCodeAction : CodeAction ...@@ -32,7 +32,7 @@ private abstract class AddImportCodeAction : CodeAction
/// <summary> /// <summary>
/// The changes to make to <see cref="OriginalDocument"/> to add the import. /// The changes to make to <see cref="OriginalDocument"/> to add the import.
/// </summary> /// </summary>
protected readonly ImmutableArray<TextChange> TextChanges; private readonly ImmutableArray<TextChange> _textChanges;
protected AddImportCodeAction( protected AddImportCodeAction(
Document originalDocument, Document originalDocument,
...@@ -41,16 +41,16 @@ private abstract class AddImportCodeAction : CodeAction ...@@ -41,16 +41,16 @@ private abstract class AddImportCodeAction : CodeAction
CodeActionPriority priority) CodeActionPriority priority)
{ {
OriginalDocument = originalDocument; OriginalDocument = originalDocument;
TextChanges = textChanges;
Title = title; Title = title;
Tags = tags; Tags = tags;
Priority = priority; Priority = priority;
_textChanges = textChanges;
} }
protected async Task<Document> GetUpdatedDocumentAsync(CancellationToken cancellationToken) protected async Task<Document> GetUpdatedDocumentAsync(CancellationToken cancellationToken)
{ {
var oldText = await OriginalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); var oldText = await OriginalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
var newText = oldText.WithChanges(TextChanges); var newText = oldText.WithChanges(_textChanges);
var newDocument = OriginalDocument.WithText(newText); var newDocument = OriginalDocument.WithText(newText);
return newDocument; return newDocument;
......
...@@ -73,8 +73,10 @@ private async Task<Solution> GetUpdatedSolutionAsync(CancellationToken cancellat ...@@ -73,8 +73,10 @@ private async Task<Solution> GetUpdatedSolutionAsync(CancellationToken cancellat
protected override async Task<IEnumerable<CodeActionOperation>> ComputeOperationsAsync( protected override async Task<IEnumerable<CodeActionOperation>> ComputeOperationsAsync(
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
var updatedDocument = await GetUpdatedDocumentAsync(cancellationToken).ConfigureAwait(false);
var oldText = await OriginalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); var oldText = await OriginalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
var newText = oldText.WithChanges(TextChanges); var newText = await updatedDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
return ImmutableArray.Create<CodeActionOperation>( return ImmutableArray.Create<CodeActionOperation>(
new InstallPackageAndAddImportOperation( new InstallPackageAndAddImportOperation(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册