Skip to content

Commit 78f8adf

Browse files
authored
status: fix exec command history not applied (#458)
Previously, in `exec jj` mode, typing triggers fuzzy/regex suggestions from command history. However, when selecting a suggestion and pressing Enter, the command executed was still the original typed input instead of the selected history command. The issue was that, the input field's value isn't updated upon entry selection in command history. This fix checks if there's a selected match in the fuzzy suggestions list before executing. If there is one, it: 1. Gets the selected match string 2. Strips the single quotes that SelectedMatch wraps around the value 3. Updates the input value with so it also gets saved to history correctly
1 parent 036eb76 commit 78f8adf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

internal/ui/status/status.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd {
145145
input := m.input.Value()
146146
prompt := m.input.Prompt
147147
fuzzy := m.fuzzy
148+
// If there's a selected match in the fuzzy list, use that instead
149+
if fuzzy != nil {
150+
if selected := fuzzy_search.SelectedMatch(fuzzy); selected != "" {
151+
// SelectedMatch returns the value wrapped in single quotes, remove them
152+
input = strings.Trim(selected, "'")
153+
m.input.SetValue(input)
154+
}
155+
}
148156
m.saveEditingSuggestions()
149157

150158
m.fuzzy = nil

0 commit comments

Comments
 (0)