diff --git a/fcore/app-update.sml b/fcore/app-update.sml index 0ffb9b7..e478e79 100644 --- a/fcore/app-update.sml +++ b/fcore/app-update.sml @@ -420,9 +420,14 @@ struct let (* delete char at cursor and then decrement cursorIdx by 1 * if cursorIdx is not 0 *) + val {searchString, ...} = app val buffer = LineGap.delete (cursorIdx, 1, buffer) - val searchList = SearchList.delete (cursorIdx, 1, #searchString app, searchList) + + val searchList = SearchList.delete (cursorIdx, 1, searchString, searchList) val searchList = SearchList.mapFrom (cursorIdx, ~1, searchList) + val (buffer, searchList) = + BuildSearchList.fromRange + (cursorIdx, 1, buffer, searchString, searchList) val cursorIdx = if @@ -435,9 +440,14 @@ struct end else let + val {searchString, ...} = app val buffer = LineGap.delete (cursorIdx, 1, buffer) - val searchList = SearchList.delete (cursorIdx, 1, #searchString app, searchList) + + val searchList = SearchList.delete (cursorIdx, 1, searchString, searchList) val searchList = SearchList.mapFrom (cursorIdx, ~1, searchList) + val (buffer, searchList) = + BuildSearchList.fromRange + (cursorIdx, 1, buffer, searchString, searchList) in helpRemoveChr (app, buffer, searchList, cursorIdx, count - 1) end diff --git a/fcore/build-search-list.sml b/fcore/build-search-list.sml index b8df726..7debfd1 100644 --- a/fcore/build-search-list.sml +++ b/fcore/build-search-list.sml @@ -81,9 +81,11 @@ struct (* searches for matchedIdx within a range from the buffer instead of from start *) fun helpFromRange - (app, origIdx, curIdx, finishIdx, buffer, searchString, searchList) = + (origIdx, curIdx, finishIdx, buffer, searchString, searchList) = let - val buffer = LineGap.goToIdx (curIdx, buffer) val {idx = bufferIdx, rightStrings, ...} = buffer in + val buffer = LineGap.goToIdx (curIdx, buffer) + val {idx = bufferIdx, rightStrings, ...} = buffer + in case nextMatch (bufferIdx, curIdx, rightStrings, searchString) of SOME matchedIdx => if matchedIdx > finishIdx then @@ -91,14 +93,14 @@ struct val buffer = LineGap.goToIdx (origIdx, buffer) val searchList = SearchList.goToNum (origIdx, searchList) in - AppWith.searchList (app, searchList, buffer, searchString) + (buffer, searchList) end else let val searchList = SearchList.insert (matchedIdx, searchList) in helpFromRange - ( app, origIdx, matchedIdx + 1, finishIdx + ( origIdx, matchedIdx + 1, finishIdx , buffer, searchString, searchList ) end @@ -107,15 +109,16 @@ struct val buffer = LineGap.goToIdx (origIdx, buffer) val searchList = SearchList.goToNum (origIdx, searchList) in - AppWith.searchList (app, searchList, buffer, searchString) + (buffer, searchList) end end - fun fromRange (app, startIdx, finishIdx, buffer, searchString, searchList) = + fun fromRange (startIdx, length, buffer, searchString, searchList) = let - val buffer = LineGap.goToIdx (startIdx, buffer) + val finishIdx = startIdx + length + String.size searchString + val bufferIdx = startIdx - String.size searchString in helpFromRange - (app, startIdx, startIdx, finishIdx, buffer, searchString, searchList) + (startIdx, bufferIdx, finishIdx, buffer, searchString, searchList) end end diff --git a/fcore/search-list.sml b/fcore/search-list.sml index 8afb25f..913df9d 100644 --- a/fcore/search-list.sml +++ b/fcore/search-list.sml @@ -9,6 +9,7 @@ sig val goToNum: int * t -> t val mapFrom: int * int * t -> t + val printlst: t -> unit end structure SearchList :> SEARCH_LIST = @@ -233,7 +234,7 @@ struct val newHd = VectorSlice.slice (hd, delstart, SOME dellength) val newHd = VectorSlice.vector newHd in - {left = left, right = joinStartOfRight (newHd, right)} + {left = left, right = joinStartOfRight (newHd, tl)} end else (* finish = last *) @@ -317,7 +318,7 @@ struct val newHd = VectorSlice.slice (hd, delpoint, SOME newLength) val newHd = VectorSlice.vector newHd in - {left = joinEndOfLeft (newHd, left), right = right} + {left = joinEndOfLeft (newHd, tl), right = right} end else (* start = first *) diff --git a/shf b/shf index 371d86b..0c0083e 100755 Binary files a/shf and b/shf differ