提交 7c831721 编写于 作者: A Andrew Casey

Make BreakLine follow the cursor

上级 c54db58c
...@@ -662,12 +662,7 @@ private void DeletePreviousCharacter() ...@@ -662,12 +662,7 @@ private void DeletePreviousCharacter()
point.Value.Snapshot.TextBuffer.Delete(new Span(point.Value.Position - characterSize, characterSize)); point.Value.Snapshot.TextBuffer.Delete(new Span(point.Value.Position - characterSize, characterSize));
UIThread(uiOnly => UIThread(uiOnly => uiOnly.ScrollToCaret());
{
// scroll to the line being edited:
SnapshotPoint caretPosition = _textView.Caret.Position.BufferPosition;
_textView.ViewScroller.EnsureSpanVisible(new SnapshotSpan(caretPosition.Snapshot, caretPosition, 0));
});
} }
private void CutOrDeleteCurrentLine(bool isCut) private void CutOrDeleteCurrentLine(bool isCut)
...@@ -1049,6 +1044,7 @@ private bool HandlePostServicesReturn(bool trySubmit) ...@@ -1049,6 +1044,7 @@ private bool HandlePostServicesReturn(bool trySubmit)
// insert new line (triggers secondary prompt injection in buffer changed event): // insert new line (triggers secondary prompt injection in buffer changed event):
_currentLanguageBuffer.Insert(caretPosition, _lineBreakString); _currentLanguageBuffer.Insert(caretPosition, _lineBreakString);
IndentCurrentLine(_textView.Caret.Position.BufferPosition); IndentCurrentLine(_textView.Caret.Position.BufferPosition);
UIThread(uiOnly => uiOnly.ScrollToCaret());
return true; return true;
} }
......
...@@ -961,6 +961,14 @@ private void AddLanguageBuffer() ...@@ -961,6 +961,14 @@ private void AddLanguageBuffer()
// projection buffer update must be the last operation as it might trigger event that accesses prompt line mapping: // projection buffer update must be the last operation as it might trigger event that accesses prompt line mapping:
_window.AppendProjectionSpans(promptSpan, languageSpan); _window.AppendProjectionSpans(promptSpan, languageSpan);
} }
public void ScrollToCaret()
{
var textView = _window._textView;
var caretPosition = textView.Caret.Position.BufferPosition;
var caretSpan = new SnapshotSpan(caretPosition.Snapshot, caretPosition, 0);
textView.ViewScroller.EnsureSpanVisible(caretSpan);
}
} }
internal enum State internal enum State
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册