minor formatting changes to exception logging, and begin building from new search list functionality as well

This commit is contained in:
2025-08-05 13:59:10 +01:00
parent 01369627bf
commit 0729662eef
3 changed files with 48 additions and 33 deletions

View File

@@ -1,8 +1,21 @@
structure SearchLineGap =
struct
fun cons (num, acc) =
let
val num = Vector.fromList [num]
in
case acc of
hd :: tl =>
if Vector.length hd < 32 then
(Vector.concat [num, hd]) :: tl
else
num :: acc
| [] => num :: acc
end
fun searchStep (pos, hd, absIdx, tl, acc, searchPos, searchString) =
if searchPos < 0 then
(absIdx + 1) :: acc
cons (absIdx + 1, acc)
else if pos < 0 then
case tl of
hd :: tl =>
@@ -33,17 +46,22 @@ struct
loopSearch (pos - 1, hd, absIdx - 1, tl, acc, searchString)
end
fun search (buffer, searchString) =
if String.size searchString = 0 then
[]
else
let
val buffer = LineGap.goToEnd buffer
val {leftStrings, idx = absIdx, ...} = buffer
in
case leftStrings of
hd :: tl =>
loopSearch (String.size hd - 1, hd, absIdx - 1, tl, [], searchString)
| [] => []
end
(* Prerequisite: move buffer/LineGap to end *)
fun search (buffer: LineGap.t, searchString) =
let
val acc =
if String.size searchString = 0 then
[]
else
let
val {leftStrings, idx = absIdx, ...} = buffer
in
case leftStrings of
hd :: tl =>
loopSearch (String.size hd - 1, hd, absIdx - 1, tl, [], searchString)
| [] => []
end
in
{left = [], right = acc}
end
end