address remainning todo-notes, which had to do with updating the searchList when we insert into a buffer.

This commit is contained in:
2026-02-08 03:17:19 +00:00
parent c28ae4d8cd
commit 33866533a3
5 changed files with 22 additions and 30 deletions

View File

@@ -185,11 +185,10 @@ struct
(app, cursorIdx, buffer, searchList, time, []) (app, cursorIdx, buffer, searchList, time, [])
else else
let let
(* todo: have not implemented search-list-rebuilding
* for insertions yet *)
val (buffer, searchList) = SearchList.deleteBufferAndSearchList val (buffer, searchList) = SearchList.deleteBufferAndSearchList
(newCursorIdx, 1, buffer, searchList, dfa) (newCursorIdx, 1, buffer, searchList, dfa)
val buffer = LineGap.insert (newCursorIdx, " ", buffer) val (buffer, searchList) = SearchList.insert
(newCursorIdx, " ", buffer, searchList, dfa)
in in
helpRemoveLineBreaks helpRemoveLineBreaks
(app, buffer, newCursorIdx, count - 1, time, searchList, dfa) (app, buffer, newCursorIdx, count - 1, time, searchList, dfa)
@@ -233,11 +232,10 @@ struct
NormalFinish.clearMode app NormalFinish.clearMode app
else else
let let
(* todo: have not implemented search-list-rebuilding
* for insertions yet *)
val (buffer, searchList) = SearchList.deleteBufferAndSearchList val (buffer, searchList) = SearchList.deleteBufferAndSearchList
(newCursorIdx, 1, buffer, searchList, dfa) (newCursorIdx, 1, buffer, searchList, dfa)
val buffer = LineGap.insert (newCursorIdx, " ", buffer) val (buffer, searchList) = SearchList.insert
(newCursorIdx, " ", buffer, searchList, dfa)
in in
helpRemoveLineBreaks helpRemoveLineBreaks
(app, buffer, newCursorIdx, count - 1, time, searchList, dfa) (app, buffer, newCursorIdx, count - 1, time, searchList, dfa)

View File

@@ -26,28 +26,17 @@ struct
end end
local local
fun loop (app: app_type, cursorIdx, buffer, count, time) = fun loop (app: app_type, cursorIdx, buffer, searchList, count, time) =
if count = 0 then if count = 0 then
let NormalDelete.finishAfterDeletingBuffer
open MailboxType (app, #cursorIdx app, buffer, searchList, time, [])
val {cursorIdx = origCursorIdx, dfa, ...} = app
val buffer = LineGap.goToStart buffer
(* todo: try updating searchList incrementally
* instead of rebuilding from scratch *)
val (buffer, searchList) = SearchList.build (buffer, dfa)
in
NormalDelete.finishAfterDeletingBuffer
(app, origCursorIdx, buffer, searchList, time, [])
end
else else
let let
val buffer = LineGap.goToIdx (cursorIdx, buffer) val buffer = LineGap.goToIdx (cursorIdx, buffer)
val lineStart = Cursor.vi0 (buffer, cursorIdx) val lineStart = Cursor.vi0 (buffer, cursorIdx)
(* todo: update searchList based on insert *) val (buffer, searchList) = SearchList.insert
val buffer = LineGap.insert (lineStart, " ", buffer) (lineStart, " ", buffer, searchList, #dfa app)
val buffer = LineGap.goToIdx (lineStart, buffer) val buffer = LineGap.goToIdx (lineStart, buffer)
val lineEnd = Cursor.viDlr (buffer, lineStart, 1) val lineEnd = Cursor.viDlr (buffer, lineStart, 1)
@@ -56,11 +45,13 @@ struct
val count = if lineEnd = nextLine then 0 else count - 1 val count = if lineEnd = nextLine then 0 else count - 1
in in
loop (app, nextLine, buffer, count, time) loop (app, nextLine, buffer, searchList, count, time)
end end
in in
fun indnetLine (app: app_type, count, time) = fun indnetLine (app: app_type, count, time) =
loop (app, #cursorIdx app, #buffer app, count, time) let val {buffer, searchList, cursorIdx, ...} = app
in loop (app, cursorIdx, buffer, searchList, count, time)
end
end end
local local

View File

@@ -552,7 +552,7 @@ struct
let let
val items = Vector.map val items = Vector.map
(fn {start, finish} => (fn {start, finish} =>
{start = start - incBy, finish = finish - incBy} {start = start + incBy, finish = finish + incBy}
) items ) items
val sizes = Vector.map #finish items val sizes = Vector.map #finish items
in in

View File

@@ -226,14 +226,17 @@ struct
val searchList = val searchList =
let let
val searchListLeft = PersistentVector.splitLeft (insIdx, searchList) val searchListLeft = PersistentVector.splitLeft (insIdx, searchList)
val searchListRight = PersistentVector.splitRight (insIdx, searchList)
val insLength = String.size insString
val searchListRight = val searchListRight =
PersistentVector.incrementBy (String.size insString, searchList) PersistentVector.splitRight (insIdx + insLength, searchList)
val searchListRight = PersistentVector.empty
in in
PersistentVector.merge (searchListLeft, searchListRight) if PersistentVector.isEmpty searchListLeft then searchListRight
else if PersistentVector.isEmpty searchListRight then searchListLeft
else PersistentVector.merge (searchListLeft, searchListRight)
end end
(* start looking for new matches from the previous match *)
val oldStart = PersistentVector.prevMatch (insIdx, searchList, 1) val oldStart = PersistentVector.prevMatch (insIdx, searchList, 1)
in in
if Vector.length dfa = 0 then if Vector.length dfa = 0 then

View File

@@ -1,5 +1,5 @@
# To-do list # To-do list
- Address to-do notes in make-normal-delete.sml (update searchList in light of insertion) - Add tests for indent, dedent and remove-line-break motions
- Add normal-delete tests for each motion, checking that searchList is as expected - Add normal-delete tests for each motion, checking that searchList is as expected
- Add tests for other yank motoins - Add tests for other yank motoins
- Tests should be based on existing tests for delete-motions, and in the same order. - Tests should be based on existing tests for delete-motions, and in the same order.