Commit Graph

493 Commits

Author SHA1 Message Date
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
4dc73aa4d6 amend tests for vi's 'j' motion, after having reimplemented it 2025-09-22 05:37:54 +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
8ca8d1db29 add new tests for 'l' motion to ensure that newlines are only skipped when they are preceded by chars 2025-09-22 04:10:39 +01:00
4c5c1f304a amend a test to respect new viH implementation 2025-09-21 21:45:30 +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
68cd2a33cf add tests for 'dl' motion 2025-09-21 00:34:02 +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
3b27e437bc add a failing test for 'dl' motion 2025-09-20 23:59:14 +01:00
46ab3d20e7 add tests to verify that cursorIdx is as expected after 'dh' delete motion 2025-09-20 23:49:30 +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
a0add68e92 begin adding normal-delete tests 2025-09-20 17:59:22 +01:00
6b05c9a07a done addint to hjkl movement tests 2025-09-20 10:04:38 +01:00
a81d45b3b3 add additional tests for 'j' motion 2025-09-20 08:09:35 +01:00
ec091b56a3 add additional tests for 'l' motion 2025-09-20 06:31:14 +01:00
60cbb33cb6 add additional tests for 'h' motion 2025-09-20 04:18:15 +01:00
2e77175187 refactor tests a bit by putting LineGap-creation functionality into TestUtils.init, and make sure we also add a Unix-style newline to the end of the string if it doesn't already have one 2025-09-20 03:44:48 +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
090e7ccea2 pass 'maxLength' value to TextScroll function so that we can prevent scrolling past the bottom of the file (unless we want to od so by centtering the screen) 2025-09-19 23:17:28 +01:00
d3fa4d08bf extract reusable function containing common code previously used in both 'NormalMove.moveCursorUp' and 'NormalMove.moveCursorDown' functions, and make them call the reusable function instead 2025-09-19 22:40:29 +01:00
859860b19f reimplement vi's 'j' motion, and remove the original function for this motion which was in cursor.sml 2025-09-19 22:33:37 +01:00
2c88341c37 remove code which became dead after reimplementing vi's 'k' motion 2025-09-19 05:27:10 +01:00
9ec8891ce5 fix bugs in new function for moving cursor upwards, taking care to calculate column different if on first line (where there is no preceding newline) vs any line other than the first 2025-09-19 05:23:20 +01:00
4c1a76ae67 begin reimplementing motion to move cursor up (vi's 'k' command), although it is in progress and buggy 2025-09-19 04:59:40 +01:00
e4e3961d41 in NormalMove.moveToLine function, use new LineGap function, 'LineGap.lineNumberToIdx', to get the index a line is at, and delete the Cursor.getLineStartIdx' function which we no longer need, as that functionality is in brolib-sml itself. 2025-09-19 04:45:29 +01:00
38c1766b14 pull in new version of brolib-sml, which adds a function to convert a line number to an index 2025-09-19 04:38:52 +01:00
b6244d4962 amend motion to move to a line: if the requested line has a linebreak as the next character after it, stay at the current position, or else add 1 to the linebreak's idx so that we go to the first character of the line 2025-09-19 04:03:54 +01:00
d871ac451f restore temp.txt to previous state, as it was temporarily being edited for testing 2025-09-19 03:04:10 +01:00
ab2f2cc752 simplify 'vi-hl-dfa's DFA, removing one state 2025-09-19 02:40:14 +01:00
ad7d103f61 rename 'ViLDfa' structure to 'ViHlDfa' since this DFA implements both vi's 'h' motion and vi's 'l' motion 2025-09-17 11:02:11 +01:00
dbf05ec8dc refactor Cursor.viH to use DFA 2025-09-17 10:45:37 +01:00
9ddb5f68d7 fix bugs in vi-l-dfa (we want to stop looping when the counter is ~1, because the starting character will likely be final/a not-newline, and we want to loop at least once; also, we want to special case 'twoNewlineState' as a final case which causes us to go backwards by 1 instead of treating 'oneNewlineState' as a final/special case). We also modify other code to use the new vi-l implementation in the program. 2025-09-17 03:52:31 +01:00
5174a5b0a4 adjustments to vi-l-dfa: we should accept a single-newline as a final state, but not a double-newline 2025-09-17 02:35:32 +01:00
161caee62a create DFA for Vi's 'l' motion 2025-09-17 02:31:38 +01:00
c94aa72015 create 'MakeIfCharFolderNext' functor, which mirrors the 'MakeIfCharFolderPrev' functor that we already have 2025-09-17 02:20:36 +01:00
97936b83a0 in TextBuilder functions, when we encounter a newline, we want any cursor here to be drawn after a linebreak (after the posX and posY values go to the next line) and not before 2025-09-16 22:29:19 +01:00
1adb74df2c pull in new brolib-sml changes (which just changes one particular function's name to be clearer), and modify code to use the correct name 2025-09-16 22:20:55 +01:00
c4fedc6434 fix 'Cursor.getLineStartIdx' function, which should look at the left nodes if there is no relevant line in this node 2025-09-16 22:09:15 +01:00
96521f358f when looping through a DFA in a functor, make sure we return the absolute index to the calling function and not a modified version of the absolute index which has already been clipped 2025-09-16 21:35:48 +01:00
12478f8ac2 remove references to 'Cursor.clipIdx' and delete that function once it is no longer used 2025-09-16 16:08:01 +01:00
578d3af5ec remove changes to temp.txt which were only for testing 2025-09-16 15:55:16 +01:00
19d2235686 refactor 'MakeNormalDelete.removeLineBreaks' function to remove function call to 'Cursor.clipIdx', instead relying on textLength field in buffer 2025-09-16 15:53:41 +01:00
2c5449dc0a rewrite 'MakeMove' functor in fcore/move.sml to use textLength field instead of Cursor.clipIdx function 2025-09-16 07:59:26 +01:00
148b108062 when using 'G' command to move to end fo file, use the 'textLength' field to calculate the new bufferIdx, which is more sensible than using the LineGap's idx for the same purpose 2025-09-16 07:52:47 +01:00
3d9bf962e7 handle additional deleteLine edge case 2025-09-16 07:40:58 +01:00
70ffea21b3 fix the last MakeNormalDelete.deleteLine bug: if we delete such that the startIdx (prior to deletion) becomes longer than the text in the buffer, we move the cursor to the start of the last line 2025-09-16 07:01:55 +01:00
6507b9d49c adjust MakeNormalDelete.deleteLine implementation slightly, because the previous implementation did not delete the last character when we are at the end of the file 2025-09-16 06:29:35 +01:00