feat(command-palette): add a read-only reference mode
The shortcuts help panel needs the palette's search and categories without running an action when a binding is chosen, and it lives in a dock where input comes from the terminal rather than the overlay protocol. Read the bindings from a file and skip execution in that mode.
This commit is contained in:
3 files changed
+78
-12
No files matched your search
@@ -74,6 +74,26 @@ func (b *testHandlerBuilder) build() *Handler {
|
||||
return h
|
||||
}
|
||||
|
||||
func TestParseData(t *testing.T) {
|
||||
h := &Handler{}
|
||||
data := []byte(`{"modes":{"":{"Cat":[{"key":"a","action":"x","action_display":"x","definition":"x"}]}},"mouse":[],"mode_order":[""],"category_order":{"":["Cat"]}}`)
|
||||
if err := h.parseData(data); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(h.all_items) != 1 {
|
||||
t.Fatalf("expected 1 item, got %d", len(h.all_items))
|
||||
}
|
||||
if b := h.all_items[0].binding; b.Key != "a" || b.Category != "Cat" {
|
||||
t.Fatalf("unexpected binding: %+v", b)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseDataRejectsEmptyInput(t *testing.T) {
|
||||
if err := (&Handler{}).parseData(nil); err == nil {
|
||||
t.Fatal("expected an error for empty data")
|
||||
}
|
||||
}
|
||||
|
||||
func newTestHandler() *Handler {
|
||||
return newBuilder().
|
||||
addBinding("", "Copy/paste", testBinding("ctrl+shift+c", "copy_to_clipboard", "Copy the selected text from the active window to the clipboard")).
|
||||
|
||||
Reference in new issue
Block a user