acassis commented on code in PR #3657:
URL: https://github.com/apache/nuttx-apps/pull/3657#discussion_r3644966678
##########
system/readline/readline_common.c:
##########
@@ -572,17 +1133,39 @@ ssize_t readline_common(FAR struct rl_common_s *vtbl,
FAR char *buf,
}
}
- /* Clear out current command from the prompt */
+ /* Clear out current command from the prompt.
+ *
+ * This cannot assume the terminal's cursor is
+ * sitting at the end of the currently displayed
+ * text (i.e. at column 'nch') and simply backspace
+ * 'nch' times -- the cursor can be anywhere in the
+ * line (e.g. the user pressed Left one or more
+ * times before pressing Up/Down again), and
+ * backspacing more times than the cursor's actual
+ * distance from the end of the prompt walks back
+ * into and erases part of the prompt itself.
+ * Instead, return to the true start of the
+ * terminal line and erase to the end of line, then
+ * reprint the prompt -- this does not depend on
+ * where the cursor happened to be.
+ */
- while (nch > 0)
- {
- nch--;
+ nch = 0;
#ifdef CONFIG_READLINE_ECHO
- RL_PUTC(vtbl, ASCII_BS);
- RL_WRITE(vtbl, g_erasetoeol, sizeof(g_erasetoeol));
-#endif
+ RL_PUTC(vtbl, '\r');
+ RL_WRITE(vtbl, g_erasetoeol, sizeof(g_erasetoeol));
+#ifdef CONFIG_READLINE_TABCOMPLETION
Review Comment:
outdated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]