aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2017-09-13 13:01:51 +0200
committerGlauber Campinho <[email protected]>2017-09-13 15:16:19 +0200
commit5211e65b8a89f95d8a4371a1fefa252c2fccfea8 (patch)
treee25313eda03a89acaa20caaedc843903f95a69e6
parentc128db95440cc4caf34cbad5e91e1e26bb5fa6a3 (diff)
downloadotp-5211e65b8a89f95d8a4371a1fefa252c2fccfea8.tar.gz
otp-5211e65b8a89f95d8a4371a1fefa252c2fccfea8.tar.bz2
otp-5211e65b8a89f95d8a4371a1fefa252c2fccfea8.zip
stdlib: Fix jumping to beginning or end of line
When cursor is before or after a multi-codepoint grapheme cluster.
-rw-r--r--lib/stdlib/src/edlin.erl8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/stdlib/src/edlin.erl b/lib/stdlib/src/edlin.erl
index 64d5a71f3c..5df9c504f9 100644
--- a/lib/stdlib/src/edlin.erl
+++ b/lib/stdlib/src/edlin.erl
@@ -412,12 +412,12 @@ do_op(backward_word, Bef0, Aft0, Rs) ->
{Bef1,Aft1,N0} = over_non_word(Bef0, Aft0, 0),
{Bef,Aft,N} = over_word(Bef1, Aft1, N0),
{{Bef,Aft},[{move_rel,-N}|Rs]};
-do_op(beginning_of_line, [C|Bef], Aft, Rs) ->
- {{[],reverse(Bef, [C|Aft])},[{move_rel,-(cp_len(Bef)+1)}|Rs]};
+do_op(beginning_of_line, [_|_]=Bef, Aft, Rs) ->
+ {{[],reverse(Bef, Aft)},[{move_rel,-(cp_len(Bef))}|Rs]};
do_op(beginning_of_line, [], Aft, Rs) ->
{{[],Aft},Rs};
-do_op(end_of_line, Bef, [C|Aft], Rs) ->
- {{reverse(Aft, [C|Bef]),[]},[{move_rel,cp_len(Aft)+1}|Rs]};
+do_op(end_of_line, Bef, [_|_]=Aft, Rs) ->
+ {{reverse(Aft, Bef),[]},[{move_rel,cp_len(Aft)}|Rs]};
do_op(end_of_line, Bef, [], Rs) ->
{{Bef,[]},Rs};
do_op(ctlu, Bef, Aft, Rs) ->