diff --git a/fcore/cursor.sml b/fcore/cursor.sml index fae1c1e..091eaff 100644 --- a/fcore/cursor.sml +++ b/fcore/cursor.sml @@ -304,9 +304,6 @@ struct fun tillNextChr (lineGap, cursorIdx, chr) = nextChr (lineGap, cursorIdx, chr, startTillNextChr) - fun toNextChr (lineGap, cursorIdx, chr) = - nextChr (lineGap, cursorIdx, chr, startToNextChr) - structure ToNextChr = MakeIfCharFolderNext (struct diff --git a/fcore/normal-mode/normal-mode.sml b/fcore/normal-mode/normal-mode.sml index 68befdf..76ee2c1 100644 --- a/fcore/normal-mode/normal-mode.sml +++ b/fcore/normal-mode/normal-mode.sml @@ -531,8 +531,7 @@ struct case String.sub (str, strPos + 1) of #"t" => NormalYank.yankToChr (app, 1, Cursor.tillNextChr, op+, chrCmd) | #"T" => NormalYank.yankToChr (app, 1, Cursor.tillPrevChr, op-, chrCmd) - | #"f" => - NormalYank.yankToChr (app, count, Cursor.toNextChr, op+, chrCmd) + | #"f" => NormalYank.yankToNextChr (app, count, chrCmd) | #"F" => NormalYank.yankToChr (app, count, Cursor.toPrevChr, op-, chrCmd) | #"g" => parseYankGo (count, app, chrCmd) diff --git a/fcore/normal-mode/normal-yank.sml b/fcore/normal-mode/normal-yank.sml index a0f9a4f..9adfe50 100644 --- a/fcore/normal-mode/normal-yank.sml +++ b/fcore/normal-mode/normal-yank.sml @@ -230,6 +230,27 @@ struct (app, buffer, cursorIdx, newOtherIdx, newCount, fMove, fInc, chr) end + fun yankToNextChr (app: app_type, count, chr) = + let + val {buffer, cursorIdx, ...} = app + val buffer = LineGap.goToIdx (cursorIdx, buffer) + val newCursorIdx = + Cursor.toNextChrNew (buffer, cursorIdx, {findChr = chr, count = count}) + in + if newCursorIdx = ~1 then + NormalFinish.clearMode app + else + let + val length = newCursorIdx - cursorIdx + 1 + val buffer = LineGap.goToIdx (newCursorIdx, buffer) + val str = LineGap.substring (cursorIdx, length, buffer) + val msg = YANK str + val mode = NORMAL_MODE "" + in + NormalModeWith.modeAndBuffer (app, buffer, mode, [DRAW msg]) + end + end + fun yankToChr (app: app_type, count, fMove, fInc, chr) = helpYankToChr ( app @@ -329,7 +350,7 @@ struct val start = Int.max (cursorIdx - 1, 0) val buffer = LineGap.goToIdx (start, buffer) - val high = Cursor.toNextChr (buffer, start, chr) + val high = Cursor.toNextChrNew (buffer, start, {findChr = chr, count = 1}) val buffer = LineGap.goToIdx (high, buffer) val low = Cursor.matchPair (buffer, high) + 1 in @@ -361,7 +382,7 @@ struct val start = Int.max (cursorIdx - 1, 0) val buffer = LineGap.goToIdx (start, buffer) - val high = Cursor.toNextChr (buffer, start, chr) + val high = Cursor.toNextChrNew (buffer, start, {findChr = chr, count = 1}) val buffer = LineGap.goToIdx (high, buffer) val low = Cursor.matchPair (buffer, high) val high = high + 1