amend motion to move to a line: if the requested line has a linebreak as the next character after it, stay at the current position, or else add 1 to the linebreak's idx so that we go to the first character of the line
This commit is contained in:
@@ -1044,7 +1044,7 @@ struct
|
|||||||
* increment by 1 as we want to go to first char after line break *)
|
* increment by 1 as we want to go to first char after line break *)
|
||||||
bufferIdx + lineIdx
|
bufferIdx + lineIdx
|
||||||
else
|
else
|
||||||
bufferIdx + lineIdx + 1
|
bufferIdx + lineIdx
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
| (_, _) =>
|
| (_, _) =>
|
||||||
|
|||||||
@@ -129,8 +129,17 @@ struct
|
|||||||
|
|
||||||
(* get idx of first chr after linebreak *)
|
(* get idx of first chr after linebreak *)
|
||||||
val cursorIdx = Cursor.getLineStartIdx (buffer, reqLine)
|
val cursorIdx = Cursor.getLineStartIdx (buffer, reqLine)
|
||||||
|
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
|
||||||
|
(* we got the line start idx, but we want to move to the index
|
||||||
|
* after it, where the first character of the line is.
|
||||||
|
* Unless the next character is a line break,
|
||||||
|
* in which case we want to stay at the current idx. *)
|
||||||
|
val cursorIdx =
|
||||||
|
if Cursor.isNextChrEndOfLine (buffer, cursorIdx) then cursorIdx
|
||||||
|
else cursorIdx + 1
|
||||||
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
|
||||||
val visualScrollColumn =
|
val visualScrollColumn =
|
||||||
TextScroll.getScrollColumn
|
TextScroll.getScrollColumn
|
||||||
(buffer, cursorIdx, windowWidth, prevScrollColumn)
|
(buffer, cursorIdx, windowWidth, prevScrollColumn)
|
||||||
|
|||||||
Reference in New Issue
Block a user