Commit Graph

  • 1f5e933772 add failing test for 'dk' motion, when cursor is on last character of line Humza Shahid 2025-09-25 10:38:57 +01:00
  • c13ef69a9e pass failing test for 'dk' by paying attention to newlines Humza Shahid 2025-09-25 10:31:02 +01:00
  • 5610ccf630 more descriptive name for one test Humza Shahid 2025-09-25 10:04:37 +01:00
  • 594367d6d8 add another failing unit test for 'dk' motion Humza Shahid 2025-09-25 10:02:16 +01:00
  • 1921f87191 handle edge case which deleted newline incorrectly when it shouldn't, passing failing test for 'dk' motion Humza Shahid 2025-09-25 09:49:37 +01:00
  • 75b4f11822 add failing test for 'dk' motion Humza Shahid 2025-09-25 09:30:07 +01:00
  • de8f5b7761 add a few more tests for 'dk' motion Humza Shahid 2025-09-25 09:19:15 +01:00
  • 02cc5a0e53 make failing test for 'dk' motion pass by appending a newline to the buffer if the buffer becomes empty Humza Shahid 2025-09-25 09:09:18 +01:00
  • 2c3eb6a8a1 begin adding tests for 'dk' motion Humza Shahid 2025-09-25 09:03:40 +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 Humza Shahid 2025-09-25 08:34:23 +01:00
  • 5264cbfac8 add tests for 'dd' motion, and they all pass Humza Shahid 2025-09-25 07:15:17 +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 Humza Shahid 2025-09-25 06:34:08 +01:00
  • cddd03812b implement first pass of 'MakeNormalDelete.deleteLine'; have to add tests for this next Humza Shahid 2025-09-25 06:23:12 +01:00
  • efaadf1337 a bit of refactoring Humza Shahid 2025-09-25 06:18:12 +01:00
  • b73117d075 add failing test for 'dj' motion, and progress reimplementing 'MakeNormalDelete.deleteLine' Humza Shahid 2025-09-25 06:11:36 +01:00
  • d25a06a9ed progress reimplementing 'MakeNormalDelete.deleteLine Humza Shahid 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 Humza Shahid 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. Humza Shahid 2025-09-25 04:56:25 +01:00
  • 1255238d6c pass failing tests for 'dj' motion Humza Shahid 2025-09-24 19:32:31 +01:00
  • 2076d25653 begin reimplementing 'MakeNormalDelete.deleteLine' function Humza Shahid 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. Humza Shahid 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 Humza Shahid 2025-09-24 09:46:28 +01:00
  • e70aab8952 add another failing test for 'dl' motion Humza Shahid 2025-09-24 09:07:26 +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 Humza Shahid 2025-09-24 09:02:33 +01:00
  • c500704f04 add failing tests for 'dj' motion Humza Shahid 2025-09-24 08:54:13 +01:00
  • a8bc405727 add failing test for 'dl' motion Humza Shahid 2025-09-24 07:58:45 +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 Humza Shahid 2025-09-24 07:18:11 +01:00
  • 51a7c358ca found bug in '0' motion, added test for it, and fixed it as well Humza Shahid 2025-09-23 16:05:23 +01:00
  • 9a15b1715a pass all tests for 'j' motion Humza Shahid 2025-09-23 15:30:28 +01:00
  • 95a4f109bd progress reimplementing 'j' motion to pass new tests Humza Shahid 2025-09-23 15:22:49 +01:00
  • c3ca8dddf4 add additional failing unit test for 'j' motion Humza Shahid 2025-09-23 13:30:54 +01:00
  • 109fda187a add a new failing test, and modify 'TestUtils.init' function (which takes a string and returns an AppType.app_type) so that it does not automatically add a newline to the end of strings. (This modification required changing the strings in some tests, as those strings did not have newlines at the end but the test assumes they did.) Humza Shahid 2025-09-23 13:18:36 +01:00
  • 2376ae07b5 fix tests which broke due to a design decision (how to handle newlines) Humza Shahid 2025-09-23 12:15:14 +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) Humza Shahid 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. Humza Shahid 2025-09-23 11:47:25 +01:00
  • 5fded45303 remove redundant test Humza Shahid 2025-09-23 11:11:33 +01:00
  • 4f20379219 take care of a few tests after refactoring/making a different design decision Humza Shahid 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) Humza Shahid 2025-09-23 10:50:10 +01:00
  • 8931d4d071 fix minor compilation error introduced in previous commit Humza Shahid 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 Humza Shahid 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 Humza Shahid 2025-09-23 09:16:02 +01:00
  • 505521f5e2 minor cosmetic change Humza Shahid 2025-09-23 09:04:18 +01:00
  • 6be1d48b02 add test for 'k' motion: when file ends with two newlines and cursor is on newline_1 in the pattern (char -> newline_1 -> newline_2), we should be able to move up by a line Humza Shahid 2025-09-23 09:00:50 +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 Humza Shahid 2025-09-23 08:54:19 +01:00
  • 494d56e997 add two new tests to check that 'w' motion does not let cursor go to last newline in file, but does let cursor go to second-last newline Humza Shahid 2025-09-23 08:20:40 +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 Humza Shahid 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. Humza Shahid 2025-09-23 07:18:58 +01:00
  • ec10f3e025 tiny amount of formatting Humza Shahid 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 Humza Shahid 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 Humza Shahid 2025-09-23 06:09:03 +01:00
  • 12bd30d9dd pull in new version of brolib-sml, which contains a bug fix for 'LineGap.delete' Humza Shahid 2025-09-22 15:07:45 +01:00
  • d6e119a161 fix bug in line_gap.sml's 'deleteRightFromHere' function: when we reach end of buffer, return with current index and current line instead of setting these to 0, and return input leftString and leftLines when we reach the end, instead of an empty list for these fields, because all of our text content is in those values and it would disappear if we return empty lists instead Humza Shahid 2025-09-22 15:06:36 +01:00
  • cb0dec93a0 simplify implementation of 'MakeNormalDelete.deleteLine Humza Shahid 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 Humza Shahid 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 Humza Shahid 2025-09-22 12:28:08 +01:00
  • d3c6031b19 pull in new version of brolib-sml, which has bug fixes for line_gap.sml's 'lineNumberToIdx' function Humza Shahid 2025-09-22 10:30:00 +01:00
  • 5b6b13278b remove unused arguments from 'moveLeft' and 'moveRight' functions in line_gap.sml, and adjust the callers of these functions so that they do not pass these parameters Humza Shahid 2025-09-22 10:23:29 +01:00
  • d76ab0c3fe fix bug in line_gap.sml's 'lineNumberToIdxRight' function: when calling 'lineNumberToIdxRight', pass tails of 'rightStrings' and 'rightLines', instead of passing 'rightStrings' and 'rightLines' themselves, so that we advance through the list Humza Shahid 2025-09-22 10:20:27 +01:00
  • 6f968ee8e5 in 'dk' motion, make sure we move the cursor to the start of the previous line in all cases Humza Shahid 2025-09-22 09:46:43 +01:00
  • 90eeb6e570 restore temp.txt to original version, as it was being edited for testing purposes Humza Shahid 2025-09-22 07:46:45 +01:00
  • a890381f2a amend vi's 'k' tests after having reimplemented 'k' motion Humza Shahid 2025-09-22 07:13:04 +01:00
  • e6ea96f995 fix bug in 'k' motion: when we move from any other line to line 0, always unconditionally decrement column by 1 Humza Shahid 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 Humza Shahid 2025-09-22 06:49:00 +01:00
  • 4dc73aa4d6 amend tests for vi's 'j' motion, after having reimplemented it Humza Shahid 2025-09-22 05:37:54 +01:00
  • 5315aff600 reimplement 'j' motion so that newline is skipped only if immediately preceded by char Humza Shahid 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 Humza Shahid 2025-09-22 04:10:39 +01:00
  • 4c5c1f304a amend a test to respect new viH implementation Humza Shahid 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 Humza Shahid 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 Humza Shahid 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 Humza Shahid 2025-09-21 16:40:05 +01:00
  • 3ea44d9725 progress reimplementing 'NormalDelete.deleteLineBack' function Humza Shahid 2025-09-21 15:45:14 +01:00
  • 68cd2a33cf add tests for 'dl' motion Humza Shahid 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. Humza Shahid 2025-09-21 00:22:24 +01:00
  • 3b27e437bc add a failing test for 'dl' motion Humza Shahid 2025-09-20 23:59:14 +01:00
  • 46ab3d20e7 add tests to verify that cursorIdx is as expected after 'dh' delete motion Humza Shahid 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 Humza Shahid 2025-09-20 18:04:59 +01:00
  • a0add68e92 begin adding normal-delete tests Humza Shahid 2025-09-20 17:59:22 +01:00
  • 6b05c9a07a done addint to hjkl movement tests Humza Shahid 2025-09-20 10:04:38 +01:00
  • a81d45b3b3 add additional tests for 'j' motion Humza Shahid 2025-09-20 08:09:35 +01:00
  • ec091b56a3 add additional tests for 'l' motion Humza Shahid 2025-09-20 06:31:14 +01:00
  • 60cbb33cb6 add additional tests for 'h' motion Humza Shahid 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 Humza Shahid 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. Humza Shahid 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) Humza Shahid 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 Humza Shahid 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 Humza Shahid 2025-09-19 22:33:37 +01:00
  • 2c88341c37 remove code which became dead after reimplementing vi's 'k' motion Humza Shahid 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 Humza Shahid 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 Humza Shahid 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. Humza Shahid 2025-09-19 04:45:29 +01:00
  • 8c56f9cc95 fix typo in line_gap.sml which caused a compilation error Humza Shahid 2025-09-19 04:40:34 +01:00
  • 38c1766b14 pull in new version of brolib-sml, which adds a function to convert a line number to an index Humza Shahid 2025-09-19 04:38:52 +01:00
  • 7ea31ace35 add function to LineGap to get the index of a line number Humza Shahid 2025-09-19 04:37:21 +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 Humza Shahid 2025-09-19 04:03:54 +01:00
  • d871ac451f restore temp.txt to previous state, as it was temporarily being edited for testing Humza Shahid 2025-09-19 03:04:10 +01:00
  • ab2f2cc752 simplify 'vi-hl-dfa's DFA, removing one state Humza Shahid 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 Humza Shahid 2025-09-17 11:02:11 +01:00
  • dbf05ec8dc refactor Cursor.viH to use DFA Humza Shahid 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. Humza Shahid 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 Humza Shahid 2025-09-17 02:35:32 +01:00