diff --git a/internal/ui/bookmarks/bookmarks.go b/internal/ui/bookmarks/bookmarks.go index 94b6b53..f5948ab 100644 --- a/internal/ui/bookmarks/bookmarks.go +++ b/internal/ui/bookmarks/bookmarks.go @@ -329,7 +329,7 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd { return nil case intents.Intent: return m.handleIntent(msg) - case tea.KeyMsg: + case tea.KeyMsg, tea.PasteMsg: if m.filterState == filterEditing { updated, cmd := m.filterInput.Update(msg) filterChanged := m.filterInput.Value() != updated.Value() @@ -339,7 +339,11 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd { } return cmd } - if cmd := m.handleIntent(intents.BookmarksApplyShortcut{Key: msg.String()}); cmd != nil { + keyMsg, ok := msg.(tea.KeyMsg) + if !ok { + return nil + } + if cmd := m.handleIntent(intents.BookmarksApplyShortcut{Key: keyMsg.String()}); cmd != nil { return cmd } case updateItemsMsg: diff --git a/internal/ui/bookmarks/bookmarks_test.go b/internal/ui/bookmarks/bookmarks_test.go index 3300030..b6d6c67 100644 --- a/internal/ui/bookmarks/bookmarks_test.go +++ b/internal/ui/bookmarks/bookmarks_test.go @@ -97,3 +97,17 @@ main;.;false;false;false;86 test.SimulateModel(op, func() tea.Msg { return intents.BookmarksFilter{Kind: intents.BookmarksFilterMove} }) test.SimulateModel(op, func() tea.Msg { return intents.BookmarksFilter{Kind: intents.BookmarksFilterMove} }) } + +func Test_FilterEditing_AcceptsPasteMsg(t *testing.T) { + commandRunner := test.NewTestCommandRunner(t) + commandRunner.Expect(jj.GitRemoteList()).SetOutput([]byte("")) + defer commandRunner.Verify() + + commit := &jj.Commit{ChangeId: "abc123", CommitId: "commit123"} + op := NewModel(test.NewTestContext(commandRunner), commit, []string{"commit123"}) + + test.SimulateModel(op, func() tea.Msg { return intents.BookmarksOpenFilter{} }) + test.SimulateModel(op, func() tea.Msg { return tea.PasteMsg{Content: "track feature"} }) + + assert.Equal(t, "track feature", op.filterInput.Value()) +} diff --git a/internal/ui/choose/choose.go b/internal/ui/choose/choose.go index 4a40e8a..1081caf 100644 --- a/internal/ui/choose/choose.go +++ b/internal/ui/choose/choose.go @@ -127,14 +127,18 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd { } return newCmd(CancelledMsg{}) } - case tea.KeyMsg: + case tea.KeyMsg, tea.PasteMsg: if m.filtering { m.input, cmd = m.input.Update(msg) m.filterOptions() return cmd } + keyMsg, ok := msg.(tea.KeyMsg) + if !ok { + return nil + } if m.ordered { - if r := msg.String(); len(r) == 1 && r[0] >= '1' && r[0] <= '9' { + if r := keyMsg.String(); len(r) == 1 && r[0] >= '1' && r[0] <= '9' { idx := int(r[0] - '1') if idx < len(m.filteredOptions) { m.selected = idx @@ -142,7 +146,7 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd { } } } - if m.filterable && msg.String() == "/" { + if m.filterable && keyMsg.String() == "/" { m.filtering = true m.input.Focus() return textinput.Blink diff --git a/internal/ui/git/git.go b/internal/ui/git/git.go index a5ca5ca..cd3cea0 100644 --- a/internal/ui/git/git.go +++ b/internal/ui/git/git.go @@ -176,7 +176,7 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd { return nil case intents.Intent: return m.handleIntent(msg) - case tea.KeyMsg: + case tea.KeyMsg, tea.PasteMsg: if m.filterState == filterEditing { updated, cmd := m.filterInput.Update(msg) filterChanged := m.filterInput.Value() != updated.Value() @@ -186,7 +186,11 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd { } return cmd } - if cmd := m.handleIntent(intents.GitApplyShortcut{Key: msg.String()}); cmd != nil { + keyMsg, ok := msg.(tea.KeyMsg) + if !ok { + return nil + } + if cmd := m.handleIntent(intents.GitApplyShortcut{Key: keyMsg.String()}); cmd != nil { return cmd } } diff --git a/internal/ui/help/help.go b/internal/ui/help/help.go index 741bb9b..b2c6643 100644 --- a/internal/ui/help/help.go +++ b/internal/ui/help/help.go @@ -173,7 +173,7 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd { } else { m.scroll = max(0, m.scroll+msg.Delta) } - case tea.KeyMsg: + case tea.KeyMsg, tea.PasteMsg: if m.filtering { prev := m.input.Value() var cmd tea.Cmd diff --git a/internal/ui/input/input.go b/internal/ui/input/input.go index 7e603a4..efc6529 100644 --- a/internal/ui/input/input.go +++ b/internal/ui/input/input.go @@ -87,7 +87,7 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd { return newCmd(CancelledMsg{}) } return nil - case tea.KeyMsg: + case tea.KeyMsg, tea.PasteMsg: var cmd tea.Cmd m.input, cmd = m.input.Update(msg) return cmd diff --git a/internal/ui/operations/target_picker/target_picker.go b/internal/ui/operations/target_picker/target_picker.go index fc7fb8a..2f292ad 100644 --- a/internal/ui/operations/target_picker/target_picker.go +++ b/internal/ui/operations/target_picker/target_picker.go @@ -161,7 +161,7 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd { } return nil } - case tea.KeyMsg: + case tea.KeyMsg, tea.PasteMsg: var cmd tea.Cmd m.input, cmd = m.input.Update(msg) m.search(m.input.Value()) diff --git a/internal/ui/password/password.go b/internal/ui/password/password.go index 7b2378d..cebd526 100644 --- a/internal/ui/password/password.go +++ b/internal/ui/password/password.go @@ -63,7 +63,7 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd { } } return nil - case tea.KeyMsg: + case tea.KeyMsg, tea.PasteMsg: var cmd tea.Cmd m.textInput, cmd = m.textInput.Update(msg) return cmd diff --git a/internal/ui/status/status.go b/internal/ui/status/status.go index fef61a3..4cbe71c 100644 --- a/internal/ui/status/status.go +++ b/internal/ui/status/status.go @@ -136,7 +136,7 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd { return m.fuzzy.Update(msg) } return nil - case tea.KeyMsg: + case tea.KeyMsg, tea.PasteMsg: if m.IsFocused() { var cmd tea.Cmd previous := m.input.Value()