From 1502a54b34730c25f0af1519f3a19a6597fbf30f Mon Sep 17 00:00:00 2001 From: temportalflux Date: Thu, 25 Jun 2026 18:38:16 -0400 Subject: [PATCH] add action default_bindings documentation table --- .../src/editable_text/actions.rs | 46 +++++++++++++++++-- .../gpui_elements/src/editable_text/state.rs | 4 +- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/crates/gpui_elements/src/editable_text/actions.rs b/crates/gpui_elements/src/editable_text/actions.rs index 65e5696e9b..1072560f51 100644 --- a/crates/gpui_elements/src/editable_text/actions.rs +++ b/crates/gpui_elements/src/editable_text/actions.rs @@ -35,7 +35,7 @@ gpui::actions!( /// Move the cursor down one visual line. NavDown, /// Move cursor to the start of the current line. - Home, + NavLineStart, /// Move cursor to the end of the current line. NavLineEnd, /// Move cursor to the beginning of the content. @@ -82,6 +82,44 @@ gpui::actions!( /// Creates a collection of default keystroke bindings for EditableText actions. /// See [`ActionBindingCollection`](gpui::ActionBindingCollection) docs on how to override these bindings. /// +/// Apple keyboards dont have Home or End keys, so there are common bindings that replace those keys. +/// | Action | All | Linux & Windows | MacOS | +/// | --------------------- | ----------- | ------------------------- | --------------- | +/// | Escape | escape | | | +/// | Enter | enter | | | +/// | Tab | tab | | | +/// | DeleteLeft | backspace | | | +/// | DeleteRight | delete | | | +/// | DeleteWordLeft | | ctrl + backspace | alt + backspace | +/// | DeleteWordRight | | ctrl + delete | alt + delete | +/// | DeleteToLineStart | | ctrl + shift + backspace | cmd + backspace | +/// | DeleteToLineEnd | | ctrl + shift + delete | ctrl + k | +/// | NavLeft | 🡄 | | | +/// | NavRight | 🡆 | | | +/// | NavUp | 🡅 | | | +/// | NavDown | 🡇 | | | +/// | NavLineStart | | home | cmd + 🡄 | +/// | NavLineEnd | | end | cmd + 🡆 | +/// | NavDocumentStart | | ctrl + home | cmd + 🡅 | +/// | NavDocumentEnd | | ctrl + end | cmd + 🡇 | +/// | NavWordLeft | | ctrl + 🡄 | alt + 🡄 | +/// | NavWordRight | | ctrl + 🡆 | alt + 🡆 | +/// | SelectAll | | ctrl + a | cmd + a | +/// | SelectLeft | shift + 🡄 | | | +/// | SelectRight | shift + 🡆 | | | +/// | SelectUp | shift + 🡅 | | | +/// | SelectDown | shift + 🡇 | | | +/// | SelectDocumentStart | | ctrl + shift + home | cmd + shift + 🡅 | +/// | SelectDocumentEnd | | ctrl + shift + end | cmd + shift + 🡇 | +/// | SelectWordLeft | | ctrl + shift + 🡄 | alt + shift + 🡄 | +/// | SelectWordRight | | ctrl + shift + 🡆 | alt + shift + 🡆 | +/// | Cut | | ctrl + x | cmd + x | +/// | Copy | | ctrl + c | cmd + c | +/// | Paste | | ctrl + v | cmd + v | +/// | Undo | | ctrl + z | cmd + z | +/// | Redo | | ctrl + shift + z | cmd + shift + z | +/// | ShowCharacterPalette | | ctrl + space | cmd + space | +/// /// TODO: Collection does not supply a way to unbind a default keystroke pub fn default_bindings() -> gpui::ActionBindingCollection { let mut bindings = gpui::ActionBindingCollection::default() @@ -114,7 +152,7 @@ pub fn default_bindings() -> gpui::ActionBindingCollection { .with::("cmd-backspace") .with::("ctrl-k") // Mac keyboards don't have Home/End keys, so cmd-left/right are standard - .with::("cmd-left") + .with::("cmd-left") .with::("cmd-right") .with::("cmd-up") .with::("cmd-down") @@ -133,7 +171,7 @@ pub fn default_bindings() -> gpui::ActionBindingCollection { .with::("ctrl-delete") .with::("ctrl-shift-backspace") .with::("ctrl-shift-delete") - .with::("home") + .with::("home") .with::("end") .with::("ctrl-home") .with::("ctrl-end") @@ -180,7 +218,7 @@ pub trait EditableTextActionHandler: Sized { /// Move the cursor down one visual line. fn nav_down(&mut self, _: &NavDown, _w: &mut Window, _cx: &mut Context) {} /// Move cursor to the start of the current line. - fn nav_line_start(&mut self, _: &Home, _w: &mut Window, _cx: &mut Context) {} + fn nav_line_start(&mut self, _: &NavLineStart, _w: &mut Window, _cx: &mut Context) {} /// Move cursor to the end of the current line. fn nav_line_end(&mut self, _: &NavLineEnd, _w: &mut Window, _cx: &mut Context) {} /// Move cursor to the start of the document. diff --git a/crates/gpui_elements/src/editable_text/state.rs b/crates/gpui_elements/src/editable_text/state.rs index 68a597b169..eab73a0084 100644 --- a/crates/gpui_elements/src/editable_text/state.rs +++ b/crates/gpui_elements/src/editable_text/state.rs @@ -799,7 +799,7 @@ impl<'app> EditableTextActionHandler> for EditableTextState } } - fn nav_line_start(&mut self, _: &Home, _w: &mut Window, cx: &mut Context<'app, Self>) { + fn nav_line_start(&mut self, _: &NavLineStart, _w: &mut Window, cx: &mut Context<'app, Self>) { // [when not multiline] semantically equivalent to document self.nav_linear(NavigationDirection::Back, TextBoundary::Line, cx); } @@ -1246,7 +1246,7 @@ mod tests { let view = create_test_input(cx, "first\nsecond", 9..9); view.update(cx, |view, window, cx| { view.input.update(cx, |input, cx| { - input.nav_line_start(&Home, window, cx); + input.nav_line_start(&NavLineStart, window, cx); assert_eq!(input.selected_range, 6..6); }); })