mirror of
https://github.com/wavetermdev/inshellisense.git
synced 2026-08-05 13:43:30 -07:00
fix: suggestions should trigger on first load
Signed-off-by: cpendery <cpendery@vt.edu>
This commit is contained in:
@@ -60,8 +60,9 @@ func New() Model {
|
||||
),
|
||||
}
|
||||
return Model{
|
||||
cursor: 0,
|
||||
keyMap: keyBindings,
|
||||
cursor: 0,
|
||||
keyMap: keyBindings,
|
||||
suggestionId: uuid.New(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +78,10 @@ func SuggestCmd(cmd string, suggestionId uuid.UUID) tea.Cmd {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Model) Init(command string) tea.Cmd {
|
||||
return SuggestCmd(command, m.suggestionId)
|
||||
}
|
||||
|
||||
func (m *Model) cursorUp() {
|
||||
m.cursor = utils.Clamp(m.cursor-1, 0, len(m.suggestions)-1)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package ui
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/charmbracelet/bubbles/cursor"
|
||||
"github.com/charmbracelet/bubbles/textinput"
|
||||
@@ -33,7 +32,7 @@ const (
|
||||
|
||||
func Start(startingContent string) model {
|
||||
ti := textinput.New()
|
||||
ti.SetValue(strings.TrimSpace(startingContent))
|
||||
ti.SetValue(startingContent)
|
||||
ti.Cursor.Style = lipgloss.NewStyle().Foreground(theme.CursorForeground)
|
||||
ti.Focus()
|
||||
sug := suggestions.New()
|
||||
@@ -42,7 +41,7 @@ func Start(startingContent string) model {
|
||||
}
|
||||
|
||||
func (m model) Init() tea.Cmd {
|
||||
return textinput.Blink
|
||||
return tea.Batch(textinput.Blink, m.suggestions.Init(m.textInput.Value()))
|
||||
}
|
||||
|
||||
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
|
||||
Reference in New Issue
Block a user