Skip to content

late background color replies escape during startup commands - #21985

Open
akasakariko wants to merge 1 commit into
vim:masterfrom
akasakariko:fix/late-startup-background-response
Open

akasakariko wants to merge 1 commit into
vim:masterfrom
akasakariko:fix/late-startup-background-response

Conversation

@akasakariko

Copy link
Copy Markdown
Contributor

With a positive termbackgroundwait, OSC 11 is sent before command-line startup commands. A terminal reply delayed by 400 ms with tbw=50 is echoed into the caller's shell after vim -c q, or while the shell command in vim -c '!sleep 1' is running. This reproduces the regression reported by h-east after patch 9.2.1375.

Defer the background query when +, -c, or -S startup commands are present. If Vim continues, the existing query after these commands still detects the background. Ordinary interactive startup retains the early query and wait. Document that command-line startup commands do not receive the wait before the first screen clear.

Add a PTY regression covering -c q, a shell command followed by -c q, +q, -S, and an indirect execute 'q'. All five cases produce an early query and a late response echo on the unmodified binary, and pass with this change. Adapt the existing background tests to keep checking normal startup waiting, typed and redirected input, interrupted handoff, CR-LF output, and color restoration without command-line startup commands.

Validation on macOS arm64, based on b8e10a2 (Vim 9.2.1382): the Huge console build succeeds without warnings; startup, terminal-code, options, help, and code-style suites pass with TEST_NO_RETRY=1, totaling 256 passing tests and 12 platform or feature skips. The two original reproduction commands change from echoed to not echoed. An additional PTY check confirms that a session continuing after a startup command sends the query after the command and uses the returned background.

The initial terminal-code run under TERM=dumb has three failures that reproduce unchanged on the baseline. The suite passes with TERM=xterm-256color. The complete Huge test suite, Tiny builds, GUI, Windows, and sanitizers were not run locally.

Related to #21664.

Problem:  Late terminal background replies can escape to the shell when
          'termbackgroundwait' is positive and startup commands quit or
          invoke a shell command (h-east).
Solution: Defer the background request until command-line startup commands
          have finished, preserve the early wait without these commands,
          and add PTY regression tests (Asuka).

related: vim#21664

Assisted-by: OpenAI Codex
Signed-off-by: Asuka <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant