Expose file and Pi panels
This commit is contained in:
+22
@@ -1313,6 +1313,15 @@ pub const Client = struct {
|
||||
self.panel_context = .file_picker;
|
||||
}
|
||||
|
||||
fn openPiPanel(self: *Client) !void {
|
||||
const rows = [_][]const u8{
|
||||
"pi_ask:explain_current_buffer",
|
||||
"pi_edit:propose_patch",
|
||||
"pi_review:critique_diff",
|
||||
};
|
||||
try self.openListRows("pi", rows[0..], .none);
|
||||
}
|
||||
|
||||
fn openListRows(self: *Client, title: []const u8, rows: []const []const u8, context: PanelContext) !void {
|
||||
if (rows.len == 0) {
|
||||
self.message = "empty list";
|
||||
@@ -2426,6 +2435,7 @@ pub const Client = struct {
|
||||
},
|
||||
.symbol => |symbol| try self.applyProtocol(symbol_mod.protocolCommand(symbol)),
|
||||
.file_picker => try self.openFilePickerPanel(),
|
||||
.pi_panel => try self.openPiPanel(),
|
||||
.search_file => self.openSearchPrompt(),
|
||||
.search_project => self.openProjectSearchPrompt(),
|
||||
.hover => try self.showCompactHover(),
|
||||
@@ -5353,3 +5363,15 @@ test "regular: dot repeats put and remains undoable" {
|
||||
snap = try client.session.snapshot();
|
||||
try std.testing.expectEqualStrings("abcabc", snap.bytes);
|
||||
}
|
||||
|
||||
test "regular: Space P opens Pi panel" {
|
||||
var client = try Client.init(std.testing.allocator, .{ .width = 56, .height = 10 });
|
||||
defer client.deinit();
|
||||
|
||||
try client.handleInput(" ");
|
||||
try client.handleInput("P");
|
||||
const frame = try client.render(std.testing.allocator);
|
||||
defer std.testing.allocator.free(frame);
|
||||
try std.testing.expect(std.mem.indexOf(u8, frame, "panel [pi]") != null);
|
||||
try std.testing.expect(std.mem.indexOf(u8, frame, "pi_ask:explain_current_buffer") != null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user