diff --git a/zed/src/editor/buffer_view.rs b/zed/src/editor/buffer_view.rs index e2516d2113..b741f271cc 100644 --- a/zed/src/editor/buffer_view.rs +++ b/zed/src/editor/buffer_view.rs @@ -41,7 +41,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("tab", "buffer:print_autoindents", Some("BufferView")), Binding::new("ctrl-shift-K", "buffer:delete_line", Some("BufferView")), Binding::new( "alt-backspace", @@ -177,6 +177,7 @@ pub fn init(app: &mut MutableAppContext) { ), ]); + app.add_action("buffer:print_autoindents", BufferView::print_autoindents); app.add_action("buffer:scroll", BufferView::scroll); app.add_action("buffer:select", BufferView::select); app.add_action("buffer:cancel", BufferView::cancel); @@ -638,6 +639,11 @@ impl BufferView { Ok(()) } + pub fn print_autoindents(&mut self, _: &(), ctx: &mut ViewContext) { + let buf = self.buffer.read(ctx); + dbg!(buf.autoindent_for_rows(0..buf.row_count())); + } + pub fn insert(&mut self, text: &String, ctx: &mut ViewContext) { let mut old_selections = SmallVec::<[_; 32]>::new(); {