Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel: "overwrite prompt" setting #8644

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/kernel/src/group.erl
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,17 @@ more_data(What, Cont0, Drv, Shell, Ls, Encoding) ->
get_line1(edlin:edit_line(eof, Cont0), Drv, Shell, Ls, Encoding);
{io_request,From,ReplyAs,Req} when is_pid(From) ->
{more_chars,Cont,_More} = edlin:edit_line([], Cont0),
send_drv_reqs(Drv, edlin:erase_line()),
io_request(Req, From, ReplyAs, Drv, Shell, []), %WRONG!!!
send_drv_reqs(Drv, edlin:redraw_line(Cont)),
Location = application:get_env(stdlib,
shell_bgmsg_location,
above),
case Location of
above ->
send_drv_reqs(Drv, edlin:erase_line()),
io_request(Req, From, ReplyAs, Drv, Shell, []), %WRONG!!!
send_drv_reqs(Drv, edlin:redraw_line(Cont));
_ ->
io_request(Req, From, ReplyAs, Drv, Shell, [])
end,
get_line1({more_chars,Cont,[]}, Drv, Shell, Ls, Encoding);
{reply,{From,ReplyAs},Reply} ->
%% We take care of replies from puts here as well
Expand Down
14 changes: 2 additions & 12 deletions lib/kernel/src/prim_tty.erl
Original file line number Diff line number Diff line change
Expand Up @@ -633,18 +633,8 @@ handle_request(State, {expand_with_trim, Binary}) ->
%% putc prints Binary and overwrites any existing characters
handle_request(State = #state{ unicode = U }, {putc, Binary}) ->
%% Todo should handle invalid unicode?
%% print above the prompt if we have a prompt.
%% otherwise print on the current line.
case {State#state.lines_before,{State#state.buffer_before, State#state.buffer_after}, State#state.lines_after} of
{[],{[],[]},[]} ->
{PutBuffer, _} = insert_buf(State, Binary),
{[encode(PutBuffer, U)], State};
_ ->
{Delete, DeletedState} = handle_request(State, delete_line),
{PutBuffer, _} = insert_buf(DeletedState, Binary),
{Redraw, _} = handle_request(State, redraw_prompt_pre_deleted),
{[Delete, encode(PutBuffer, U), Redraw], State}
end;
{PutBuffer, _} = insert_buf(State, Binary),
{[encode(PutBuffer, U)], State};
handle_request(State = #state{}, delete_after_cursor) ->
{[State#state.delete_after_cursor],
State#state{buffer_after = [],
Expand Down
13 changes: 13 additions & 0 deletions lib/kernel/test/interactive_shell_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@
end.

shell_multiline_prompt(Config) ->
Term1 = start_tty([{args,["-stdlib","shell_multiline_prompt","{edlin,inverted_space_prompt}"]}|Config]),

Check warning on line 483 in lib/kernel/test/interactive_shell_SUITE.erl

View workflow job for this annotation

GitHub Actions / CT Test Results

1 out of 2 runs failed: shell_format

artifacts/Unit Test Results/kernel_junit.xml [took 4s]
Raw output
Test shell_format in interactive_shell_SUITE failed!
{test_case_failed,nomatch}
Term2 = start_tty([{args,["-stdlib","shell_multiline_prompt","\"...> \""]}|Config]),
Term3 = start_tty([{args,["-stdlib","shell_multiline_prompt","edlin"]}|Config]),

Expand Down Expand Up @@ -976,6 +976,7 @@
after
stop_tty(Term)
end.

shell_receive_standard_out(Config) ->
Term = start_tty(Config),
try
Expand All @@ -987,7 +988,19 @@
ok
after
stop_tty(Term)
end,
Term2 = start_tty([{args,["-stdlib","shell_bgmsg_location","below"]}|Config]),
try
send_tty(Term2,"my_fun(5) -> ok; my_fun(N) -> receive after 100 -> io:format(\"~p\\n\", [N]), my_fun(N+1) end.\n"),
send_tty(Term2, "spawn(shell_default, my_fun, [0]). ABC\n"),
timer:sleep(1000),
check_location(Term2, {0,-18}), %% Check that we are at the same location relative to the start.
check_content(Term2, "..0\\s+1\\s+2\\s+3\\s+4"),
ok
after
stop_tty(Term2)
end.

%% Test that the shell works when invalid utf-8 (aka latin1) is sent to it
shell_invalid_unicode(Config) ->
Term = start_tty(Config),
Expand Down
Loading