From 1921f87191d1f0208765dc0cb1ec6d89e9e74f42 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Thu, 25 Sep 2025 09:49:37 +0100 Subject: [PATCH] handle edge case which deleted newline incorrectly when it shouldn't, passing failing test for 'dk' motion --- fcore/normal-mode/make-normal-delete.sml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fcore/normal-mode/make-normal-delete.sml b/fcore/normal-mode/make-normal-delete.sml index cd8b957..8849dfe 100644 --- a/fcore/normal-mode/make-normal-delete.sml +++ b/fcore/normal-mode/make-normal-delete.sml @@ -540,8 +540,17 @@ struct NormalFinish.clearMode app else if newCursorLineNumber = 0 then (* deleting from current line to start of file *) - let val endOfLine = Cursor.viDlr (buffer, cursorIdx, 1) + 2 - in finishDeleteLineBack (app, buffer, 0, endOfLine, endOfLine, time) + let + val endOfLine = Cursor.viDlr (buffer, cursorIdx, 1) + + (* edge case: if we are on a newline (if endOfLine = cursorIdx) + * then we only want to delete 1 character at this line, + * which is the newline the cursor is at. + * Otherwise, we want to delete 2 chars by default. *) + val endOfLine = + if endOfLine = cursorIdx then endOfLine + 1 else endOfLine + 2 + in + finishDeleteLineBack (app, buffer, 0, endOfLine, endOfLine, time) end else let