reader: Fix infinite loop for up/downcase bindings

This could *probably* be rewritten nicer with a for-loop

Fixes #10222
This commit is contained in:
Fabian Boehm 2024-01-16 18:10:24 +01:00
parent 5d3aea363e
commit 34c09b1816
2 changed files with 7 additions and 1 deletions

View file

@ -2795,7 +2795,7 @@ impl ReaderData {
let mut capitalized_first = false;
// We apply the operation from the current location to the end of the word.
let pos = el.position();
let mut pos = el.position();
let init_pos = pos;
self.move_word(
elt,
@ -2824,6 +2824,7 @@ impl ReaderData {
replacement.extend(chr.to_lowercase());
};
capitalized_first = capitalized_first || make_uppercase;
pos = pos + 1;
}
self.replace_substring(elt, init_pos..pos, replacement);
self.update_buff_pos(elt, None);

View file

@ -375,6 +375,11 @@ expect_prompt()
send("\x1A")
expect_str("bound ctrl-z")
send('echo foobar')
send('\x02\x02\x02') # ctrl-b, backward-char
sendline('\x1bu') # alt+u, upcase word
expect_prompt("fooBAR")
# Check that the builtin version of `exit` works
# (for obvious reasons this MUST BE LAST)
sendline("function myexit; echo exit; exit; end; bind \cz myexit")