diff --git a/src/reader.rs b/src/reader.rs index 2e8a59dcf..b4528d9e6 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -1739,7 +1739,7 @@ fn move_word( } } - fn jump( + fn jump_and_remember_last_jump( &mut self, direction: JumpDirection, precision: JumpPrecision, @@ -1749,7 +1749,16 @@ fn jump( self.last_jump_target = Some(target); self.last_jump_direction = direction; self.last_jump_precision = precision; + self.jump(direction, precision, elt, vec![target]) + } + fn jump( + &mut self, + direction: JumpDirection, + precision: JumpPrecision, + elt: EditableLineTag, + targets: Vec, + ) -> bool { let el = self.edit_line(elt); match direction { @@ -1761,7 +1770,7 @@ fn jump( return false; } tmp_pos -= 1; - if el.at(tmp_pos) == target { + if targets.iter().any(|&target| el.at(tmp_pos) == target) { if precision == JumpPrecision::Till { tmp_pos = std::cmp::min(el.len() - 1, tmp_pos + 1); } @@ -1773,7 +1782,7 @@ fn jump( JumpDirection::Forward => { let mut tmp_pos = el.position() + 1; while tmp_pos < el.len() { - if el.at(tmp_pos) == target { + if targets.iter().any(|&target| el.at(tmp_pos) == target) { if precision == JumpPrecision::Till { tmp_pos -= 1; } @@ -3098,7 +3107,8 @@ 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(direction, precision, elt, target); + let success = + self.jump_and_remember_last_jump(direction, precision, elt, target); self.input_data.function_set_status(success); } @@ -3108,7 +3118,7 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) { let mut success = false; if let Some(target) = self.last_jump_target { - success = self.data.jump( + success = self.data.jump_and_remember_last_jump( self.data.last_jump_direction, self.data.last_jump_precision, elt, @@ -3130,9 +3140,12 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) { }; if let Some(last_target) = self.last_jump_target { - success = self - .data - .jump(dir, self.data.last_jump_precision, elt, last_target); + success = self.data.jump_and_remember_last_jump( + dir, + self.data.last_jump_precision, + elt, + last_target, + ); } self.last_jump_direction = original_dir;