Commit Graph

641 Commits

Author SHA1 Message Date
6b0149162f a bit of formatting 2025-09-25 10:50:02 +01:00
bf55373f6d 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. 2025-09-25 10:49:20 +01:00
c13ef69a9e pass failing test for 'dk' by paying attention to newlines 2025-09-25 10:31:02 +01:00
1921f87191 handle edge case which deleted newline incorrectly when it shouldn't, passing failing test for 'dk' motion 2025-09-25 09:49:37 +01:00
02cc5a0e53 make failing test for 'dk' motion pass by appending a newline to the buffer if the buffer becomes empty 2025-09-25 09:09:18 +01:00
0255b127a7 fix minor bug in make-dfa-loop.sml: when folding backwards using an if-statement, make sure we start folding from the leftStrings if the cursorIdx < 0 2025-09-25 08:34:23 +01:00
1000e74183 pass failing test for 'dj' motion through a different startLine calculation depending on whether cursor is already on a newline or not 2025-09-25 06:34:08 +01:00
cddd03812b implement first pass of 'MakeNormalDelete.deleteLine'; have to add tests for this next 2025-09-25 06:23:12 +01:00
efaadf1337 a bit of refactoring 2025-09-25 06:18:12 +01:00
b73117d075 add failing test for 'dj' motion, and progress reimplementing 'MakeNormalDelete.deleteLine' 2025-09-25 06:11:36 +01:00
d25a06a9ed progress reimplementing 'MakeNormalDelete.deleteLine 2025-09-25 06:04:11 +01:00
11015dfa9e add two more test cases for 'dj' motion that were failing when added, and modify 'MakeNormalDelete.deleteLineDown' to handle them 2025-09-25 05:28:13 +01:00
e24230834e rename existing 'MakeNormalDelete.deleteLine' function to 'MakeNormalDelete.deleteLineDown', make 'dj' and 'ydj' commands use the renamed function, and add a new 'MakeNormalDelete.deleteLine' function (which has no implementation yet). We do this because we want to distinguish between 'dd' and 'dj' commands, allowing 'dd' to delete to the end of the file despite any count, while stoppinhg 'dj' from deleting the file when on the last line. 2025-09-25 04:56:25 +01:00
1255238d6c pass failing tests for 'dj' motion 2025-09-24 19:32:31 +01:00
2076d25653 begin reimplementing 'MakeNormalDelete.deleteLine' function 2025-09-24 17:58:37 +01:00
80078196e0 if 'MakeNormalDelete.deleteLine' deletes to the end of the file such that there is no newline at the end, then append a newline. This makes one of the tests we have pass. 2025-09-24 13:05:13 +01:00
222a9aa43c fix 'MakeNormalDelete.removeChr' by accounting for case when we are deleting from last line but the last line does not end with its own newline 2025-09-24 09:46:28 +01:00
95393e1e13 amand MakeNormalDelete.removeChr function (which is used by 'x' and 'dh' commands) to pass test, which checks that cursorIdx does not fall on newline-after-chr after deletion 2025-09-24 09:02:33 +01:00
00ab086257 remove code related to appending newlines in 'MakeNormalDelete', as we have decided that we allow files which do not end in newlines as well as files that do 2025-09-24 07:18:11 +01:00
51a7c358ca found bug in '0' motion, added test for it, and fixed it as well 2025-09-23 16:05:23 +01:00
9a15b1715a pass all tests for 'j' motion 2025-09-23 15:30:28 +01:00
95a4f109bd progress reimplementing 'j' motion to pass new tests 2025-09-23 15:22:49 +01:00
fcc8c8085a reimplement 'G' motion so that it follows new rule (cursor goes to second-last chr if last chr is a newline preceded by a non-newline, but goes to last chr otherwise) 2025-09-23 11:57:19 +01:00
5d20b81bcc adjust functor to move by dfa so that we cannot go to the last char of the file if (last char is a newline and is preceded by a non-newline), but otherwise we can go to the last char of the file. 2025-09-23 11:47:25 +01:00
4f20379219 take care of a few tests after refactoring/making a different design decision 2025-09-23 11:04:47 +01:00
961ce63023 begin refactoring to let cursor move to very last char of file (including unix line ending) 2025-09-23 10:50:10 +01:00
8931d4d071 fix minor compilation error introduced in previous commit 2025-09-23 09:29:02 +01:00
ec462a4df7 remove special case from 'k' motion: the exact semantics we want for trailing newlines at the end of a file are currently a bit unclear and require exploration 2025-09-23 09:27:13 +01:00
21e12addf3 in text builders, check when on newline if this is the second last character in the file, and draw it on a newline if so. This is to align with the design decision that we want the second-last character to be selectable 2025-09-23 09:16:02 +01:00
505521f5e2 minor cosmetic change 2025-09-23 09:04:18 +01:00
c9365076ad handle special case with 'k' motion: when file ends with \n\n and cursor is on first \n: we should be able to move upwards from here too 2025-09-23 08:54:19 +01:00
79d232df7a amend very minor bug: when looping through DFA and hitting a 'final state', we let the next chr afterwards handle the start state, but we want the current char to handle the start state instead, as this matches vim's behaviour 2025-09-23 07:36:51 +01:00
0b0d5268fc handle edge case when deleting by DFA: when we are deleting to the end of the file and if cursor is on first character after newline, then we also want to delete preceding newline too. Or else we will end up with two newlines at the end of the file, which is not what we want. 2025-09-23 07:18:58 +01:00
ec10f3e025 tiny amount of formatting 2025-09-23 07:04:41 +01:00
9174e4923c don't deleteByDfa when buffer's length is 1, because that would mean that we would be deleting last newline in file 2025-09-23 07:04:20 +01:00
02ada5765b improve 'MakeNormalDelete.deleteByDfa' function by refraining from deleting the unix-style line ending, if DFA takes us past the ending 2025-09-23 06:09:03 +01:00
cb0dec93a0 simplify implementation of 'MakeNormalDelete.deleteLine 2025-09-22 13:02:08 +01:00
e3148e6ac1 when deleting using a DFA motion, make sure we have a linebreak at the end so that we still have unix-style line endings as an invariant 2025-09-22 12:41:33 +01:00
351f7e9bf9 fix edge case with 'd$' motion: if deleting to end of file, we need to append two newlines 2025-09-22 12:28:08 +01:00
6f968ee8e5 in 'dk' motion, make sure we move the cursor to the start of the previous line in all cases 2025-09-22 09:46:43 +01:00
e6ea96f995 fix bug in 'k' motion: when we move from any other line to line 0, always unconditionally decrement column by 1 2025-09-22 07:02:20 +01:00
3128647a5f reimplement 'k' motion so that newlines which are immediately preceded by non-newline chars are skipped 2025-09-22 06:49:00 +01:00
5315aff600 reimplement 'j' motion so that newline is skipped only if immediately preceded by char 2025-09-22 05:32:03 +01:00
cdc23945a5 reimplement vi's 'h' movement, so that we only skip newline characters that immediately follow a non-newline 2025-09-21 21:36:59 +01:00
d63201ada7 reimplement vi's 'l' motion so that we only skip a newline when it is preceded by a non-newline character 2025-09-21 17:49:30 +01:00
639f71009c done reimplementing 'MakeNormalDelete.deleteLineBack', taking care of cases where we use this motion while on the first line or on the last 2025-09-21 16:40:05 +01:00
3ea44d9725 progress reimplementing 'NormalDelete.deleteLineBack' function 2025-09-21 15:45:14 +01:00
6af2b58b0f make 'dl' motion (including count) call the same function as the 'x' motion, because they have identical behaviour. 2025-09-21 00:22:24 +01:00
2758b864bc fix bug found by unit test: when deleting leftwards, we should never delete beyond the end of the line 2025-09-20 18:04:59 +01:00
c29afbdb7c 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. 2025-09-20 02:58:51 +01:00