mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-04 00:53:41 +08:00
Fix assertion failure in FZF keybindings
It seems the logic for calculating the cursor position was not ported correctly, because the correct place to insert it is at the cursor_pos regardless of range.start, going by the parameters submitted to the function and the expected result.
This commit is contained in:
parent
ce19f82c19
commit
977b97a236
|
@ -54,7 +54,6 @@ fn replace_part(
|
|||
cursor_pos: usize,
|
||||
) {
|
||||
let mut out_pos = cursor_pos;
|
||||
|
||||
let mut out = buff[..range.start].to_owned();
|
||||
|
||||
match insert_mode {
|
||||
|
@ -67,11 +66,11 @@ fn replace_part(
|
|||
out.push_utfstr(insert);
|
||||
}
|
||||
AppendMode::Insert => {
|
||||
let cursor = cursor_pos - range.start;
|
||||
assert!(range.start <= cursor);
|
||||
out.push_utfstr(&buff[range.start..cursor]);
|
||||
assert!(cursor_pos >= range.start);
|
||||
assert!(cursor_pos <= range.end);
|
||||
out.push_utfstr(&buff[range.start..cursor_pos]);
|
||||
out.push_utfstr(&insert);
|
||||
out.push_utfstr(&buff[cursor..range.end]);
|
||||
out.push_utfstr(&buff[cursor_pos..range.end]);
|
||||
out_pos += insert.len();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user