From 6af9a06e74a658e03bc116c940eb427f5805e01f Mon Sep 17 00:00:00 2001 From: wongjiahau Date: Thu, 23 Feb 2023 10:52:18 +0800 Subject: [PATCH] feat(explorer): bind "="/"_" to "Zoom in"/"Zoom out" --- changes | 2 ++ helix-term/src/ui/explorer.rs | 4 ++-- helix-term/src/ui/tree.rs | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/changes b/changes index 52633356..6429aa7f 100644 --- a/changes +++ b/changes @@ -29,6 +29,7 @@ TODO - [x] refactor, add tree.expand_children() method New: +- [x] increase indentation - [x] Change '[' to "go to previous root" - [x] Change 'b' to "go to parent" - [x] Use C-o for jumping to previous position @@ -44,6 +45,7 @@ New: - [x] add integration test for Explorer - [x] bind "o" to open/close file/folder - [x] bind "C-n/C-p" to up/down +- [x] bind "="/"_" to zoom-in/zoom-out - [] search highlight matching word - [] Error didn't clear - [] should preview be there by default? diff --git a/helix-term/src/ui/explorer.rs b/helix-term/src/ui/explorer.rs index b297c610..e766eee6 100644 --- a/helix-term/src/ui/explorer.rs +++ b/helix-term/src/ui/explorer.rs @@ -797,8 +797,8 @@ impl Component for Explorer { key!('[') => self.go_to_previous_root(), key!('d') => self.new_remove_prompt()?, key!('r') => self.new_rename_prompt(cx), - key!('-') => self.decrease_size(), - key!('+') => self.increase_size(), + key!('-') | key!('_') => self.decrease_size(), + key!('+') | key!('=') => self.increase_size(), _ => { self.tree .handle_event(&Event::Key(*key_event), cx, &mut self.state, &filter); diff --git a/helix-term/src/ui/tree.rs b/helix-term/src/ui/tree.rs index 1b62fc5a..b909b272 100644 --- a/helix-term/src/ui/tree.rs +++ b/helix-term/src/ui/tree.rs @@ -662,7 +662,10 @@ impl TreeView { fn move_right(&mut self, cols: usize) { self.pre_render = Some(Box::new(move |tree, area| { - let max_scroll = tree.max_len.saturating_sub(area.width as usize); + let max_scroll = tree + .max_len + .saturating_sub(area.width as usize) + .saturating_add(1); tree.column = max_scroll.min(tree.column + cols); })); }