Skip to content

feat: Double Ctrl+C to close pgxcli#95

Draft
LeeFred3042U wants to merge 1 commit into
balajz:mainfrom
LeeFred3042U:feat/Double-Ctrl+C-to-close-pgxcli
Draft

feat: Double Ctrl+C to close pgxcli#95
LeeFred3042U wants to merge 1 commit into
balajz:mainfrom
LeeFred3042U:feat/Double-Ctrl+C-to-close-pgxcli

Conversation

@LeeFred3042U

Copy link
Copy Markdown
Contributor

Closes #75

Changes

internal/app/ui/model.go

  • Added ctrlcSeq int field to Model to track the current Ctrl+C seq generated
  • In Update():
    • updated the StatePending guard to also exclude Interrupt key
    • updated seqTimeoutMsg case to also check ctrlcSeq
    • updated Interrupt handler inside tea.KeyMsg block:
      • first Ctrl+C in StateInput sets StatePending and fires a tea.Tick
      • second Ctrl+C within 500ms dispatches QuitRequestMsg and returns to StateInput
      • Ctrl+C during StateExecuting remains instant cancel, no double press required

Notes

@balajz

balajz commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Hi, since both share the same state, pressing Esc and Ctrl+C will close the pgxcli.

How about using a global sequence counter and splitting the states?

escSeq   int
ctrlcSeq int

to

pendingSeq int
const (
    StateInput State = iota
    StateExecuting
    StatePendingClear
    StatePendingQuit
)

@LeeFred3042U

Copy link
Copy Markdown
Contributor Author

@balajz ok

@balajz balajz marked this pull request as draft June 13, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Double Ctrl+C to close pgxcli

2 participants