aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Editor.cxx
diff options
context:
space:
mode:
authorMarko Njezic <devnull@localhost>2012-01-30 23:15:48 +0100
committerMarko Njezic <devnull@localhost>2012-01-30 23:15:48 +0100
commite1a304d01326eda8f3fb5ee7911a32ee21ca1edb (patch)
tree604fd9f4c0ae1f3dd37bde89dc8c99049d477e76 /src/Editor.cxx
parentf61e7637a96d944903917df68f5d3646c292d9a2 (diff)
downloadscintilla-mirror-e1a304d01326eda8f3fb5ee7911a32ee21ca1edb.tar.gz
Fix cursor up/down movement on wrapped lines and lines with annotations.
Bug #1776560.
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r--src/Editor.cxx46
1 files changed, 33 insertions, 13 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 8f8478e96..d4443ab45 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -5002,30 +5002,50 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) {
caretToUse = sel.Rectangular().caret;
}
}
+
Point pt = LocationFromPosition(caretToUse);
- int lineDoc = pdoc->LineFromPosition(caretToUse.Position());
- Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc));
- int subLine = (pt.y - ptStartLine.y) / vs.lineHeight;
- int commentLines = vs.annotationVisible ? pdoc->AnnotationLines(lineDoc) : 0;
- SelectionPosition posNew = SPositionFromLocation(
- Point(lastXChosen - xOffset, pt.y + direction * vs.lineHeight), false, false, UserVirtualSpace());
- if ((direction > 0) && (subLine >= (cs.GetHeight(lineDoc) - 1 - commentLines))) {
- posNew = SPositionFromLocation(
- Point(lastXChosen - xOffset, pt.y + (commentLines + 1) * vs.lineHeight), false, false, UserVirtualSpace());
+ int skipLines = 0;
+
+ if (vs.annotationVisible) {
+ int lineDoc = pdoc->LineFromPosition(caretToUse.Position());
+ Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc));
+ int subLine = (pt.y - ptStartLine.y) / vs.lineHeight;
+
+ if (direction < 0 && subLine == 0) {
+ int lineDisplay = cs.DisplayFromDoc(lineDoc);
+ if (lineDisplay > 0) {
+ skipLines = pdoc->AnnotationLines(cs.DocFromDisplay(lineDisplay - 1));
+ }
+ } else if (direction > 0 && subLine >= (cs.GetHeight(lineDoc) - 1 - pdoc->AnnotationLines(lineDoc))) {
+ skipLines = pdoc->AnnotationLines(lineDoc);
+ }
}
+
+ int newY = pt.y + (1 + skipLines) * direction * vs.lineHeight;
+ SelectionPosition posNew = SPositionFromLocation(
+ Point(lastXChosen - xOffset, newY), false, false, UserVirtualSpace());
+
if (direction < 0) {
// Line wrapping may lead to a location on the same line, so
// seek back if that is the case.
- // There is an equivalent case when moving down which skips
- // over a line but as that does not trap the user it is fine.
Point ptNew = LocationFromPosition(posNew.Position());
while ((posNew.Position() > 0) && (pt.y == ptNew.y)) {
- posNew.Add(- 1);
+ posNew.Add(-1);
+ posNew.SetVirtualSpace(0);
+ ptNew = LocationFromPosition(posNew.Position());
+ }
+ } else if (direction > 0 && posNew.Position() != pdoc->Length()) {
+ // There is an equivalent case when moving down which skips
+ // over a line.
+ Point ptNew = LocationFromPosition(posNew.Position());
+ while ((posNew.Position() > caretToUse.Position()) && (ptNew.y > newY)) {
+ posNew.Add(-1);
posNew.SetVirtualSpace(0);
ptNew = LocationFromPosition(posNew.Position());
}
}
- MovePositionTo(posNew, selt);
+
+ MovePositionTo(MovePositionSoVisible(posNew, direction), selt);
}
void Editor::ParaUpOrDown(int direction, Selection::selTypes selt) {