WIP: Print autoindents on tab

This commit is contained in:
Antonio Scandurra 2021-05-27 18:22:33 +02:00
parent 1cd04bd0d1
commit 362b369448

View file

@ -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<Self>) {
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<Self>) {
let mut old_selections = SmallVec::<[_; 32]>::new();
{