refactor: clean-up naming of file_tree_palette.Value.follow_path

This commit is contained in:
CJ van den Berg 2026-02-19 20:08:16 +01:00
parent 7708457bb8
commit d442769958
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -44,9 +44,9 @@ pub const Entry = struct {
pub fn deinit(palette: *Type) void { pub fn deinit(palette: *Type) void {
tui.message_filters().remove_ptr(palette); tui.message_filters().remove_ptr(palette);
palette.value.pending_node = null; palette.value.pending_node = null;
if (palette.value.follow_file_path) |path| { if (palette.value.follow_path) |path| {
palette.allocator.free(path); palette.allocator.free(path);
palette.value.follow_file_path = null; palette.value.follow_path = null;
} }
if (palette.value.root_node) |node| { if (palette.value.root_node) |node| {
deinit_root_node(palette.allocator, node); deinit_root_node(palette.allocator, node);
@ -74,7 +74,7 @@ fn deinit_node(allocator: std.mem.Allocator, node: *Node) void {
pub const ValueType = struct { pub const ValueType = struct {
root_node: ?*Node = null, root_node: ?*Node = null,
pending_node: ?*Node = null, pending_node: ?*Node = null,
follow_file_path: ?[]const u8 = null, follow_path: ?[]const u8 = null,
}; };
pub const defaultValue: ValueType = .{}; pub const defaultValue: ValueType = .{};
@ -128,7 +128,7 @@ fn receive_project_manager(palette: *Type, _: tp.pid_ref, m: tp.message) Message
palette.entries.clearRetainingCapacity(); palette.entries.clearRetainingCapacity();
if (palette.value.root_node) |root| try build_visible_list(palette, root, 0); if (palette.value.root_node) |root| try build_visible_list(palette, root, 0);
palette.longest_hint = max_entry_overhead(palette); palette.longest_hint = max_entry_overhead(palette);
try follow_file(palette, pending); try follow_path(palette, pending);
palette.start_query(0) catch {}; palette.start_query(0) catch {};
tui.need_render(@src()); tui.need_render(@src());
} else if (try cbor.match(m.buf, .{ "PRJ", "path_error", tp.any, tp.any, tp.any })) { } else if (try cbor.match(m.buf, .{ "PRJ", "path_error", tp.any, tp.any, tp.any })) {
@ -169,9 +169,9 @@ fn max_entry_overhead(palette: *Type) usize {
return max_overhead; return max_overhead;
} }
fn follow_file(palette: *Type, pending_: ?*Node) !void { fn follow_path(palette: *Type, pending_: ?*Node) !void {
const pending = pending_ orelse return; const pending = pending_ orelse return;
const target = palette.value.follow_file_path orelse return; const target = palette.value.follow_path orelse return;
const children = pending.children orelse return; const children = pending.children orelse return;
for (children.items) |*child| { for (children.items) |*child| {
@ -183,13 +183,13 @@ fn follow_file(palette: *Type, pending_: ?*Node) !void {
return; return;
} else if (child.type_ == .file and std.mem.eql(u8, target, child.path)) { } else if (child.type_ == .file and std.mem.eql(u8, target, child.path)) {
select_child(palette, child); select_child(palette, child);
palette.allocator.free(palette.value.follow_file_path.?); palette.allocator.free(palette.value.follow_path.?);
palette.value.follow_file_path = null; palette.value.follow_path = null;
return; return;
} }
} }
palette.allocator.free(palette.value.follow_file_path.?); palette.allocator.free(palette.value.follow_path.?);
palette.value.follow_file_path = null; palette.value.follow_path = null;
} }
fn select_child(palette: *Type, child: *Node) void { fn select_child(palette: *Type, child: *Node) void {
@ -230,7 +230,7 @@ pub fn load_entries(palette: *Type) !usize {
}; };
palette.value.root_node = node; palette.value.root_node = node;
if (tui.get_active_editor()) |editor| if (editor.file_path) |file_path| { if (tui.get_active_editor()) |editor| if (editor.file_path) |file_path| {
palette.value.follow_file_path = try palette.allocator.dupe(u8, file_path); palette.value.follow_path = try palette.allocator.dupe(u8, file_path);
}; };
try request_node_children(palette, node); try request_node_children(palette, node);
return 0; return 0;