better handling of double linebreaks in cursor.sml's viH function
This commit is contained in:
@@ -95,6 +95,12 @@ struct
|
|||||||
#"\n" =>
|
#"\n" =>
|
||||||
if strIdx > 1 then
|
if strIdx > 1 then
|
||||||
(* if there are at least two chars before strIdx *)
|
(* if there are at least two chars before strIdx *)
|
||||||
|
if String.sub (hd, strIdx - 2) = #"\n" then
|
||||||
|
(* if there is double line break like \n\n,
|
||||||
|
* we would like to move the cursor
|
||||||
|
* to the second linebreak *)
|
||||||
|
cursorIdx - 1
|
||||||
|
else
|
||||||
cursorIdx - 2
|
cursorIdx - 2
|
||||||
else
|
else
|
||||||
(* only one char before strIdx which is \n
|
(* only one char before strIdx which is \n
|
||||||
@@ -116,8 +122,14 @@ struct
|
|||||||
(case lastChr of
|
(case lastChr of
|
||||||
#"\n" =>
|
#"\n" =>
|
||||||
if String.size lHd > 2 then
|
if String.size lHd > 2 then
|
||||||
(* if there is at least one character before \n
|
(* if there at least one character before \n
|
||||||
* then decrement cursorIdx by 2 *)
|
* then decrement cursorIdx by 2
|
||||||
|
* or decrement cursorIdx by 1
|
||||||
|
* if we are in a double linebreak
|
||||||
|
* if we are not in a double linebreak *)
|
||||||
|
if String.sub (lHd, strIdx - 2) = #"\n" then
|
||||||
|
cursorIdx - 1
|
||||||
|
else
|
||||||
cursorIdx - 2
|
cursorIdx - 2
|
||||||
else
|
else
|
||||||
(* this string only contains \n
|
(* this string only contains \n
|
||||||
@@ -128,7 +140,12 @@ struct
|
|||||||
* If not, increment cursorIdx by 1,
|
* If not, increment cursorIdx by 1,
|
||||||
* landing on newline. *)
|
* landing on newline. *)
|
||||||
(case lTl of
|
(case lTl of
|
||||||
_ :: _ => cursorIdx - 2
|
ltlHd :: _ =>
|
||||||
|
if
|
||||||
|
String.sub (ltlHd, String.size ltlHd - 1)
|
||||||
|
= #"\n"
|
||||||
|
then cursorIdx - 1
|
||||||
|
else cursorIdx - 2
|
||||||
| [] => cursorIdx - 1)
|
| [] => cursorIdx - 1)
|
||||||
| _ =>
|
| _ =>
|
||||||
(* next char is not newline,
|
(* next char is not newline,
|
||||||
|
|||||||
Reference in New Issue
Block a user