Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(client): add config option keys.scroll_exits #1744

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions atuin-client/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,7 @@ enter_accept = true

## Set commands that will be completely ignored from stats
#ignored_commands = ["cd", "ls", "vi"]

[keys]
# Defaults to true. If disabled, using the up/down key won't exit the TUI when scrolled past the first/last entry.
# scroll_exits = false
9 changes: 9 additions & 0 deletions atuin-client/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ pub struct Sync {
pub records: bool,
}

#[derive(Clone, Debug, Deserialize, Default)]
pub struct Keys {
pub scroll_exits: bool,
}

#[derive(Clone, Debug, Deserialize)]
pub struct Settings {
pub dialect: Dialect,
Expand Down Expand Up @@ -360,6 +365,9 @@ pub struct Settings {
#[serde(default)]
pub sync: Sync,

#[serde(default)]
pub keys: Keys,

// This is automatically loaded when settings is created. Do not set in
// config! Keep secrets and settings apart.
#[serde(skip)]
Expand Down Expand Up @@ -588,6 +596,7 @@ impl Settings {
// New users will get the new default, that is more similar to what they are used to.
.set_default("enter_accept", false)?
.set_default("sync.records", false)?
.set_default("keys.scroll_exits", true)?
.set_default("keymap_mode", "emacs")?
.set_default("keymap_mode_shell", "auto")?
.set_default("keymap_cursor", HashMap::<String, String>::new())?
Expand Down
2 changes: 1 addition & 1 deletion atuin/src/command/client/search/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl State {
is_down: bool,
) -> InputAction {
if is_down {
if enable_exit && self.results_state.selected() == 0 {
if settings.keys.scroll_exits && enable_exit && self.results_state.selected() == 0 {
return Self::handle_key_exit(settings);
}
self.scroll_down(1);
Expand Down