Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions internal/app/ui/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type Model struct {
version string
highlighter func(string) string
escSeq int
ctrlcSeq int

keys KeyMap
styles Styles
Expand Down Expand Up @@ -176,13 +177,13 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.handleInput()

case seqTimeoutMsg:
if msg.seq == m.escSeq {
if msg.seq == m.escSeq || msg.seq == m.ctrlcSeq {
m.state = StateInput
}
return m, nil

case tea.KeyMsg:
if m.state == StatePending && !key.Matches(msg, m.keys.Clear) {
if m.state == StatePending && !key.Matches(msg, m.keys.Clear) && !key.Matches(msg, m.keys.Interrupt) {
m.state = StateInput
}

Expand All @@ -202,9 +203,18 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return nil
}
}

m.input.Reset()
return m, nil
if m.state == StatePending {
m.state = StateInput
return m, func() tea.Msg {
return QuitRequestMsg{}
}
}
m.state = StatePending
m.ctrlcSeq++
n := m.ctrlcSeq
return m, tea.Tick(500*time.Millisecond, func(t time.Time) tea.Msg {
return seqTimeoutMsg{seq: n}
})
}
if key.Matches(msg, m.keys.Clear) {
if m.state == StateExecuting {
Expand Down
Loading