fix readline redisplay issue with a prompt containing terminal escape sequences that needs to change (e.g., to show the vi editing mode) after a paste that leaves the cursor in column 0; fix readline display overflow with a prompt that contains more than 256 wrapped lines

This commit is contained in:
Chet Ramey
2026-07-01 11:04:36 -04:00
parent 76037847c3
commit 0e16a4e4b1
6 changed files with 215 additions and 1224 deletions
+19
View File
@@ -13053,3 +13053,22 @@ builtins/exec.def,builtins/hash.def,builtins/help.def,builtins/history.def
builtins/source.def,builtins/type.def
- sanitize command and file names used in error messages by calling
printable_filename
6/16
----
lib/readline/display.c
- update_line: when we are deciding whether or not we have to redraw
the prompt string because the first difference is in the middle of
a prompt with potential invisible characters, check even if the
cursor is at column 0 -- we might choose to move forward to the
first difference by moving the cursor instead of redrawing chars,
so we might skip over the initial part of a CSI sequence
Report from Derek Schrock <dereks@lifeofadishwasher.com>
6/26
----
lib/readline/display.c
- rl_redisplay: make sure to use CHECK_INV_LBREAKS() when copying
local_prompt_newlines into the inv_lbreaks array in case the
prompt consumes more lines than the initial 256 inv_lbreaks size
Report from Ben Kallus <benjamin.p.kallus.gr@dartmouth.edu>
+7 -2
View File
@@ -1024,6 +1024,7 @@ rl_redisplay (void)
while (local_prompt_newlines[newlines+1] != -1)
{
temp = local_prompt_newlines[newlines+1];
CHECK_INV_LBREAKS ();
inv_lbreaks[++newlines] = temp;
}
@@ -2218,6 +2219,9 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
can't directly check it) is still on the visible line because we
haven't overwritten it yet. We guess that there aren't any invisible
characters in any of the prompts we put in with rl_message */
/* This is wrong if the prompt is switching between two variants, both
with invisible characters (e.g., when using mode strings with terminal
escape sequences). */
else if (current_line == 0 && local_prompt && new[0] == local_prompt[0] &&
(memcmp (new, local_prompt, local_prompt_len) == 0) &&
(memcmp (old, local_prompt, local_prompt_len) != 0))
@@ -2261,11 +2265,12 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
od = ofd - old; /* index of first difference in visible line */
nd = nfd - new; /* nd, od are buffer indexes */
if (current_line == 0 && !_rl_horizontal_scroll_mode &&
_rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos > 0 &&
_rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos >= 0 &&
(((od > 0 || nd > 0) && (od <= prompt_last_invisible || nd <= prompt_last_invisible)) ||
((od >= lendiff) && _rl_last_c_pos < PROMPT_ENDING_INDEX)))
{
_rl_cr ();
if (_rl_last_c_pos > 0)
_rl_cr ();
if (modmark)
_rl_output_some_chars ("*", 1);
_rl_output_some_chars (local_prompt, lendiff);
BIN
View File
Binary file not shown.
+3 -3
View File
@@ -3,7 +3,7 @@
# This file is distributed under the same license as the bash package.
# Petr Pisar <petr.pisar@atlas.cz>, 2008, 2009, 2010, 2011, 2012, 2013, 2014.
# Petr Pisar <petr.pisar@atlas.cz>, 2015, 2016, 2018, 2019, 2020, 2022, 2023.
# Petr Pisar <petr.pisar@atlas.cz>, 2025.
# Petr Pisar <petr.pisar@atlas.cz>, 2025, 2026.
#
# alias → alias
# subscript → podskript
@@ -16,7 +16,7 @@ msgstr ""
"Project-Id-Version: bash 5.3-rc2\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-04-22 09:37-0400\n"
"PO-Revision-Date: 2025-06-03 21:27+02:00\n"
"PO-Revision-Date: 2026-06-19 21:45+02:00\n"
"Last-Translator: Petr Pisar <petr.pisar@atlas.cz>\n"
"Language-Team: Czech <translation-team-cs@lists.sourceforge.net>\n"
"Language: cs\n"
@@ -1186,7 +1186,7 @@ msgstr "chybná celočíselná konstanta"
#: expr.c:1620
msgid "value too great for base"
msgstr "hodnot je pro základ příliš velká"
msgstr "hodnota je pro základ příliš velká"
#: expr.c:1671
#, c-format
BIN
View File
Binary file not shown.
+186 -1219
View File
File diff suppressed because it is too large Load Diff