Skip to content

Commit 6ae0b3f

Browse files
chitao1234ellie
andauthored
feat: make new arrow key behavior configurable (#2606)
* feat: make new arrow key behavior configurable The arrow key behavior in interactive search was changed in #2453, make it configurable via keys.exit_past_line_start and keys.accept_past_line_end * Update crates/atuin-client/config.toml * Update crates/atuin-client/config.toml * Update crates/atuin-client/config.toml * I've made so many typos with these, sorry --------- Co-authored-by: Ellie Huxtable <[email protected]>
1 parent 231d87c commit 6ae0b3f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

crates/atuin-client/config.toml

+4
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ enter_accept = true
209209
[keys]
210210
# Defaults to true. If disabled, using the up/down key won't exit the TUI when scrolled past the first/last entry.
211211
# scroll_exits = true
212+
# Defaults to true. The left arrow key will exit the TUI when scrolling before the first character
213+
# exit_past_line_start = true
214+
# Defaults to true. The right arrow key performs the same functionality as Tab and copies the selected line to the command line to be modified.
215+
# accept_past_line_end = true
212216

213217
[sync]
214218
# Enable sync v2 by default

crates/atuin-client/src/settings.rs

+4
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ pub struct Sync {
330330
#[derive(Clone, Debug, Deserialize, Default, Serialize)]
331331
pub struct Keys {
332332
pub scroll_exits: bool,
333+
pub exit_past_line_start: bool,
334+
pub accept_past_line_end: bool,
333335
pub prefix: String,
334336
}
335337

@@ -777,6 +779,8 @@ impl Settings {
777779
.set_default("enter_accept", false)?
778780
.set_default("sync.records", true)?
779781
.set_default("keys.scroll_exits", true)?
782+
.set_default("keys.accept_past_line_end", true)?
783+
.set_default("keys.exit_past_line_start", true)?
780784
.set_default("keys.prefix", "a")?
781785
.set_default("keymap_mode", "emacs")?
782786
.set_default("keymap_mode_shell", "auto")?

crates/atuin/src/command/client/search/interactive.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,12 @@ impl State {
224224
KeyCode::Esc if esc_allow_exit => Some(Self::handle_key_exit(settings)),
225225
KeyCode::Char('[') if ctrl && esc_allow_exit => Some(Self::handle_key_exit(settings)),
226226
KeyCode::Tab => Some(InputAction::Accept(self.results_state.selected())),
227-
KeyCode::Right if cursor_at_end_of_line => {
227+
KeyCode::Right if cursor_at_end_of_line && settings.keys.accept_past_line_end => {
228228
Some(InputAction::Accept(self.results_state.selected()))
229229
}
230-
KeyCode::Left if cursor_at_start_of_line => Some(Self::handle_key_exit(settings)),
230+
KeyCode::Left if cursor_at_start_of_line && settings.keys.exit_past_line_start => {
231+
Some(Self::handle_key_exit(settings))
232+
}
231233
KeyCode::Char('o') if ctrl => {
232234
self.tab_index = (self.tab_index + 1) % TAB_TITLES.len();
233235
Some(InputAction::Continue)

0 commit comments

Comments
 (0)