diff options
author | Christian Duerr <contact@christianduerr.com> | 2021-01-03 11:24:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-03 11:24:04 +0000 |
commit | 08e111dfae15d2428d87c3a80c68d858b144d287 (patch) | |
tree | 0ea6953c4c820ce059b05a288ed287e65dd446b3 /alacritty/src/input.rs | |
parent | c1262d78901960b790dfb1f32bb6be99e9237c8c (diff) | |
download | r-alacritty-08e111dfae15d2428d87c3a80c68d858b144d287.tar.gz r-alacritty-08e111dfae15d2428d87c3a80c68d858b144d287.tar.bz2 r-alacritty-08e111dfae15d2428d87c3a80c68d858b144d287.zip |
Fix debug mode crash in vi-less search
Diffstat (limited to 'alacritty/src/input.rs')
-rw-r--r-- | alacritty/src/input.rs | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs index cac21f69..2be0c8c4 100644 --- a/alacritty/src/input.rs +++ b/alacritty/src/input.rs @@ -24,7 +24,7 @@ use glutin::window::CursorIcon; use alacritty_terminal::ansi::{ClearMode, Handler}; use alacritty_terminal::event::EventListener; use alacritty_terminal::grid::{Dimensions, Scroll}; -use alacritty_terminal::index::{Column, Direction, Line, Point, Side}; +use alacritty_terminal::index::{Boundary, Column, Direction, Line, Point, Side}; use alacritty_terminal::selection::SelectionType; use alacritty_terminal::term::{ClipboardType, SizeInfo, Term, TermMode}; use alacritty_terminal::vi_mode::ViMotion; @@ -175,26 +175,35 @@ impl<T: EventListener> Execute<T> for Action { } }, Action::ViAction(ViAction::SearchNext) => { - let origin = ctx.terminal().visible_to_buffer(ctx.terminal().vi_mode_cursor.point); + let terminal = ctx.terminal(); + let origin = terminal + .visible_to_buffer(terminal.vi_mode_cursor.point) + .add_absolute(terminal, Boundary::Wrap, 1); let direction = ctx.search_direction(); - let regex_match = ctx.terminal().search_next(origin, direction, Side::Left, None); + let regex_match = terminal.search_next(origin, direction, Side::Left, None); if let Some(regex_match) = regex_match { ctx.terminal_mut().vi_goto_point(*regex_match.start()); } }, Action::ViAction(ViAction::SearchPrevious) => { - let origin = ctx.terminal().visible_to_buffer(ctx.terminal().vi_mode_cursor.point); + let terminal = ctx.terminal(); + let origin = terminal + .visible_to_buffer(terminal.vi_mode_cursor.point) + .sub_absolute(terminal, Boundary::Wrap, 1); let direction = ctx.search_direction().opposite(); - let regex_match = ctx.terminal().search_next(origin, direction, Side::Left, None); + let regex_match = terminal.search_next(origin, direction, Side::Left, None); if let Some(regex_match) = regex_match { ctx.terminal_mut().vi_goto_point(*regex_match.start()); } }, Action::ViAction(ViAction::SearchStart) => { let terminal = ctx.terminal(); - let origin = terminal.visible_to_buffer(ctx.terminal().vi_mode_cursor.point); + let origin = terminal + .visible_to_buffer(terminal.vi_mode_cursor.point) + .sub_absolute(terminal, Boundary::Wrap, 1); + let regex_match = terminal.search_next(origin, Direction::Left, Side::Left, None); if let Some(regex_match) = regex_match { ctx.terminal_mut().vi_goto_point(*regex_match.start()); @@ -202,7 +211,10 @@ impl<T: EventListener> Execute<T> for Action { }, Action::ViAction(ViAction::SearchEnd) => { let terminal = ctx.terminal(); - let origin = terminal.visible_to_buffer(ctx.terminal().vi_mode_cursor.point); + let origin = terminal + .visible_to_buffer(terminal.vi_mode_cursor.point) + .add_absolute(terminal, Boundary::Wrap, 1); + let regex_match = terminal.search_next(origin, Direction::Right, Side::Right, None); if let Some(regex_match) = regex_match { ctx.terminal_mut().vi_goto_point(*regex_match.end()); |