change line indexing in AppUpdate.moveToLine from 0-based to 1-based (so first line can be access with 1G, second with 2G, as is normal with Vim)

This commit is contained in:
2024-11-04 02:56:57 +00:00
parent 66d4346c74
commit a0a8fcc17b
2 changed files with 28 additions and 20 deletions

View File

@@ -69,8 +69,13 @@ struct
val bufferLine = bufferLine - 1 val bufferLine = bufferLine - 1
val buffer = LineGap.goToIdx (bufferIdx, buffer) val buffer = LineGap.goToIdx (bufferIdx, buffer)
val bufferLine = TextWindow.getStartLineWithCursorCentered val bufferLine =
(buffer, bufferIdx, bufferLine, windowWidth, windowHeight) let
val maxHeight = windowHeight - (TextConstants.ySpace * 2)
in
TextWindow.getStartLineWithCursorCentered
(buffer, bufferIdx, bufferLine, windowWidth, maxHeight)
end
val buffer = LineGap.goToLine (bufferLine, buffer) val buffer = LineGap.goToLine (bufferLine, buffer)
val drawMsg = val drawMsg =
@@ -85,6 +90,9 @@ struct
end end
fun moveToLine (app: app_type, reqLine) = fun moveToLine (app: app_type, reqLine) =
if reqLine = 0 then
moveToStart app
else
let let
val {windowWidth, windowHeight, buffer, startLine = origLine, ...} = app val {windowWidth, windowHeight, buffer, startLine = origLine, ...} = app
val buffer = LineGap.goToLine (reqLine, buffer) val buffer = LineGap.goToLine (reqLine, buffer)
@@ -285,7 +293,7 @@ struct
if String.size str = 0 then if String.size str = 0 then
moveToEnd app moveToEnd app
else else
moveToLine (app, count) moveToLine (app, count - 1)
| #"%" => moveToMatchingPair app | #"%" => moveToMatchingPair app
(* multi-char commands which can be appended *) (* multi-char commands which can be appended *)
| #"t" => appendChr (app, chr, str) | #"t" => appendChr (app, chr, str)

BIN
shf

Binary file not shown.