Skip to content

vte: guard case 'm' (SGR) against CSI_GT prefix#29

Merged
kdj0c merged 1 commit intokmscon:mainfrom
kdj0c:fix_gt_sgr_misinterpret
Mar 12, 2026
Merged

vte: guard case 'm' (SGR) against CSI_GT prefix#29
kdj0c merged 1 commit intokmscon:mainfrom
kdj0c:fix_gt_sgr_misinterpret

Conversation

@kdj0c
Copy link
Copy Markdown
Contributor

@kdj0c kdj0c commented Mar 12, 2026

Problem

Fish 4.x (and other terminals implementing modifyOtherKeys/XTMODKEYS) send \033[>4;1m at every prompt to enable the keyboard protocol. The > prefix sets the CSI_GT flag, indicating this is a private/DEC sequence — not an SGR attribute.

do_csi() dispatches case 'm': directly to csi_attribute() without checking CSI_GT, so \033[>4;1m is misinterpreted as SGR 4;1 (underline + bold). The result: blank terminal cells render as _.

This is reproducible with fish 4.x inside any kmscon/libtsm terminal.

Fix

Add the same CSI_GT guard that case 'p': already has, one case below:

case 'm':
    if (!(vte->csi_flags & CSI_GT))
        csi_attribute(vte);
    break;

References

  • Fish 4.x sends \033[>4;1m (XTMODKEYS enable) at every readline re-entry, not just startup
  • case 'p': in the same switch already correctly guards against CSI_GT
  • XTerm docs: CSI > Ps m — Set/reset key modifier options

Fish 4.x (and other terminals using modifyOtherKeys/XTMODKEYS) send
\033[>4;1m at every prompt to enable the keyboard protocol. The '>'
prefix sets the CSI_GT flag, marking this as a private/DEC sequence —
not an SGR attribute sequence.

do_csi() dispatches case 'm': directly to csi_attribute() without
checking CSI_GT, so \033[>4;1m is misinterpreted as SGR 4;1
(underline + bold). This causes blank terminal cells to render as '_'.

The adjacent case 'p': already has the correct CSI_GT guard; apply
the same pattern to case 'm':.
@kdj0c
Copy link
Copy Markdown
Contributor Author

kdj0c commented Mar 12, 2026

Tested with fish, those strange underlines are now gone!

@kdj0c kdj0c merged commit 5c09c11 into kmscon:main Mar 12, 2026
2 checks passed
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.

2 participants