mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-06 01:14:52 +01:00
feat(tui): add keymap to remove entries from recently used models (#1019)
This commit is contained in:
@@ -24,6 +24,12 @@ type SearchSelectionMsg struct {
|
||||
// SearchCancelledMsg is emitted when the search is cancelled
|
||||
type SearchCancelledMsg struct{}
|
||||
|
||||
// SearchRemoveItemMsg is emitted when Ctrl+X is pressed to remove an item
|
||||
type SearchRemoveItemMsg struct {
|
||||
Item any
|
||||
Index int
|
||||
}
|
||||
|
||||
// SearchDialog is a reusable component that combines a text input with a list
|
||||
type SearchDialog struct {
|
||||
textInput textinput.Model
|
||||
@@ -38,6 +44,7 @@ type searchKeyMap struct {
|
||||
Down key.Binding
|
||||
Enter key.Binding
|
||||
Escape key.Binding
|
||||
Remove key.Binding
|
||||
}
|
||||
|
||||
var searchKeys = searchKeyMap{
|
||||
@@ -57,6 +64,10 @@ var searchKeys = searchKeyMap{
|
||||
key.WithKeys("esc"),
|
||||
key.WithHelp("esc", "cancel"),
|
||||
),
|
||||
Remove: key.NewBinding(
|
||||
key.WithKeys("ctrl+x"),
|
||||
key.WithHelp("ctrl+x", "remove from recent"),
|
||||
),
|
||||
}
|
||||
|
||||
// NewSearchDialog creates a new SearchDialog
|
||||
@@ -148,6 +159,13 @@ func (s *SearchDialog) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
case key.Matches(msg, searchKeys.Remove):
|
||||
if selectedItem, idx := s.list.GetSelectedItem(); idx != -1 {
|
||||
return s, func() tea.Msg {
|
||||
return SearchRemoveItemMsg{Item: selectedItem, Index: idx}
|
||||
}
|
||||
}
|
||||
|
||||
case key.Matches(msg, searchKeys.Up):
|
||||
var cmd tea.Cmd
|
||||
listModel, cmd := s.list.Update(msg)
|
||||
|
||||
Reference in New Issue
Block a user