feat: make indent_cursor follow indent_mode and insert tabs

This commit is contained in:
CJ van den Berg 2025-07-30 19:17:52 +02:00
parent a74c0ecf46
commit 3abfd6555e
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -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 {