File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
crates/atuin/src/command/client/search Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,10 @@ impl Cursor {
203203 pub fn start ( & mut self ) {
204204 self . index = 0 ;
205205 }
206+
207+ pub fn position ( & self ) -> usize {
208+ self . index
209+ }
206210}
207211
208212#[ cfg( test) ]
Original file line number Diff line number Diff line change @@ -205,6 +205,9 @@ impl State {
205205
206206 let ctrl = input. modifiers . contains ( KeyModifiers :: CONTROL ) ;
207207 let esc_allow_exit = !( self . tab_index == 0 && self . keymap_mode == KeymapMode :: VimInsert ) ;
208+ let cursor_at_end_of_line =
209+ self . search . input . position ( ) == UnicodeWidthStr :: width ( self . search . input . as_str ( ) ) ;
210+ let cursor_at_start_of_line = self . search . input . position ( ) == 0 ;
208211
209212 // support ctrl-a prefix, like screen or tmux
210213 if !self . prefix
@@ -221,12 +224,14 @@ impl State {
221224 KeyCode :: Esc if esc_allow_exit => Some ( Self :: handle_key_exit ( settings) ) ,
222225 KeyCode :: Char ( '[' ) if ctrl && esc_allow_exit => Some ( Self :: handle_key_exit ( settings) ) ,
223226 KeyCode :: Tab => Some ( InputAction :: Accept ( self . results_state . selected ( ) ) ) ,
227+ KeyCode :: Right if cursor_at_end_of_line => {
228+ Some ( InputAction :: Accept ( self . results_state . selected ( ) ) )
229+ }
230+ KeyCode :: Left if cursor_at_start_of_line => Some ( Self :: handle_key_exit ( settings) ) ,
224231 KeyCode :: Char ( 'o' ) if ctrl => {
225232 self . tab_index = ( self . tab_index + 1 ) % TAB_TITLES . len ( ) ;
226-
227233 Some ( InputAction :: Continue )
228234 }
229-
230235 _ => None ,
231236 } ;
232237
You can’t perform that action at this time.
0 commit comments