Add a basic `tab` keybinding

Antonio Scandurra and Nathan Sobo created

Co-Authored-By: Nathan Sobo <nathan@zed.dev>

Change summary

gpui/src/platform/mac/event.rs | 2 ++
zed/src/editor/buffer_view.rs  | 1 +
2 files changed, 3 insertions(+)

Detailed changes

gpui/src/platform/mac/event.rs 🔗

@@ -15,6 +15,7 @@ use std::{ffi::CStr, os::raw::c_char};
 const BACKSPACE_KEY: u16 = 0x7f;
 const ENTER_KEY: u16 = 0x0d;
 const ESCAPE_KEY: u16 = 0x1b;
+const TAB_KEY: u16 = 0x09;
 
 impl Event {
     pub unsafe fn from_native(native_event: id, window_height: Option<f32>) -> Option<Self> {
@@ -49,6 +50,7 @@ impl Event {
                         ENTER_KEY => "enter",
                         DELETE_KEY => "delete",
                         ESCAPE_KEY => "escape",
+                        TAB_KEY => "tab",
                         _ => unmodified_chars,
                     }
                 } else {

zed/src/editor/buffer_view.rs 🔗

@@ -36,6 +36,7 @@ pub fn init(app: &mut MutableAppContext) {
         Binding::new("delete", "buffer:delete", Some("BufferView")),
         Binding::new("ctrl-d", "buffer:delete", Some("BufferView")),
         Binding::new("enter", "buffer:newline", Some("BufferView")),
+        Binding::new("tab", "buffer:insert", Some("BufferView")).with_arg("\t".to_string()),
         Binding::new("ctrl-shift-K", "buffer:delete_line", Some("BufferView")),
         Binding::new(
             "alt-backspace",