mirror of
https://github.com/sst/opencode.git
synced 2025-09-04 04:00:36 +00:00
feat: believe it or not, even faster tui init
This commit is contained in:
parent
b9f894f1e9
commit
c8eb1b24c3
2 changed files with 11 additions and 14 deletions
|
@ -190,14 +190,17 @@ func (c *completionDialogComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
|
|
||||||
return c, tea.Batch(cmds...)
|
return c, tea.Batch(cmds...)
|
||||||
} else {
|
} else {
|
||||||
items, err := c.completionProvider.GetChildEntries("")
|
cmd := func() tea.Msg {
|
||||||
if err != nil {
|
items, err := c.completionProvider.GetChildEntries("")
|
||||||
// status.Error(err.Error())
|
if err != nil {
|
||||||
|
// status.Error(err.Error())
|
||||||
|
}
|
||||||
|
return items
|
||||||
}
|
}
|
||||||
|
cmds = append(cmds, cmd)
|
||||||
c.list.SetItems(items)
|
cmds = append(cmds, c.pseudoSearchTextArea.Focus())
|
||||||
c.pseudoSearchTextArea.SetValue(msg.String())
|
c.pseudoSearchTextArea.SetValue(msg.String())
|
||||||
return c, c.pseudoSearchTextArea.Focus()
|
return c, tea.Batch(cmds...)
|
||||||
}
|
}
|
||||||
case tea.WindowSizeMsg:
|
case tea.WindowSizeMsg:
|
||||||
c.width = msg.Width
|
c.width = msg.Width
|
||||||
|
@ -247,11 +250,6 @@ func (c *completionDialogComponent) IsEmpty() bool {
|
||||||
func (c *completionDialogComponent) SetProvider(provider CompletionProvider) {
|
func (c *completionDialogComponent) SetProvider(provider CompletionProvider) {
|
||||||
if c.completionProvider.GetId() != provider.GetId() {
|
if c.completionProvider.GetId() != provider.GetId() {
|
||||||
c.completionProvider = provider
|
c.completionProvider = provider
|
||||||
items, err := provider.GetChildEntries("")
|
|
||||||
if err != nil {
|
|
||||||
// status.Error(err.Error())
|
|
||||||
}
|
|
||||||
c.list.SetItems(items)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,6 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
// Get the current text from the editor to determine which provider to use
|
// Get the current text from the editor to determine which provider to use
|
||||||
editorModel := p.editor.GetContent().(interface{ GetValue() string })
|
editorModel := p.editor.GetContent().(interface{ GetValue() string })
|
||||||
currentInput := editorModel.GetValue()
|
currentInput := editorModel.GetValue()
|
||||||
|
|
||||||
provider := p.completionManager.GetProvider(currentInput)
|
provider := p.completionManager.GetProvider(currentInput)
|
||||||
p.completionDialog.SetProvider(provider)
|
p.completionDialog.SetProvider(provider)
|
||||||
|
|
||||||
|
@ -106,9 +105,9 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
p.completionDialog = context.(dialog.CompletionDialog)
|
p.completionDialog = context.(dialog.CompletionDialog)
|
||||||
cmds = append(cmds, contextCmd)
|
cmds = append(cmds, contextCmd)
|
||||||
|
|
||||||
// Doesn't forward event if enter key is pressed and there are completions
|
// Doesn't forward event if enter key is pressed
|
||||||
if keyMsg, ok := msg.(tea.KeyMsg); ok {
|
if keyMsg, ok := msg.(tea.KeyMsg); ok {
|
||||||
if keyMsg.String() == "enter" { // && !p.completionDialog.IsEmpty() {
|
if keyMsg.String() == "enter" {
|
||||||
return p, tea.Batch(cmds...)
|
return p, tea.Batch(cmds...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue