in search-list.sml: fix 'delRightFromHere' and 'delLeftFromHere' functions which joined newHd with left/right, rather than the tl, and therefore added new numbers to the list, which is incorrect behaviour. Fixed this by using joining with 'tl' rather than left/right. In build-search-list.sml: make fromRange function return tuple instead of an instance of app. Finally, in app-update.sml: progress towards refactoring 'helpRemoveChr' function to map and delete from searchList as desired.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 *)
|
||||
|
||||
Reference in New Issue
Block a user