fix: make unindent_cursor work correctly in indent_mode tabs

This commit is contained in:
CJ van den Berg 2025-07-30 20:04:26 +02:00
parent ed1fe30e74
commit 666d30df3b
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -3725,16 +3725,16 @@ pub const Editor = struct {
const off = first % self.indent_size; const off = first % self.indent_size;
const cols = if (off == 0) self.indent_size else off; const cols = if (off == 0) self.indent_size else off;
const sel = cursel.enable_selection(root, self.metrics) catch return error.Stop; const sel = cursel.enable_selection(root, self.metrics) catch return error.Stop;
sel.begin.move_begin(); try sel.begin.move_to(root, sel.begin.row, first, self.metrics);
try sel.end.move_to(root, sel.end.row, cols, self.metrics); try sel.end.move_to(root, sel.end.row, first - cols, self.metrics);
var saved = false; var saved = false;
if (cursor_protect) |cp| if (cp.row == cursor.row and cp.col < cols) { if (cursor_protect) |cp| if (cp.row == cursor.row and cp.col < first and cp.col >= first - cols) {
cp.col = cols + 1; cp.col = first + 1;
saved = true; saved = true;
}; };
newroot = try self.delete_selection(root, &cursel, allocator); newroot = try self.delete_selection(root, &cursel, allocator);
if (cursor_protect) |cp| if (saved) { if (cursor_protect) |cp| if (saved) {
try cp.move_to(root, cp.row, 0, self.metrics); try cp.move_to(root, cp.row, first - cols, self.metrics);
cp.clamp_to_buffer(newroot, self.metrics); cp.clamp_to_buffer(newroot, self.metrics);
}; };
return newroot; return newroot;