aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/menu.rs
diff options
context:
space:
mode:
authorSkyler Hawthorne2022-10-08 22:14:49 +0000
committerMichael Davis2023-08-01 14:41:42 +0000
commit15e07d4db893aec7b9e117c1f88400a68ba98ae2 (patch)
treef3d78f1904c596af44e79d0f850c33c3f518f2fb /helix-term/src/ui/menu.rs
parent93acb538121cab36712f40f26fa287df93817de5 (diff)
feat: smart_tab
Implement `smart_tab`, which optionally makes the tab key run the `move_parent_node_start` command when the cursor has non- whitespace to its left.
Diffstat (limited to 'helix-term/src/ui/menu.rs')
-rw-r--r--helix-term/src/ui/menu.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs
index bdad2e40..c73e7bed 100644
--- a/helix-term/src/ui/menu.rs
+++ b/helix-term/src/ui/menu.rs
@@ -11,7 +11,7 @@ pub use tui::widgets::{Cell, Row};
use fuzzy_matcher::skim::SkimMatcherV2 as Matcher;
use fuzzy_matcher::FuzzyMatcher;
-use helix_view::{graphics::Rect, Editor};
+use helix_view::{editor::SmartTabConfig, graphics::Rect, Editor};
use tui::layout::Constraint;
pub trait Item {
@@ -247,6 +247,21 @@ impl<T: Item + 'static> Component for Menu<T> {
compositor.pop();
}));
+ // Ignore tab key when supertab is turned on in order not to interfere
+ // with it. (Is there a better way to do this?)
+ if (event == key!(Tab) || event == shift!(Tab))
+ && cx.editor.config().auto_completion
+ && matches!(
+ cx.editor.config().smart_tab,
+ Some(SmartTabConfig {
+ enable: true,
+ supersede_menu: true,
+ })
+ )
+ {
+ return EventResult::Ignored(None);
+ }
+
match event {
// esc or ctrl-c aborts the completion and closes the menu
key!(Esc) | ctrl!('c') => {