fix: restoring of last_find_query from editor state

This commit is contained in:
CJ van den Berg 2025-07-16 16:33:45 +02:00
parent f8d3bbf643
commit 7bdbe60776
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -398,12 +398,12 @@ 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 clipboard: []const u8 = undefined; var clipboard: []const u8 = undefined;
var query: []const u8 = undefined; var last_find_query: []const u8 = undefined;
var find_history: []const u8 = undefined; var find_history: []const u8 = undefined;
if (!try cbor.match(buf, .{ if (!try cbor.match(buf, .{
tp.extract(&file_path), tp.extract(&file_path),
tp.extract(&clipboard), tp.extract(&clipboard),
tp.extract(&query), tp.extract(&last_find_query),
tp.extract(&self.enable_format_on_save), tp.extract(&self.enable_format_on_save),
tp.extract_cbor(&find_history), tp.extract_cbor(&find_history),
tp.extract_cbor(&view_cbor), tp.extract_cbor(&view_cbor),
@ -413,7 +413,7 @@ pub const Editor = struct {
if (op == .open_file) if (op == .open_file)
try self.open(file_path); try self.open(file_path);
self.clipboard = if (clipboard.len > 0) try self.allocator.dupe(u8, clipboard) else null; self.clipboard = if (clipboard.len > 0) try self.allocator.dupe(u8, clipboard) else null;
self.last_find_query = if (query.len > 0) try self.allocator.dupe(u8, clipboard) else null; self.last_find_query = if (last_find_query.len > 0) try self.allocator.dupe(u8, last_find_query) else null;
const rows = self.view.rows; const rows = self.view.rows;
const cols = self.view.cols; const cols = self.view.cols;
if (!try self.view.extract(&view_cbor)) if (!try self.view.extract(&view_cbor))