summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErlang/OTP <otp@erlang.org>2019-11-15 09:44:27 +0100
committerErlang/OTP <otp@erlang.org>2019-11-15 09:44:27 +0100
commit96e510ba56d403fe21ed200fe7ae8632bac7f84b (patch)
tree11f3290d705323db9fe9317cbb75eb615917c444
parent1d1ee8f87ae2b651dbb2502fc19577a6a3a6f34b (diff)
parentc9122f6a7244d9b495fe5b777b1f472a89b2a3d9 (diff)
downloaderlang-96e510ba56d403fe21ed200fe7ae8632bac7f84b.tar.gz
Merge branch 'hans/ssh/fix_cli-20-21/OTP-14849' into maint-20
* hans/ssh/fix_cli-20-21/OTP-14849: ssh: Fix cli problems at line end
-rw-r--r--lib/ssh/src/ssh_cli.erl8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/ssh/src/ssh_cli.erl b/lib/ssh/src/ssh_cli.erl
index 958c342f5f..ab9624ec6e 100644
--- a/lib/ssh/src/ssh_cli.erl
+++ b/lib/ssh/src/ssh_cli.erl
@@ -387,7 +387,7 @@ insert_chars([], {Buf, BufTail, Col}, _Tty) ->
insert_chars(Chars, {Buf, BufTail, Col}, Tty) ->
{NewBuf, _NewBufTail, WriteBuf, NewCol} =
conv_buf(Chars, Buf, [], [], Col),
- M = move_cursor(NewCol + length(BufTail), NewCol, Tty),
+ M = move_cursor(special_at_width(NewCol+length(BufTail), Tty), NewCol, Tty),
{[WriteBuf, BufTail | M], {NewBuf, BufTail, NewCol}}.
%%% delete characters at current position, (backwards if negative argument)
@@ -402,7 +402,7 @@ delete_chars(N, {Buf, BufTail, Col}, Tty) -> % N < 0
NewBuf = nthtail(-N, Buf),
NewCol = case Col + N of V when V >= 0 -> V; _ -> 0 end,
M1 = move_cursor(Col, NewCol, Tty),
- M2 = move_cursor(NewCol + length(BufTail) - N, NewCol, Tty),
+ M2 = move_cursor(special_at_width(NewCol+length(BufTail)-N, Tty), NewCol, Tty),
{[M1, BufTail, lists:duplicate(-N, $ ) | M2],
{NewBuf, BufTail, NewCol}}.
@@ -459,6 +459,10 @@ move_cursor(From, To, #ssh_pty{width=Width, term=Type}) ->
end,
[Tcol | Trow].
+%%% Caution for line "breaks"
+special_at_width(From0, #ssh_pty{width=Width}) when (From0 rem Width) == 0 -> From0 - 1;
+special_at_width(From0, _) -> From0.
+
%% %%% write out characters
%% %%% make sure that there is data to send
%% %%% before calling ssh_connection:send