Add file and project search panels
This commit is contained in:
+8
-6
@@ -21,7 +21,9 @@ pub const Action = union(enum) {
|
||||
quit,
|
||||
open: []u8,
|
||||
symbol: symbol_mod.Symbol,
|
||||
file_picker,
|
||||
search_file,
|
||||
search_project,
|
||||
repeat_rail,
|
||||
restore_last,
|
||||
not_built: Feature,
|
||||
@@ -127,6 +129,10 @@ pub const Leader = struct {
|
||||
self.mode = .open_prompt;
|
||||
return .none;
|
||||
}
|
||||
if (std.mem.eql(u8, text, "f")) {
|
||||
self.mode = .idle;
|
||||
return .file_picker;
|
||||
}
|
||||
if (std.mem.eql(u8, text, "p")) {
|
||||
self.mode = .symbol_rail;
|
||||
return .none;
|
||||
@@ -174,6 +180,7 @@ pub const Leader = struct {
|
||||
.text => |text| {
|
||||
self.mode = .idle;
|
||||
if (std.mem.eql(u8, text, "f")) return .search_file;
|
||||
if (std.mem.eql(u8, text, "p")) return .search_project;
|
||||
self.message = "search target is not built in this profile yet";
|
||||
return .{ .not_built = .search };
|
||||
},
|
||||
@@ -325,12 +332,7 @@ test "regular: search rail opens current-file search and rejects other targets"
|
||||
|
||||
try expectActionTag(.none, try leader.handleEvent(input.normalize(" ")));
|
||||
try expectActionTag(.none, try leader.handleEvent(input.normalize("s")));
|
||||
const action = try leader.handleEvent(input.normalize("p"));
|
||||
switch (action) {
|
||||
.not_built => |feature| try std.testing.expectEqual(Feature.search, feature),
|
||||
else => return error.ExpectedNotBuiltAction,
|
||||
}
|
||||
try std.testing.expectEqualStrings("search target is not built in this profile yet", leader.status());
|
||||
try expectActionTag(.search_project, try leader.handleEvent(input.normalize("p")));
|
||||
}
|
||||
|
||||
test "adversarial: unknown leader key does not dispatch and recovers to idle" {
|
||||
|
||||
Reference in New Issue
Block a user