提交 2560d491 编写于 作者: D David Poeschl

Inline Rename: Map caret position to correct buffer on Home/End

Fixes bug #2516 by mapping the new caret position to the correct buffer when Home/End is pressed during InlineRename. This change also avoids exceptions when we fail to map the selected spans down to our buffer when Inline Rename is invoked.
上级 b2f29f7a
......@@ -92,16 +92,29 @@ private bool HandleLineStartOrLineEndCommand(ITextBuffer subjectBuffer, ITextVie
return false;
}
// The PointTrackingMode should not matter because we are not tracking between
// versions, and the PositionAffinity is set towards the identifier.
var newPointInView = view.BufferGraph.MapUpToBuffer(
newPoint,
PointTrackingMode.Negative,
lineStart ? PositionAffinity.Successor : PositionAffinity.Predecessor,
view.TextBuffer);
if (!newPointInView.HasValue)
{
return false;
}
if (extendSelection)
{
view.Selection.Select(view.Selection.AnchorPoint, new VirtualSnapshotPoint(newPoint));
view.Selection.Select(view.Selection.AnchorPoint, new VirtualSnapshotPoint(newPointInView.Value));
}
else
{
view.Selection.Clear();
}
view.Caret.MoveTo(newPoint);
view.Caret.MoveTo(newPointInView.Value);
return true;
}
}
......
......@@ -91,7 +91,8 @@ private void ExecuteRenameWorker(RenameCommandArgs args, CancellationToken cance
var selectedSpans = args.TextView.Selection.GetSnapshotSpansOnBuffer(args.SubjectBuffer);
// Now make sure the entire selection is contained within that token.
if (selectedSpans.Count > 1)
// There can be zero selectedSpans in projection scenarios.
if (selectedSpans.Count != 1)
{
ShowErrorDialog(workspace, EditorFeaturesResources.YouMustRenameAnIdentifier);
return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册