mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-22 10:14:22 +01:00
feat(tui): more ways to quit
This commit is contained in:
@@ -344,6 +344,12 @@ func (m *editorComponent) Submit() (tea.Model, tea.Cmd) {
|
||||
if value == "" {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
switch value {
|
||||
case "exit", "quit", "q", ":q":
|
||||
return m, tea.Quit
|
||||
}
|
||||
|
||||
if len(value) > 0 && value[len(value)-1] == '\\' {
|
||||
// If the last character is a backslash, remove it and add a newline
|
||||
m.textarea.ReplaceRange(len(value)-1, len(value), "")
|
||||
|
||||
@@ -85,7 +85,7 @@ func (c *completionDialogComponent) getAllCompletions(query string) tea.Cmd {
|
||||
}
|
||||
|
||||
// If there's a query, use fuzzy ranking to sort results
|
||||
if query != "" && len(allItems) > 0 {
|
||||
if query != "" && len(allItems) > 0 && len(c.providers) > 1 {
|
||||
t := theme.CurrentTheme()
|
||||
baseStyle := styles.NewStyle().Background(t.BackgroundElement())
|
||||
// Create a slice of display values for fuzzy matching
|
||||
@@ -94,10 +94,7 @@ func (c *completionDialogComponent) getAllCompletions(query string) tea.Cmd {
|
||||
displayValues[i] = item.Display(baseStyle)
|
||||
}
|
||||
|
||||
// Get fuzzy matches with ranking
|
||||
matches := fuzzy.RankFindFold(query, displayValues)
|
||||
|
||||
// Sort by score (best matches first)
|
||||
sort.Sort(matches)
|
||||
|
||||
// Reorder items based on fuzzy ranking
|
||||
|
||||
Reference in New Issue
Block a user