diff --git a/fcore/cursor.sml b/fcore/cursor.sml index f066475..d920bf9 100644 --- a/fcore/cursor.sml +++ b/fcore/cursor.sml @@ -1003,73 +1003,6 @@ struct | [] => cursorIdx end - (* Prerequisite: move lineGap to reqLine *) - fun getLineStartIdx (lineGap: LineGap.t, reqLine) = - let - val - { rightStrings - , rightLines - , line = bufferLine - , idx = bufferIdx - , leftStrings - , leftLines - , ... - } = lineGap - in - case (rightStrings, rightLines) of - (shd :: stl, lhd :: ltl) => - (* reqLine exists in lineGap, so retrieve it *) - let - val relativeLine = reqLine - bufferLine - 1 - in - if relativeLine < 0 then - (* line is in left node, if it exists *) - (case (leftStrings, leftLines) of - (leftShd :: leftStl, leftLhd :: leftLtl) => - startVi0 - ( String.size leftShd - 1 - , leftShd - , leftLhd - , bufferIdx - 1 - , leftStl - , leftLtl - ) + 1 - | (_, _) => 0) - else - let - val lineIdx = Vector.sub (lhd, relativeLine) - in - if lineIdx = String.size shd - 1 andalso List.null stl then - (* if is end of buffer, return last idx in buffer; else, - * increment by 1 as we want to go to first char after line break *) - bufferIdx + lineIdx - else - bufferIdx + lineIdx - end - end - | (_, _) => - (* reqLine does not exist in lineGap, so just go to start of last line *) - let - val {leftStrings, leftLines, ...} = lineGap - in - (case (leftStrings, leftLines) of - (lshd :: lstl, llhd :: lltl) => - let - val result = startVi0 - ( String.size lshd - 1 - , lshd - , llhd - , bufferIdx - 1 - , lstl - , lltl - ) - in - if result = bufferIdx then bufferIdx - 1 else result - end - | (_, _) => 0) - end - end - (* Prerequisite: lineGap is moved to cursorIdx *) fun isCursorAtStartOfLine (lineGap: LineGap.t, cursorIdx) = let diff --git a/fcore/normal-mode/normal-move.sml b/fcore/normal-mode/normal-move.sml index db76d2c..002f708 100644 --- a/fcore/normal-mode/normal-move.sml +++ b/fcore/normal-mode/normal-move.sml @@ -128,7 +128,7 @@ struct val buffer = LineGap.goToLine (reqLine, buffer) (* get idx of first chr after linebreak *) - val cursorIdx = Cursor.getLineStartIdx (buffer, reqLine) + val cursorIdx = LineGap.lineNumberToIdx (reqLine, buffer) val buffer = LineGap.goToIdx (cursorIdx, buffer) (* we got the line start idx, but we want to move to the index diff --git a/lib/brolib-sml b/lib/brolib-sml index 7ea31ac..8c56f9c 160000 --- a/lib/brolib-sml +++ b/lib/brolib-sml @@ -1 +1 @@ -Subproject commit 7ea31ace35429ccf28b80602fcc5ca5c1c1c8c09 +Subproject commit 8c56f9cc95794274d358af3b9e3de67fce534fc0