fix minor bug regarding 'NormalMove.moveCursorDown': after a <count-j> that moved the cursor to the last line in the buffer, the cursor would be at the last column too, even if that wasn't the previous column. To address this issue, we take out code that calculates the lineIdx from the 'NormalMove.finishMoveCursorUpDown' function, and have both 'NormalMove.moveCursorUp' and 'NormalMove.moveCursorDown' calculate their own lineIdx in different ways and pass it to the 'NormalMove.finishMoveCursorUpAndDown' function.
This commit is contained in:
@@ -108,7 +108,7 @@ struct
|
||||
end
|
||||
|
||||
fun finishMoveCursorUpDown
|
||||
(app: app_type, newCursorLineNumber, buffer, column) =
|
||||
(app: app_type, newCursorLineNumber, buffer, column, lineIdx) =
|
||||
let
|
||||
val
|
||||
{ windowWidth
|
||||
@@ -121,13 +121,6 @@ struct
|
||||
, ...
|
||||
} = app
|
||||
|
||||
val buffer = LineGap.goToLine (newCursorLineNumber, buffer)
|
||||
val lineIdx = LineGap.lineNumberToIdx (newCursorLineNumber, buffer)
|
||||
val buffer = LineGap.goToIdx (lineIdx, buffer)
|
||||
val lineIdx =
|
||||
if Cursor.isNextChrEndOfLine (buffer, lineIdx) then lineIdx
|
||||
else lineIdx + 1
|
||||
|
||||
val buffer = LineGap.goToIdx (lineIdx, buffer)
|
||||
val endOfLineIdx = Cursor.viDlr (buffer, lineIdx, 1)
|
||||
val endOfLineIdx =
|
||||
@@ -200,8 +193,15 @@ struct
|
||||
LineGap.idxToLineNumber (cursorIdx, buffer)
|
||||
val newCursorLineNumber = Int.max (cursorLineNumber - count, 0)
|
||||
val column = if newCursorLineNumber = 0 then column - 1 else column
|
||||
|
||||
val buffer = LineGap.goToLine (newCursorLineNumber, buffer)
|
||||
val lineIdx = LineGap.lineNumberToIdx (newCursorLineNumber, buffer)
|
||||
val buffer = LineGap.goToIdx (lineIdx, buffer)
|
||||
val lineIdx =
|
||||
if Cursor.isNextChrEndOfLine (buffer, lineIdx) then lineIdx
|
||||
else lineIdx + 1
|
||||
in
|
||||
finishMoveCursorUpDown (app, newCursorLineNumber, buffer, column)
|
||||
finishMoveCursorUpDown (app, newCursorLineNumber, buffer, column, lineIdx)
|
||||
end
|
||||
|
||||
fun moveCursorDown (app: app_type, count) =
|
||||
@@ -236,8 +236,22 @@ struct
|
||||
Int.max (0, #lineLength buffer - 1)
|
||||
else
|
||||
newCursorLineNumber
|
||||
|
||||
val buffer = LineGap.goToLine (newCursorLineNumber, buffer)
|
||||
val lineIdx = LineGap.lineNumberToIdx (newCursorLineNumber, buffer)
|
||||
val buffer = LineGap.goToIdx (lineIdx, buffer)
|
||||
val lineIdx =
|
||||
if lineIdx >= #textLength buffer - 2 then
|
||||
Int.max (0, #textLength buffer - 2)
|
||||
else
|
||||
lineIdx
|
||||
val lineIdx =
|
||||
if Cursor.isNextChrEndOfLine (buffer, lineIdx) then lineIdx
|
||||
else lineIdx + 1
|
||||
val buffer = LineGap.goToIdx (lineIdx, buffer)
|
||||
val lineIdx = Cursor.vi0 (buffer, lineIdx)
|
||||
in
|
||||
finishMoveCursorUpDown (app, newCursorLineNumber, buffer, column)
|
||||
finishMoveCursorUpDown (app, newCursorLineNumber, buffer, column, lineIdx)
|
||||
end
|
||||
|
||||
fun moveToLine (app: app_type, reqLine) =
|
||||
|
||||
Reference in New Issue
Block a user