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

View File

@@ -26,28 +26,17 @@ struct
end
local
fun loop (app: app_type, cursorIdx, buffer, count, time) =
fun loop (app: app_type, cursorIdx, buffer, searchList, count, time) =
if count = 0 then
let
open MailboxType
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
NormalDelete.finishAfterDeletingBuffer
(app, #cursorIdx app, buffer, searchList, time, [])
else
let
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val lineStart = Cursor.vi0 (buffer, cursorIdx)
(* todo: update searchList based on insert *)
val buffer = LineGap.insert (lineStart, " ", buffer)
val (buffer, searchList) = SearchList.insert
(lineStart, " ", buffer, searchList, #dfa app)
val buffer = LineGap.goToIdx (lineStart, buffer)
val lineEnd = Cursor.viDlr (buffer, lineStart, 1)
@@ -56,11 +45,13 @@ struct
val count = if lineEnd = nextLine then 0 else count - 1
in
loop (app, nextLine, buffer, count, time)
loop (app, nextLine, buffer, searchList, count, time)
end
in
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
local

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
# 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 tests for other yank motoins
- Tests should be based on existing tests for delete-motions, and in the same order.