mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-20 06:13:47 +08:00
Fix regression causing alt-right to stop at autosuggestion
Fixes #10839
This commit is contained in:
parent
ca21872d14
commit
913860bd1c
|
@ -2859,7 +2859,7 @@ impl<'a> Reader<'a> {
|
||||||
self.update_buff_pos(elt, Some(new_position));
|
self.update_buff_pos(elt, Some(new_position));
|
||||||
}
|
}
|
||||||
rl::KillToken => {
|
rl::KillToken => {
|
||||||
let Some(new_position) = self.forward_token() else {
|
let Some(new_position) = self.forward_token(false) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2877,11 +2877,21 @@ impl<'a> Reader<'a> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
rl::ForwardToken => {
|
rl::ForwardToken => {
|
||||||
let Some(new_position) = self.forward_token() else {
|
let (_elt, el) = self.active_edit_line();
|
||||||
return;
|
if self.is_at_end(el) {
|
||||||
};
|
let Some(new_position) = self.forward_token(true) else {
|
||||||
let (elt, _el) = self.active_edit_line();
|
return;
|
||||||
self.update_buff_pos(elt, Some(new_position));
|
};
|
||||||
|
self.accept_autosuggestion(AutosuggestionPortion::Count(
|
||||||
|
new_position - el.len(),
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
let Some(new_position) = self.forward_token(false) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let (elt, _el) = self.active_edit_line();
|
||||||
|
self.update_buff_pos(elt, Some(new_position));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rl::BackwardWord | rl::BackwardBigword | rl::PrevdOrBackwardWord => {
|
rl::BackwardWord | rl::BackwardBigword | rl::PrevdOrBackwardWord => {
|
||||||
if c == rl::PrevdOrBackwardWord && self.command_line.is_empty() {
|
if c == rl::PrevdOrBackwardWord && self.command_line.is_empty() {
|
||||||
|
@ -3449,22 +3459,30 @@ impl<'a> Reader<'a> {
|
||||||
Some(new_position)
|
Some(new_position)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn forward_token(&self) -> Option<usize> {
|
fn forward_token(&self, autosuggest: bool) -> Option<usize> {
|
||||||
let (_elt, el) = self.active_edit_line();
|
let (_elt, el) = self.active_edit_line();
|
||||||
let pos = el.position();
|
let pos = el.position();
|
||||||
if pos == el.len() {
|
let buffer = if autosuggest {
|
||||||
|
if pos > self.autosuggestion.text.len() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
&self.autosuggestion.text
|
||||||
|
} else {
|
||||||
|
el.text()
|
||||||
|
};
|
||||||
|
if pos == buffer.len() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are not in a token, look for one ahead
|
// If we are not in a token, look for one ahead
|
||||||
let buff_pos = pos
|
let buff_pos = pos
|
||||||
+ el.text()[pos..]
|
+ buffer[pos..]
|
||||||
.chars()
|
.chars()
|
||||||
.take_while(|c| c.is_ascii_whitespace())
|
.take_while(|c| c.is_ascii_whitespace())
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
let mut tok = 0..0;
|
let mut tok = 0..0;
|
||||||
parse_util_token_extent(el.text(), buff_pos, &mut tok, None);
|
parse_util_token_extent(buffer, buff_pos, &mut tok, None);
|
||||||
|
|
||||||
let new_position = if tok.end == pos { pos + 1 } else { tok.end };
|
let new_position = if tok.end == pos { pos + 1 } else { tok.end };
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user