From 6be558af5b69c067a9989f786cea92ae6c699f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20J=C3=B6rges?= Date: Wed, 11 May 2022 09:25:27 +0200 Subject: [PATCH] shell: check echo flag in z_shell_cursor_in_empty_line() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- subsys/shell/shell_ops.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subsys/shell/shell_ops.c b/subsys/shell/shell_ops.c index 30b58abf717..d8dae42c055 100644 --- a/subsys/shell/shell_ops.c +++ b/subsys/shell/shell_ops.c @@ -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. */ bool z_shell_cursor_in_empty_line(const struct shell *shell) { - return ((shell->ctx->cmd_buff_pos + z_shell_strlen(shell->ctx->prompt)) - % shell->ctx->vt100_ctx.cons.terminal_wid == 0U); + return (((shell->ctx->cmd_buff_pos * shell->ctx->cfg.flags.echo) + + 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)