fix 'MakeNormalDelete.deleteLineBack' test, which failed because we were using the wrong way to check if cursor is currently at the start of the line. We checked '(endOfLine = cursorIdx) which works in most cases to verify that the current position is a newline, but fails when the cursor is at the last non-newline character of the line. This is fixed by being more precise and calling 'Cursor.isCursorAtStartOfLine' to check directly if the cursor is currently at the end of the line.

This commit is contained in:
2025-09-25 10:49:20 +01:00
parent 1f5e933772
commit bf55373f6d
2 changed files with 4 additions and 3 deletions

View File

@@ -547,8 +547,9 @@ struct
* then we only want to delete 1 character at this line, * then we only want to delete 1 character at this line,
* which is the newline the cursor is at. * which is the newline the cursor is at.
* Otherwise, we want to delete 2 chars by default. *) * Otherwise, we want to delete 2 chars by default. *)
val buffer = LineGap.goToIdx (endOfLine, buffer)
val endOfLine = val endOfLine =
if endOfLine = cursorIdx then endOfLine + 1 else endOfLine + 2 if Cursor.isCursorAtStartOfLine (buffer, endOfLine) then endOfLine + 1 else endOfLine + 2
in in
finishDeleteLineBack (app, buffer, 0, endOfLine, endOfLine, time) finishDeleteLineBack (app, buffer, 0, endOfLine, endOfLine, time)
end end
@@ -560,8 +561,9 @@ struct
* then we don't want to delete the newline * then we don't want to delete the newline
* as we are already deleting the newline * as we are already deleting the newline
* at the start of this range *) * at the start of this range *)
val buffer = LineGap.goToIdx (endOfLine, buffer)
val endOfLine = val endOfLine =
if endOfLine = cursorIdx then endOfLine else endOfLine + 1 if Cursor.isCursorAtStartOfLine (buffer, endOfLine) then endOfLine else endOfLine + 1
val buffer = LineGap.goToLine (newCursorLineNumber, buffer) val buffer = LineGap.goToLine (newCursorLineNumber, buffer)

View File

@@ -1,5 +1,4 @@
hello hello
world world
trello trello
brillo brillo