From 3abfd6555e0fb2ca315b42f55ad77a7fabf4eaad Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 30 Jul 2025 19:17:52 +0200 Subject: [PATCH] feat: make indent_cursor follow indent_mode and insert tabs --- src/tui/editor.zig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index f9e84d9..5424ab7 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -3679,9 +3679,16 @@ pub const Editor = struct { const space = " "; var cursel: CurSel = .{}; cursel.cursor = cursor; - const cols = self.indent_size - find_first_non_ws(root, cursel.cursor.row, self.metrics) % self.indent_size; try move_cursor_begin(root, &cursel.cursor, self.metrics); - return self.insert(root, &cursel, space[0..cols], allocator) catch return error.Stop; + switch (self.indent_mode) { + .spaces, .auto => { + const cols = self.indent_size - find_first_non_ws(root, cursel.cursor.row, self.metrics) % self.indent_size; + return self.insert(root, &cursel, space[0..cols], allocator) catch return error.Stop; + }, + .tabs => { + return self.insert(root, &cursel, "\t", allocator) catch return error.Stop; + }, + } } fn indent_cursel(self: *Self, root_: Buffer.Root, cursel: *CurSel, allocator: Allocator) error{Stop}!Buffer.Root {