fully remove 'word_type' datatype from cursor.sml

This commit is contained in:
2024-10-24 13:44:12 +01:00
parent 5534fd3645
commit 8b3bd97af3
2 changed files with 49 additions and 78 deletions

View File

@@ -839,25 +839,6 @@ struct
cursorIdx cursorIdx
end end
(*
* nvim's motion.txt document describes a word as:
* - A sequence of (letters, digits and underscores)
* - or a sequence of other non-blank characters
* - separated by white space (space, tab, <EOL>)
*)
datatype word_type =
ALPHA_NUM
| SPACE
| NON_BLANK
fun getWordType chr =
if Char.isAlphaNum chr orelse chr = #"_" then
ALPHA_NUM
else if Char.isSpace chr then
SPACE
else
NON_BLANK
fun isNextChrSpace (strPos, str, strTl) = fun isNextChrSpace (strPos, str, strTl) =
if strPos + 1 < String.size str then if strPos + 1 < String.size str then
let let
@@ -1150,8 +1131,7 @@ struct
| (_, _) => cursorIdx | (_, _) => cursorIdx
end end
fun helpEndOfWordString fun helpEndOfWordString (strPos, str, absIdx, stl, ltl) =
(strPos, str, absIdx, stl, ltl) =
if strPos = String.size str then if strPos = String.size str then
helpEndOfWordList (stl, ltl, absIdx) helpEndOfWordList (stl, ltl, absIdx)
else else
@@ -1188,22 +1168,13 @@ struct
fun startEndOfWord (shd, strIdx, absIdx, stl, ltl) = fun startEndOfWord (shd, strIdx, absIdx, stl, ltl) =
(* we want to start iterating from next char after strIdx *) (* we want to start iterating from next char after strIdx *)
if strIdx - 1 < String.size shd then if strIdx - 1 < String.size shd then
let
val nextChr = String.sub (shd, strIdx + 1)
in
helpEndOfWordString helpEndOfWordString
(strIdx + 1, shd, absIdx + 1, stl, ltl) (strIdx + 1, shd, absIdx + 1, stl, ltl)
end
else else
case (stl, ltl) of case (stl, ltl) of
(stlhd::stltl, ltlhd::ltltl) => (stlhd::stltl, ltlhd::ltltl) =>
let
val nextChr = String.sub (stlhd, 0)
val wordType = getWordType nextChr
in
helpEndOfWordString helpEndOfWordString
(0, stlhd, absIdx + 1, stltl, ltltl) (0, stlhd, absIdx + 1, stltl, ltltl)
end
| (_, _) => | (_, _) =>
(* tl is empty; just return absIdx *) (* tl is empty; just return absIdx *)
absIdx absIdx

BIN
shf

Binary file not shown.