提交 d4b9d4c9 编写于 作者: R Ravi Chande

Naming

上级 bbe46b6b
...@@ -78,14 +78,14 @@ private void Commit(PresentationItem item, Model model, char? commitChar, Cancel ...@@ -78,14 +78,14 @@ private void Commit(PresentationItem item, Model model, char? commitChar, Cancel
if (provider == null) if (provider == null)
{ {
var viewBuffer = this.TextView.TextBuffer; var viewBuffer = this.TextView.TextBuffer;
var commitDocument = model.TriggerSnapshot.AsText().GetDocumentWithFrozenPartialSemanticsAsync(cancellationToken).WaitAndGetResult(cancellationToken); var triggerSnapshotDocument = model.TriggerSnapshot.AsText().GetDocumentWithFrozenPartialSemanticsAsync(cancellationToken).WaitAndGetResult(cancellationToken);
// Get the desired text changes for this item. Note that these changes are // Get the desired text changes for this item. Note that these changes are
// specified in terms of the trigger snapshot. // specified in terms of the trigger snapshot.
var completionService = CompletionService.GetService(commitDocument); var completionService = CompletionService.GetService(triggerSnapshotDocument);
var commitChange = completionService.GetChangeAsync( var triggerSnapshotChange = completionService.GetChangeAsync(
commitDocument, item.Item, commitChar, cancellationToken).WaitAndGetResult(cancellationToken); triggerSnapshotDocument, item.Item, commitChar, cancellationToken).WaitAndGetResult(cancellationToken);
textChangesInTriggerSnapshot = commitChange.TextChanges; textChangesInTriggerSnapshot = triggerSnapshotChange.TextChanges;
// Use character based diffing here to avoid overwriting the commit character placed into the editor. // Use character based diffing here to avoid overwriting the commit character placed into the editor.
var editOptions = new EditOptions(new StringDifferenceOptions var editOptions = new EditOptions(new StringDifferenceOptions
...@@ -105,9 +105,9 @@ private void Commit(PresentationItem item, Model model, char? commitChar, Cancel ...@@ -105,9 +105,9 @@ private void Commit(PresentationItem item, Model model, char? commitChar, Cancel
// Try mapping the item span against the trigger snapshot to the ViewBuffer's trigger snapshot. // Try mapping the item span against the trigger snapshot to the ViewBuffer's trigger snapshot.
// Then map that forward to the ViewBuffer's current snapshot. // Then map that forward to the ViewBuffer's current snapshot.
var originalSpanInView = model.GetViewBufferSpan(triggerSnapshotTextChange.Span).TextSpan.ToSnapshotSpan(model.ViewTriggerSnapshot); var originalSpanInView = model.GetViewBufferSpan(triggerSnapshotTextChange.Span).TextSpan.ToSnapshotSpan(model.ViewTriggerSnapshot);
var translatedOriginalSpanInView = originalSpanInView.TranslateTo(TextView.TextBuffer.CurrentSnapshot, SpanTrackingMode.EdgeInclusive); var originalViewSpanTranslatedToCurrentViewSnapshot = originalSpanInView.TranslateTo(TextView.TextBuffer.CurrentSnapshot, SpanTrackingMode.EdgeInclusive);
textChangesInCurrentViewSnapshot.Add(new TextChange(translatedOriginalSpanInView.Span.ToTextSpan(), triggerSnapshotTextChange.NewText)); textChangesInCurrentViewSnapshot.Add(new TextChange(originalViewSpanTranslatedToCurrentViewSnapshot.Span.ToTextSpan(), triggerSnapshotTextChange.NewText));
} }
// Note: we currently create the edit on the textview's buffer. This is // Note: we currently create the edit on the textview's buffer. This is
...@@ -121,7 +121,7 @@ private void Commit(PresentationItem item, Model model, char? commitChar, Cancel ...@@ -121,7 +121,7 @@ private void Commit(PresentationItem item, Model model, char? commitChar, Cancel
var isLast = iChange == textChangesInCurrentViewSnapshot.Count - 1; var isLast = iChange == textChangesInCurrentViewSnapshot.Count - 1;
// add commit char to end of last change if not already included // add commit char to end of last change if not already included
if (isLast && !commitChange.IncludesCommitCharacter && commitChar.HasValue) if (isLast && !triggerSnapshotChange.IncludesCommitCharacter && commitChar.HasValue)
{ {
textChangeInView = new TextChange( textChangeInView = new TextChange(
textChangeInView.Span, textChangeInView.NewText + commitChar.Value); textChangeInView.Span, textChangeInView.NewText + commitChar.Value);
...@@ -180,9 +180,9 @@ private void Commit(PresentationItem item, Model model, char? commitChar, Cancel ...@@ -180,9 +180,9 @@ private void Commit(PresentationItem item, Model model, char? commitChar, Cancel
} }
// adjust the caret position if requested by completion service // adjust the caret position if requested by completion service
if (commitChange.NewPosition != null) if (triggerSnapshotChange.NewPosition != null)
{ {
var target = new SnapshotPoint(this.SubjectBuffer.CurrentSnapshot, commitChange.NewPosition.Value); var target = new SnapshotPoint(this.SubjectBuffer.CurrentSnapshot, triggerSnapshotChange.NewPosition.Value);
this.TextView.TryMoveCaretToAndEnsureVisible(target); this.TextView.TryMoveCaretToAndEnsureVisible(target);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册