add missing implementation of Cursor.matchPair when strIdx is in tl
This commit is contained in:
@@ -1632,6 +1632,54 @@ struct
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun startMatchPair (strIdx, shd, stl, cursorIdx) =
|
||||||
|
let
|
||||||
|
val chr = String.sub (shd, strIdx)
|
||||||
|
in
|
||||||
|
(case chr of
|
||||||
|
#"(" =>
|
||||||
|
helpMatchPairNext
|
||||||
|
( strIdx + 1, shd, cursorIdx + 1, stl, cursorIdx
|
||||||
|
, #"(", 1, #")", 0
|
||||||
|
)
|
||||||
|
| #")" =>
|
||||||
|
helpMatchPairPrev
|
||||||
|
( strIdx - 1, shd, cursorIdx - 1, stl, cursorIdx
|
||||||
|
, #"(", 0, #")", 1
|
||||||
|
)
|
||||||
|
| #"[" =>
|
||||||
|
helpMatchPairNext
|
||||||
|
( strIdx + 1, shd, cursorIdx + 1, stl, cursorIdx
|
||||||
|
, #"[", 1, #"]", 0
|
||||||
|
)
|
||||||
|
| #"]" =>
|
||||||
|
helpMatchPairPrev
|
||||||
|
( strIdx - 1, shd, cursorIdx - 1, stl, cursorIdx
|
||||||
|
, #"[", 0, #"]", 1
|
||||||
|
)
|
||||||
|
| #"{" =>
|
||||||
|
helpMatchPairNext
|
||||||
|
( strIdx + 1, shd, cursorIdx + 1, stl, cursorIdx
|
||||||
|
, #"{", 1, #"}", 0
|
||||||
|
)
|
||||||
|
| #"}" =>
|
||||||
|
helpMatchPairPrev
|
||||||
|
( strIdx - 1, shd, cursorIdx - 1, stl, cursorIdx
|
||||||
|
, #"{", 0, #"}", 1
|
||||||
|
)
|
||||||
|
| #"<" =>
|
||||||
|
helpMatchPairNext
|
||||||
|
( strIdx + 1, shd, cursorIdx + 1, stl, cursorIdx
|
||||||
|
, #"<", 1, #">", 0
|
||||||
|
)
|
||||||
|
| #">" =>
|
||||||
|
helpMatchPairPrev
|
||||||
|
( strIdx - 1, shd, cursorIdx - 1, stl, cursorIdx
|
||||||
|
, #"<", 0, #">", 1
|
||||||
|
)
|
||||||
|
| _ => cursorIdx)
|
||||||
|
end
|
||||||
|
|
||||||
fun matchPair (lineGap: LineGap.t, cursorIdx) =
|
fun matchPair (lineGap: LineGap.t, cursorIdx) =
|
||||||
let
|
let
|
||||||
val {rightStrings, idx = bufferIdx, leftStrings, ...} = lineGap
|
val {rightStrings, idx = bufferIdx, leftStrings, ...} = lineGap
|
||||||
@@ -1644,52 +1692,7 @@ struct
|
|||||||
in
|
in
|
||||||
if strIdx < String.size shd then
|
if strIdx < String.size shd then
|
||||||
(* strIdx is in this string *)
|
(* strIdx is in this string *)
|
||||||
let
|
startMatchPair (strIdx, shd, stl, cursorIdx)
|
||||||
val chr = String.sub (shd, strIdx)
|
|
||||||
in
|
|
||||||
(case chr of
|
|
||||||
#"(" =>
|
|
||||||
helpMatchPairNext
|
|
||||||
( strIdx + 1, shd, cursorIdx + 1, stl, cursorIdx
|
|
||||||
, #"(", 1, #")", 0
|
|
||||||
)
|
|
||||||
| #")" =>
|
|
||||||
helpMatchPairPrev
|
|
||||||
( strIdx - 1, shd, cursorIdx - 1, stl, cursorIdx
|
|
||||||
, #"(", 0, #")", 1
|
|
||||||
)
|
|
||||||
| #"[" =>
|
|
||||||
helpMatchPairNext
|
|
||||||
( strIdx + 1, shd, cursorIdx + 1, stl, cursorIdx
|
|
||||||
, #"[", 1, #"]", 0
|
|
||||||
)
|
|
||||||
| #"]" =>
|
|
||||||
helpMatchPairPrev
|
|
||||||
( strIdx - 1, shd, cursorIdx - 1, stl, cursorIdx
|
|
||||||
, #"[", 0, #"]", 1
|
|
||||||
)
|
|
||||||
| #"{" =>
|
|
||||||
helpMatchPairNext
|
|
||||||
( strIdx + 1, shd, cursorIdx + 1, stl, cursorIdx
|
|
||||||
, #"{", 1, #"}", 0
|
|
||||||
)
|
|
||||||
| #"}" =>
|
|
||||||
helpMatchPairPrev
|
|
||||||
( strIdx - 1, shd, cursorIdx - 1, stl, cursorIdx
|
|
||||||
, #"{", 0, #"}", 1
|
|
||||||
)
|
|
||||||
| #"<" =>
|
|
||||||
helpMatchPairNext
|
|
||||||
( strIdx + 1, shd, cursorIdx + 1, stl, cursorIdx
|
|
||||||
, #"<", 1, #">", 0
|
|
||||||
)
|
|
||||||
| #">" =>
|
|
||||||
helpMatchPairPrev
|
|
||||||
( strIdx - 1, shd, cursorIdx - 1, stl, cursorIdx
|
|
||||||
, #"<", 0, #">", 1
|
|
||||||
)
|
|
||||||
| _ => cursorIdx)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
(* strIdx is in tl *)
|
(* strIdx is in tl *)
|
||||||
(case stl of
|
(case stl of
|
||||||
@@ -1698,7 +1701,7 @@ struct
|
|||||||
val strIdx = strIdx - String.size shd
|
val strIdx = strIdx - String.size shd
|
||||||
val leftStrings = shd :: leftStrings
|
val leftStrings = shd :: leftStrings
|
||||||
in
|
in
|
||||||
(print "match pair throw err\n"; raise Match)
|
startMatchPair (strIdx, stlhd, leftStrings, cursorIdx)
|
||||||
end
|
end
|
||||||
| [] => cursorIdx)
|
| [] => cursorIdx)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user