Skip to content

Send DECRQM sequences based on version response#19938

Open
64-bitman wants to merge 3 commits intovim:masterfrom
64-bitman:fix_decrqm
Open

Send DECRQM sequences based on version response#19938
64-bitman wants to merge 3 commits intovim:masterfrom
64-bitman:fix_decrqm

Conversation

@64-bitman
Copy link
Copy Markdown
Contributor

Should fix #19852

@h-east
Copy link
Copy Markdown
Member

h-east commented Apr 9, 2026

Thank you for your PR. Please confirm two points.
(This review was created by Claude Opus 4.6 with 1M context)

1. tpr_set_by_termresponse should be TRUE

File: src/term.c (init_term_props)

    term_props[TPR_DECRQM].tpr_set_by_termresponse = FALSE;

TPR_DECRQM is set to TPR_YES inside handle_version_response() (i.e., based on the DA2 response), so tpr_set_by_termresponse should be TRUE, not FALSE.

When tpr_set_by_termresponse is FALSE, init_term_props(FALSE) (called during terminal re-initialization) will NOT reset TPR_DECRQM, which means a stale value from a previous terminal could persist.

For reference, TPR_CURSOR_STYLE, TPR_CURSOR_BLINK, TPR_UNDERLINE_RGB, and TPR_MOUSE — all of which are set in handle_version_response() — have tpr_set_by_termresponse = TRUE.

2. GNU screen consideration

File: src/term.c (handle_version_response)

The xterm fallback block (where term_props[TPR_MOUSE].tpr_status is TPR_UNKNOWN) sets TPR_DECRQM = TPR_YES unconditionally. GNU screen (arg[0] == 83) matches an earlier branch and doesn't reach this fallback, so it won't get TPR_YES — which is probably correct since GNU screen likely doesn't support DECRQM. Just want to confirm this is intentional.

Comment thread runtime/doc/builtin.txt Outdated
@h-east
Copy link
Copy Markdown
Member

h-east commented Apr 15, 2026

Here are additional review comments.
(Supported by Claude Opus 4.6 with 1M context)

1. Missing TPR_DECRQM for PuTTY / SecureCRT

File: src/term.c (handle_version_response, version == 136 branch)

The PuTTY branch (arg[0] == 0 && version == 136) and SecureCRT branch (arg[0] == 1 && version == 136) don't set TPR_DECRQM. PuTTY supports DECRQM, so it should probably get TPR_YES. Without it, TPR_DECRQM stays TPR_UNKNOWN and DECRQM sequences won't be sent.

2. Missing TPR_DECRQM for libvterm / Konsole

File: src/term.c (handle_version_response, version == 100 || version == 115 branch)

The libvterm/Konsole branch doesn't set TPR_DECRQM either. Konsole supports DECRQM. For libvterm (used inside Vim's :terminal), it may not be needed, but the two share the same branch — might need to distinguish them or add a comment explaining why it's left as unknown.

3. arg[1] >= 2500 branch covers a wide range of terminals

File: src/term.c (handle_version_response)

if (arg[1] >= 2500)
{
    term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES;
    term_props[TPR_DECRQM].tpr_status = TPR_YES;
}

This matches Gnome terminal (1;3801;0, 1;4402;0, 1;2501;0), xfce4-terminal (1;2802;0), and potentially other terminals. Do all of them handle DECRQM properly? The comment says "Assuming any version number over 2500 is not an xterm", which is quite broad.

4. need_flush and DECRQM sending moved outside #ifdef FEAT_TERMRESPONSE

File: src/term.c (handle_version_response)

The original send_decrqm_modes() was called inside #ifdef FEAT_TERMRESPONSE in vim_main2(). In the new code, the DECRQM sending and need_flush / out_flush() are placed outside the #ifdef FEAT_TERMRESPONSE block. If DECRQM sending depends on the termresponse feature, it should stay inside the #ifdef.

5. Guard termcap_active && cur_tmode == TMODE_RAW removed

File: src/term.c

The original send_decrqm_modes() had:

if (termcap_active && cur_tmode == TMODE_RAW)
{
    // send DECRQM ...
}

The new code in handle_version_response() sends DECRQM without this guard. If it's guaranteed that handle_version_response() is always called in raw mode, a brief comment noting that would be helpful.

@chrisbra
Copy link
Copy Markdown
Member

hm, this causes quite a few test failures. Let me re-trigger CI again.

@64-bitman
Copy link
Copy Markdown
Contributor Author

hm, this causes quite a few test failures. Let me re-trigger CI again.

Should be fixed

@chrisbra
Copy link
Copy Markdown
Member

there still seem to be some screen dump failures :(

@64-bitman
Copy link
Copy Markdown
Contributor Author

64-bitman commented Apr 16, 2026

there still seem to be some screen dump failures :(

I'll try fixing them when I can (soon hopefully), it is exam season for me :/

@chrisbra
Copy link
Copy Markdown
Member

no worries, take your time and good luck for your exams 🤞

@h-east
Copy link
Copy Markdown
Member

h-east commented Apr 17, 2026

@64-bitman I'll take over this matter. Please leave this PR as is.
You should focus on the exam 👍

Move DECRQM request out of handle_version_response() and send it at
startup via may_req_decrqm(), following the existing
may_req_termresponse() and may_req_bg_color() pattern.

Sending DECRQM from handle_version_response() caused DECRPM responses
to arrive during user input processing, leaving bytes in typebuf when
clear_showcmd() ran.  This made visual-mode showcmd (e.g. "7" line count
after V<C-D><C-D>) intermittently disappear, failing many screendump
tests on CI.

- Add decrqm_status (termrequest_T) and register it in
  all_termrequests[].
- Add may_req_decrqm() in the style of may_req_bg_color().  It only
  sends when the status is STATUS_GET and TPR_DECRQM is not TPR_NO.
- Call may_req_decrqm() from vim_main2() right after may_req_bg_color(),
  where the original send_decrqm_modes() used to be called.
- Mark decrqm_status as STATUS_GOT in the DECRPM response handler.

Co-Authored-By: Hirohito Higashi <h.east.727@gmail.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

"pp" shown at the beginning of the buffer when opening a new file

3 participants