progress reimplementing 'j' motion to pass new tests
This commit is contained in:
@@ -275,21 +275,45 @@ struct
|
||||
|
||||
val buffer = LineGap.goToLine (newCursorLineNumber, buffer)
|
||||
val lineIdx = LineGap.lineNumberToIdx (newCursorLineNumber, buffer)
|
||||
|
||||
val buffer = LineGap.goToIdx (lineIdx, buffer)
|
||||
|
||||
val lineIdx =
|
||||
if Cursor.isPrevChrStartOfLine (buffer, lineIdx) then lineIdx
|
||||
else lineIdx + 1
|
||||
|
||||
val lineIdx =
|
||||
if lineIdx >= #textLength buffer - 1 then
|
||||
Int.max (0, #textLength buffer - 1)
|
||||
else
|
||||
lineIdx
|
||||
in
|
||||
finishMoveCursorUpDown
|
||||
(app, newCursorLineNumber, buffer, column, lineIdx)
|
||||
if lineIdx >= #textLength buffer then
|
||||
(* we reached last line *)
|
||||
let
|
||||
val lineIdx = Int.max (#textLength buffer - 1, 0)
|
||||
val buffer = LineGap.goToIdx (lineIdx, buffer)
|
||||
val startOfLine = Cursor.vi0 (buffer, lineIdx)
|
||||
in
|
||||
if cursorIdx >= startOfLine then
|
||||
(* we are already on last line so don't move *)
|
||||
NormalFinish.buildTextAndClear
|
||||
(app, buffer, cursorIdx, searchList, [], bufferModifyTime)
|
||||
else
|
||||
finishMoveCursorUpDown
|
||||
(app, newCursorLineNumber, buffer, column, startOfLine)
|
||||
end
|
||||
else if lineIdx = #textLength buffer - 1 then
|
||||
(* last line in buffer ends with \n
|
||||
* and we just reached it *)
|
||||
let val () = print "296\n"
|
||||
in raise Fail ""
|
||||
end
|
||||
else
|
||||
let
|
||||
val lineIdx =
|
||||
if lineIdx >= #textLength buffer - 2 then
|
||||
Int.max (0, #textLength buffer - 2)
|
||||
else
|
||||
lineIdx
|
||||
|
||||
val buffer = LineGap.goToIdx (lineIdx, buffer)
|
||||
val lineIdx =
|
||||
if Cursor.isOnNewlineAfterChr (buffer, lineIdx) then lineIdx + 1
|
||||
else lineIdx
|
||||
in
|
||||
finishMoveCursorUpDown
|
||||
(app, newCursorLineNumber, buffer, column, lineIdx)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user