Compare commits

..

No commits in common. "6fce29f8761a2b4187a114285bee4fece895f7f9" and "7d2e6a3b459f3cc2f26b901e01d8fc8a4c38ec37" have entirely different histories.

2 changed files with 6 additions and 19 deletions

View file

@ -208,7 +208,6 @@ const suppressed_errors = std.StaticStringMap(void).initComptime(.{
.{ "enable_fast_scroll", void }, .{ "enable_fast_scroll", void },
.{ "disable_fast_scroll", void }, .{ "disable_fast_scroll", void },
.{ "clear_diagnostics", void }, .{ "clear_diagnostics", void },
.{ "palette_menu_cancel", void },
}); });
pub fn executeName(name: []const u8, ctx: Context) tp.result { pub fn executeName(name: []const u8, ctx: Context) tp.result {

View file

@ -270,16 +270,11 @@ pub const TriggerSymbol = struct {
pub fn cborEncode(self: @This(), writer: *std.Io.Writer) std.io.Writer.Error!void { pub fn cborEncode(self: @This(), writer: *std.Io.Writer) std.io.Writer.Error!void {
try cbor.writeArrayHeader(writer, 2); try cbor.writeArrayHeader(writer, 2);
try cbor.writeValue(writer, self.char); try cbor.writeValue(writer, self.char);
try cbor.writeValue(writer, command.get_name(self.command)); try cbor.writeValue(writer, self.command);
} }
pub fn cborExtract(self: *@This(), iter: *[]const u8) cbor.Error!bool { pub fn cborExtract(self: *@This(), iter: *[]const u8) cbor.Error!bool {
var command_name: []const u8 = undefined; return try cbor.matchValue(iter, .{ cbor.extract(&self.char), cbor.extract(&self.command) });
if (try cbor.matchValue(iter, .{ cbor.extract(&self.char), cbor.extract(&command_name) })) {
self.command = command.get_id(command_name) orelse command.ID_unknown;
return true;
}
return false;
} }
}; };
@ -501,8 +496,8 @@ pub const Editor = struct {
try cbor.writeValue(writer, self.tab_width); try cbor.writeValue(writer, self.tab_width);
try cbor.writeValue(writer, self.indent_mode); try cbor.writeValue(writer, self.indent_mode);
try cbor.writeValue(writer, self.syntax_no_render); try cbor.writeValue(writer, self.syntax_no_render);
try cbor.writeValue(writer, self.insert_triggers.items); try cbor.writeValue(writer, self.insert_triggers);
try cbor.writeValue(writer, self.delete_triggers.items); try cbor.writeValue(writer, self.delete_triggers);
if (self.find_history) |history| { if (self.find_history) |history| {
try cbor.writeArrayHeader(writer, history.items.len); try cbor.writeArrayHeader(writer, history.items.len);
for (history.items) |item| for (history.items) |item|
@ -524,8 +519,6 @@ pub const Editor = struct {
var view_cbor: []const u8 = undefined; var view_cbor: []const u8 = undefined;
var cursels_cbor: []const u8 = undefined; var cursels_cbor: []const u8 = undefined;
var last_find_query: []const u8 = undefined; var last_find_query: []const u8 = undefined;
var insert_triggers: []TriggerSymbol = undefined;
var delete_triggers: []TriggerSymbol = undefined;
var find_history: []const u8 = undefined; var find_history: []const u8 = undefined;
if (!try cbor.matchValue(iter, .{ if (!try cbor.matchValue(iter, .{
tp.extract(&file_path), tp.extract(&file_path),
@ -535,17 +528,13 @@ pub const Editor = struct {
tp.extract(&self.tab_width), tp.extract(&self.tab_width),
tp.extract(&self.indent_mode), tp.extract(&self.indent_mode),
tp.extract(&self.syntax_no_render), tp.extract(&self.syntax_no_render),
cbor.extractAlloc(&insert_triggers, self.allocator), cbor.extractAlloc(&self.insert_triggers, self.allocator),
cbor.extractAlloc(&delete_triggers, self.allocator), cbor.extractAlloc(&self.delete_triggers, self.allocator),
tp.extract_cbor(&find_history), tp.extract_cbor(&find_history),
tp.extract_cbor(&view_cbor), tp.extract_cbor(&view_cbor),
tp.extract_cbor(&cursels_cbor), tp.extract_cbor(&cursels_cbor),
})) }))
return error.RestoreStateMatch; return error.RestoreStateMatch;
self.insert_triggers.deinit(self.allocator);
self.insert_triggers = .fromOwnedSlice(insert_triggers);
self.delete_triggers.deinit(self.allocator);
self.delete_triggers = .fromOwnedSlice(delete_triggers);
self.refresh_tab_width(); self.refresh_tab_width();
if (op == .open_file) if (op == .open_file)
try self.open(file_path); try self.open(file_path);
@ -6240,7 +6229,6 @@ pub const Editor = struct {
} }
pub fn add_symbol_trigger(self: *Self, char: u8, command_: command.ID, event: TriggerEvent) error{OutOfMemory}!void { pub fn add_symbol_trigger(self: *Self, char: u8, command_: command.ID, event: TriggerEvent) error{OutOfMemory}!void {
for (self.get_event_triggers(event).items) |item| if (item.char == char and item.command == command_) return;
(try self.get_event_triggers(event).addOne(self.allocator)).* = .{ .char = char, .command = command_ }; (try self.get_event_triggers(event).addOne(self.allocator)).* = .{ .char = char, .command = command_ };
} }