shell: check echo flag in z_shell_cursor_in_empty_line()

If the echo flag is disabled the cmd_buff isn't printed and the
characters in it must not be counted in this function.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
This commit is contained in:
Gerhard Jörges 2022-05-11 09:25:27 +02:00 committed by Maureen Helm
commit 6be558af5b

View file

@ -50,8 +50,10 @@ static inline bool full_line_cmd(const struct shell *shell)
/* Function returns true if cursor is at beginning of an empty line. */ /* Function returns true if cursor is at beginning of an empty line. */
bool z_shell_cursor_in_empty_line(const struct shell *shell) bool z_shell_cursor_in_empty_line(const struct shell *shell)
{ {
return ((shell->ctx->cmd_buff_pos + z_shell_strlen(shell->ctx->prompt)) return (((shell->ctx->cmd_buff_pos * shell->ctx->cfg.flags.echo) +
% shell->ctx->vt100_ctx.cons.terminal_wid == 0U); z_shell_strlen(shell->ctx->prompt)) %
shell->ctx->vt100_ctx.cons.terminal_wid ==
0U);
} }
void z_shell_op_cond_next_line(const struct shell *shell) void z_shell_op_cond_next_line(const struct shell *shell)