mirror of
https://github.com/sst/opencode.git
synced 2025-08-04 05:28:16 +00:00
Add debounce before exit when using non-leader exit command (#759)
This commit is contained in:
parent
cfc715bd48
commit
7893b84614
2 changed files with 53 additions and 3 deletions
|
@ -38,6 +38,7 @@ type EditorComponent interface {
|
|||
Paste() (tea.Model, tea.Cmd)
|
||||
Newline() (tea.Model, tea.Cmd)
|
||||
SetInterruptKeyInDebounce(inDebounce bool)
|
||||
SetExitKeyInDebounce(inDebounce bool)
|
||||
}
|
||||
|
||||
type editorComponent struct {
|
||||
|
@ -45,6 +46,7 @@ type editorComponent struct {
|
|||
textarea textarea.Model
|
||||
spinner spinner.Model
|
||||
interruptKeyInDebounce bool
|
||||
exitKeyInDebounce bool
|
||||
}
|
||||
|
||||
func (m *editorComponent) Init() tea.Cmd {
|
||||
|
@ -224,7 +226,10 @@ func (m *editorComponent) Content(width int) string {
|
|||
Render(textarea)
|
||||
|
||||
hint := base(m.getSubmitKeyText()) + muted(" send ")
|
||||
if m.app.IsBusy() {
|
||||
if m.exitKeyInDebounce {
|
||||
keyText := m.getExitKeyText()
|
||||
hint = base(keyText+" again") + muted(" to exit")
|
||||
} else if m.app.IsBusy() {
|
||||
keyText := m.getInterruptKeyText()
|
||||
if m.interruptKeyInDebounce {
|
||||
hint = muted(
|
||||
|
@ -365,6 +370,10 @@ func (m *editorComponent) SetInterruptKeyInDebounce(inDebounce bool) {
|
|||
m.interruptKeyInDebounce = inDebounce
|
||||
}
|
||||
|
||||
func (m *editorComponent) SetExitKeyInDebounce(inDebounce bool) {
|
||||
m.exitKeyInDebounce = inDebounce
|
||||
}
|
||||
|
||||
func (m *editorComponent) getInterruptKeyText() string {
|
||||
return m.app.Commands[commands.SessionInterruptCommand].Keys()[0]
|
||||
}
|
||||
|
@ -373,6 +382,10 @@ func (m *editorComponent) getSubmitKeyText() string {
|
|||
return m.app.Commands[commands.InputSubmitCommand].Keys()[0]
|
||||
}
|
||||
|
||||
func (m *editorComponent) getExitKeyText() string {
|
||||
return m.app.Commands[commands.AppExitCommand].Keys()[0]
|
||||
}
|
||||
|
||||
func (m *editorComponent) resetTextareaStyles() textarea.Model {
|
||||
t := theme.CurrentTheme()
|
||||
bgColor := t.BackgroundElement()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue