feat: add interactive and non-interactive commands to set the current buffer's tab_width
This commit is contained in:
parent
1632061144
commit
3e0e75c9c8
3 changed files with 39 additions and 0 deletions
|
|
@ -432,6 +432,7 @@ pub const Editor = struct {
|
|||
tp.extract_cbor(&cursels_cbor),
|
||||
}))
|
||||
return error.RestoreStateMatch;
|
||||
self.refresh_tab_width();
|
||||
if (op == .open_file)
|
||||
try self.open(file_path);
|
||||
self.clipboard = if (clipboard.len > 0) try self.allocator.dupe(u8, clipboard) else null;
|
||||
|
|
@ -702,6 +703,23 @@ pub const Editor = struct {
|
|||
return;
|
||||
}
|
||||
|
||||
fn refresh_tab_width(self: *Self) void {
|
||||
self.metrics = self.plane.metrics(self.tab_width);
|
||||
switch (self.indent_mode) {
|
||||
.spaces, .auto => {},
|
||||
.tabs => self.indent_size = self.tab_width,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_tab_width(self: *Self, ctx: Context) Result {
|
||||
var tab_width: usize = 0;
|
||||
if (!try ctx.args.match(.{tp.extract(&tab_width)}))
|
||||
return error.InvalidSetTabWidthArgument;
|
||||
self.tab_width = tab_width;
|
||||
self.refresh_tab_width();
|
||||
}
|
||||
pub const set_tab_width_meta: Meta = .{ .arguments = &.{.integer} };
|
||||
|
||||
fn close(self: *Self) !void {
|
||||
var meta = std.ArrayListUnmanaged(u8).empty;
|
||||
defer meta.deinit(self.allocator);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue