Add file and project search panels

This commit is contained in:
slhx agent
2026-06-21 13:11:56 +02:00
parent 70ef989c2a
commit 1d1ecf29d5
5 changed files with 240 additions and 28 deletions
+16 -4
View File
@@ -192,10 +192,22 @@ fn openDirectoryPreview(allocator: std.mem.Allocator, io: std.Io, client: *tui.C
while (try iterator.next(io)) |entry| {
if (count >= 80) break;
if (entry.kind != .file and entry.kind != .directory) continue;
const suffix = if (entry.kind == .directory) "/" else "";
const command = try std.fmt.allocPrint(allocator, "repo_file {s}{s}=", .{ entry.name, suffix });
defer allocator.free(command);
client.handleTraceLine(command) catch {};
const relative_path = try std.fmt.allocPrint(allocator, "{s}/{s}{s}", .{ path, entry.name, if (entry.kind == .directory) "/" else "" });
defer allocator.free(relative_path);
if (entry.kind == .file) {
const bytes = std.Io.Dir.cwd().readFileAlloc(io, relative_path, allocator, .limited(diagnostics.max_file_bytes)) catch |err| switch (err) {
error.StreamTooLong, error.AccessDenied, error.FileNotFound, error.NotDir => null,
else => null,
};
if (bytes) |content| {
defer allocator.free(content);
client.addRepoFileContent(relative_path, content) catch {};
} else {
client.addRepoFileContent(relative_path, "") catch {};
}
} else {
client.addRepoFileContent(relative_path, "") catch {};
}
count += 1;
}
try client.handleTraceLine("file_picker");