Commit Graph

672 Commits

Author SHA1 Message Date
1fa2a44a2f progress addressing to-do notes in fcore/normal-mode/make-normal-delete.sml, although some notes are still left. The notes that have been addressed involved cases where we create a new buffer containing just a newline, because all of the text in the buffer has been deleted otherwise. In this case, we call 'SearchList.build' and build the search-list from scratch, which is fast because only one character needs to be checked. 2026-02-08 02:16:48 +00:00
0c40cad77a done replacing direct calls to 'LineGap.delete' with calls to 'SearchList.deleteBufferAndSearchList', so that the search list is also deleted from whenever the buffer is deleted from 2026-02-07 22:27:44 +00:00
340e52019f handle edge case when deleting from buffer: if the previous match is extended into a new match, then replace the old match in the search list with the extended match 2026-02-07 02:25:45 +00:00
0ea0d44da3 add function to extend an existing match, and add tests for it 2026-02-07 00:29:58 +00:00
b02b2f53da when deleting from buffer and search list both, don't try to find any matches if the DFA is empty (has a length of 0), because that means there is no search to find a match for 2026-02-06 21:25:44 +00:00
2292c30cd3 bookmark checkpoint in refactoring code to call funhction which deletes from both (searchList and buffer), instead of just deleting buffer 2026-02-06 20:43:47 +00:00
02086e0922 code outline of a function to extend an existing match in search-list.sml. 2026-02-06 20:30:07 +00:00
11a632556c progress refactoring delete functions in fcore/normal-mode/make-normal-delete.sml so that searchList is incrementally rebuilt when buffer is deleted from 2026-02-06 09:41:39 +00:00
9c66c3f5e8 progress in changing functions to use 'PersistentVector.delete' so that search list is incremental and not rebuilt from scratch after each deletion 2026-02-06 08:57:18 +00:00
df7669b065 progress in changing functions to use 'PersistentVector.delete' so that search list is incremental and not rebuilt from scratch after each deletion 2026-02-06 08:52:11 +00:00
c856f49a6c amend merge function from persistent-vector.sml. If we reach the same depth and find that there is no space, then climb (using the stack) up by one depth, raise the depth of the smaller node by 1, and merge there. This helps ensure balance. Before, we broke a LEAF into two LEAF objects if we wanted to merge and found that there was no room, but that led to balancing problems, which are addressed by this change. 2026-02-05 23:54:31 +00:00
0f907769e3 add a function to persistent-vector.sml to check if all leaves are at the same depth (which is how we want to balance) 2026-02-05 20:39:01 +00:00
1f2af6aacd amend implementation of 'yw' so that we do not yank newline following last word in line, if we are trying to yank last word 2026-02-04 10:12:04 +00:00
83c660818e begin adding tests for 'yw' yank motion 2026-02-04 09:26:57 +00:00
2ee963a3d8 done implementing tests for yank. Also simplify 'NormalDelete.deleteLineDown' and 'NormalYank.yankLineDown' functions by removing an if-branch which can never trigger. (The code path can only be executed in the event that 'endLineIdx' is on a newline, and there is an if-expression in that branch checking whether 'endLineIdx' is on a newline, which is redundant.) 2026-01-31 22:20:52 +00:00
c0d4155808 adjust 'NormalYank.yankLineDown' function to pass failing test 2026-01-31 21:53:32 +00:00
000cf4ab62 implement 'yj' motion. (Next: add tests for it.) 2026-01-31 12:05:16 +00:00
faa15866f8 seems like 'NormalYankDelete' functions need to yank one character more than the deletion range, so implement that, and make note to add tests for that module 2026-01-23 21:08:12 +00:00
c6dee6e9f9 implement function that deletes from both LineGap.t and SearchList, maintaining an exact match between both 2026-01-18 09:59:00 +00:00
5e3e8b39b1 add function in PersistentVector to insert a match while keeping same absolute indices (to be used when a new match appears after a deletion) 2026-01-18 08:52:38 +00:00
185ef3fc12 done implementing 'PersistentVector.merge', which means that 'PersistentVector.delete' is now complete. (Todo: test 'PersistentVector.delete'.) 2026-01-18 06:58:41 +00:00
79a0c95a58 implement another case for 'PersistentVector.merge': merge when right depth is greater than left depth 2026-01-18 06:52:49 +00:00
7b05490812 progress implementing 'PersistentVector.merge' for case where left subtree and right subtree have same depth 2026-01-18 06:40:22 +00:00
66d672505a fix calculation of number to decrement by in 'PersistentVector.delete', after additional test showed that calculation resulted in incorrect metadata. (Todo: just implement function to merge left and right subtrees.) 2026-01-18 00:27:03 +00:00
83bb852ae2 add another test for 'PersistentVector.delete 2026-01-17 23:45:20 +00:00
1c947eab7d add a test for 'PersistentVector.delete' (even though the 'PersistentVector.merge' helper function is unimplemented) 2026-01-17 23:27:36 +00:00
ee58556bde progress implementing 'PersistentVector.delete'. (Todo: implement function to merge left and right vectors.) 2026-01-17 23:14:05 +00:00
b84713a98e add 'PersistentVector.countDepth' function, which is meant to count the depth, and is to be used for deletion 2026-01-17 22:51:06 +00:00
4280f580a2 add function to decrement persistent-vector.sml. (The plan is to split the left and right, and then decrement the right metadata so that the absolute indices match.) 2026-01-17 22:46:08 +00:00
98ec1fbee6 fix another size-recalculation mistake in 'PersistentVector.splitRight' function. (When we are splitting in the middle of a BRANCH, we want to subtract the old child size from the remainder, and then add the new child size to the remainder, because this calculation will account for the splitting of preceding elements.) 2026-01-16 22:40:38 +00:00
e52d4856ee amend recalculation of size metadata in 'PersistentVector.splitRIght: we always want to decrement by prevSize in this function. (We will have another function call to decrement so that left split and right split represent the same absolute indices when they are joined, before they are split.) 2026-01-16 22:31:43 +00:00
ddcb0ea56d finish initial implementation for 'PersistentVector.splitRight' 2026-01-16 22:16:44 +00:00
eb316d7be2 begin implementation of PersistentVector.splitRight function 2026-01-16 21:58:59 +00:00
2058a57026 add functions for testing persistent-vector.sml 2026-01-15 07:16:04 +00:00
559b254b0c initial implementation of 'PersistentVector.splitLeft' function 2026-01-15 06:13:38 +00:00
79fda65f78 begin coding 'PersistentVector.splitLeft' function 2026-01-15 05:51:22 +00:00
267c0c5d96 change persistent-vector.sml's 'prevMatch' function to use rope-like metadata, and remove dead code 2026-01-15 05:39:55 +00:00
d6da7a3ea3 persistent-vector.sml was in a partial state where some functions use rope-like metadata and some functions do not, so change 'nextMatch' function to use rope-like metatadata (still need to change other functions) 2026-01-15 05:25:17 +00:00
e1077b7780 add tests for 'yk' motion (next: implement 'yj' motion and test it) 2026-01-14 04:49:41 +00:00
66f1fb0b5e implement 'yk' motion (next: add tests for it) 2026-01-13 23:54:48 +00:00
e37e04a2a2 rename 'NormalDelete.deleteLineBack' function to 'NormalDelete.deleteLineUp' which is clearer ('k' in 'dk' motion means move cursor up one line) 2026-01-13 23:40:29 +00:00
f1dd822d5b add tests for 'yl' motion 2026-01-07 07:52:06 +00:00
407f78ce7a fix bug in 'NormalYank.yankRight' function. Instead of calling 'Int.max (endOfLineIdx, high)', we should call 'Int.min (endOfLineIdx, high)' because we are trying to get the smaller number, and not the largest. 2026-01-07 06:55:42 +00:00
cc4716f3db refactor fcore/normal-yank.sml a bit (replace repeated logic with a function call) 2026-01-07 06:49:52 +00:00
8b0031ca71 add tests for 'yh' motion 2026-01-07 06:33:10 +00:00
adb8757ed8 implemented 'yh' motion (yank left) 2026-01-05 10:39:42 +00:00
210d535b9f reimplement 'da<symbol>' motion to first check if it is inside a symbol-pair, just like 'di<symbol>' was reimplemented in recent commits 2026-01-03 08:36:07 +00:00
ba6798f476 make implementation of 'di<symbol>' more robust (we check if the cursor is inside a symbol-pair before checking if there is a symbol pair after the cursor), and add tests for 'di<symbol>' motion 2026-01-03 08:09:08 +00:00
bce2a5a22d finish reimplementing 'di<symbol>' and 'da<symbol>' motions so that they align more closely with the behaviour of Vim. (Todo: test them next) 2026-01-02 20:07:36 +00:00
886f384490 when deleting inside pair, instead of searching either for either chr1 or chr2 and stopping at first match, search instead for openChr and closeChr, and keep an integer tracking what level of nesting we are at. This gives us the behaviour we want, which is to delete the pair at the correct level of nesting. When we encounter openChr, we increment the nesting counter by 1 and continue searching. When we encounter closeChr, if the nesting counter is 0, we return the current index, but if the nesting counter is higher than 0 when encounter closeChr, we decrement the nesting counter by 1 and continue searching. 2026-01-02 18:50:04 +00:00