Merge pull request #11564

This commit is contained in:
Johannes Altmanninger
2025-06-08 11:26:57 +02:00

View File

@@ -2110,11 +2110,12 @@ fn jump_and_remember_last_jump(
precision: JumpPrecision,
elt: EditableLineTag,
target: char,
skip_till: bool,
) -> bool {
self.last_jump_target = Some(target);
self.last_jump_direction = direction;
self.last_jump_precision = precision;
self.jump(direction, precision, elt, vec![target])
self.jump(direction, precision, elt, vec![target], skip_till)
}
fn jump(
@@ -2123,12 +2124,16 @@ fn jump(
precision: JumpPrecision,
elt: EditableLineTag,
targets: Vec<char>,
skip_till: bool,
) -> bool {
let el = self.edit_line(elt);
match direction {
JumpDirection::Backward => {
let mut tmp_pos = el.position();
if precision == JumpPrecision::Till && skip_till && tmp_pos > 0 {
tmp_pos -= 1;
}
loop {
if tmp_pos == 0 {
@@ -2146,6 +2151,10 @@ fn jump(
}
JumpDirection::Forward => {
let mut tmp_pos = el.position() + 1;
if precision == JumpPrecision::Till && skip_till && tmp_pos < el.len() - 1 {
tmp_pos += 1;
}
while tmp_pos < el.len() {
if targets.iter().any(|&target| el.at(tmp_pos) == target) {
if precision == JumpPrecision::Till {
@@ -3689,7 +3698,7 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) {
let (elt, _el) = self.active_edit_line();
if let Some(target) = self.function_pop_arg() {
let success =
self.jump_and_remember_last_jump(direction, precision, elt, target);
self.jump_and_remember_last_jump(direction, precision, elt, target, false);
self.input_data.function_set_status(success);
}
@@ -3746,7 +3755,13 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) {
)
}
// If we stand on non-bracket character, we prefer to jump forward
None => self.jump(JumpDirection::Forward, precision, elt, r_brackets.to_vec()),
None => self.jump(
JumpDirection::Forward,
precision,
elt,
r_brackets.to_vec(),
false,
),
};
self.input_data.function_set_status(success);
}
@@ -3760,6 +3775,7 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) {
self.data.last_jump_precision,
elt,
target,
true,
);
}
@@ -3782,6 +3798,7 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) {
self.data.last_jump_precision,
elt,
last_target,
true,
);
}