Option to configure wrapping on move

Closes: https://github.com/sayanarijit/xplr/issues/441
pull/453/head
Arijit Basu 2 years ago committed by Arijit Basu
parent 618ade53ec
commit ecc59b1d9d

@ -1787,9 +1787,15 @@ impl App {
}
fn focus_previous(mut self) -> Result<Self> {
let bounded = self.config.general.enforce_bounded_index_navigation;
if let Some(dir) = self.directory_buffer_mut() {
dir.focus = if dir.focus == 0 {
dir.total.max(1) - 1
if bounded {
dir.focus
} else {
dir.total.max(1) - 1
}
} else {
dir.focus.max(1) - 1
};
@ -1828,9 +1834,15 @@ impl App {
}
fn focus_next(mut self) -> Result<Self> {
let bounded = self.config.general.enforce_bounded_index_navigation;
if let Some(dir) = self.directory_buffer_mut() {
dir.focus = if (dir.focus + 1) == dir.total {
0
if bounded {
dir.focus
} else {
0
}
} else {
dir.focus + 1
}

@ -234,6 +234,9 @@ pub struct GeneralConfig {
#[serde(default)]
pub hide_remaps_in_help_menu: bool,
#[serde(default)]
pub enforce_bounded_index_navigation: bool,
#[serde(default)]
pub prompt: UiElement,

@ -42,6 +42,15 @@ xplr.config.general.enable_recover_mode = false
-- Type: boolean
xplr.config.general.hide_remaps_in_help_menu = false
-- Set it to `true` if you want the cursor to stay in the same position when
-- the focus is on the first path and you navigate to the previous path
-- (by pressing `up`/`k`), or when the focus is on the last path and you
-- navigate to the next path (by pressing `down`/`j`).
-- The default behavior is to rotate from the last/first path.
--
-- Type: boolean
xplr.config.general.enforce_bounded_index_navigation = false
-- This is the shape of the prompt for the input buffer.
--
-- Type: nullable string

Loading…
Cancel
Save