fix readline vi-mode mark commands to prevent errors if user types an arrow key where a mark name is expected; fix for non-ascii characters being included in variable names if the system isalnum(3) returns success for the character

This commit is contained in:
Chet Ramey
2026-08-07 11:46:08 -04:00
parent 9b6349ef40
commit 9c8a70bc9e
24 changed files with 18698 additions and 19440 deletions
+12
View File
@@ -2365,6 +2365,14 @@ rl_vi_possible_completions (void)
}
#endif
static inline int
_rl_vi_check_arrows (void)
{
return ((RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) &&
_rl_pushed_input_available () == 0 &&
_rl_input_queued (0));
}
/* Functions to save and restore marks. */
static int
_rl_vi_set_mark (void)
@@ -2378,6 +2386,8 @@ _rl_vi_set_mark (void)
if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
{
rl_ding ();
if (ch == ESC && _rl_vi_check_arrows ())
_rl_unget_char (ch); /* assume arrow key or other CSI sequence */
return 1;
}
ch -= 'a';
@@ -2429,6 +2439,8 @@ _rl_vi_goto_mark (void)
else if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
{
rl_ding ();
if (ch == ESC && _rl_vi_check_arrows ())
_rl_unget_char (ch); /* assume arrow key or other CSI sequence */
return 1;
}