feat: make indent_size always equal to tab_width in indent_mode tabs

This commit is contained in:
CJ van den Berg 2025-07-30 20:03:12 +02:00
parent 4100585b03
commit ed1fe30e74
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -460,9 +460,9 @@ pub const Editor = struct {
fn init(self: *Self, allocator: Allocator, n: Plane, buffer_manager: *Buffer.Manager) void { fn init(self: *Self, allocator: Allocator, n: Plane, buffer_manager: *Buffer.Manager) void {
const logger = log.logger("editor"); const logger = log.logger("editor");
const frame_rate = tp.env.get().num("frame-rate"); const frame_rate = tp.env.get().num("frame-rate");
const indent_size = tui.config().indent_size;
const tab_width = tui.config().tab_width; const tab_width = tui.config().tab_width;
const indent_mode = tui.config().indent_mode; const indent_mode = tui.config().indent_mode;
const indent_size = if (indent_mode == .tabs) tab_width else tui.config().indent_size;
self.* = Self{ self.* = Self{
.allocator = allocator, .allocator = allocator,
.plane = n, .plane = n,
@ -683,10 +683,12 @@ pub const Editor = struct {
while (it.next()) |line| { while (it.next()) |line| {
if (line.len == 0) continue; if (line.len == 0) continue;
if (line[0] == '\t') { if (line[0] == '\t') {
self.indent_size = self.tab_width;
self.indent_mode = .tabs; self.indent_mode = .tabs;
return; return;
} }
} }
self.indent_size = tui.config().indent_size;
self.indent_mode = .spaces; self.indent_mode = .spaces;
return; return;
} }