[PR #16990] Query SGR 4:X support from Terminal before consuming it in the adapter #31082

Open
opened 2026-01-31 09:44:57 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/16990

State: closed
Merged: No


Currently, we unconditionally allow SGR 4:X in our adapter. This works for terminals that support SGR 4:X, but others have to face missing underlines if the application thinks the terminal does support extended underline style.

On Windows, an application might send out a DECRQSS query to check for extended style support before enabling it, but this won't work because it is the Conpty that would respond and not the actual terminal. To fix this issue, Conpty will send a DERQSS SGR query to the terminal during the startup. The query first sets the undercurl (4:3) and queries the SGR attributes. When a DECRPSS response is received in the input state machine engine, we'll check for the presence of the undercurl attribute in the response. If undercurl is present, we'll tell the adapter to start consuming SGR 4:X sequences.

Conpty will ignore SGR 4:X sequences if the terminal doesn't support extended styles. This way, if the terminal never responded or the response didn't include the (4:3), and an application sent us (Conpty) a DECRQSS query \x1b[0m;\x1b[4:3m\x1bP$qm to detect support for extended style, our DECRPSS response will also not contain SGR 4:X either.

References and Relevant Issues

https://github.com/neovim/neovim/issues/26744
https://github.com/neovim/neovim/pull/28052

Validation Steps Performed

  • TBA

PR Checklist

  • Tests added/passed
**Original Pull Request:** https://github.com/microsoft/terminal/pull/16990 **State:** closed **Merged:** No --- Currently, we unconditionally allow `SGR 4:X` in our adapter. This works for terminals that support SGR 4:X, but others have to face missing underlines if the application *thinks* the terminal does support extended underline style. On Windows, an application might send out a DECRQSS query to check for extended style support before enabling it, but this won't work because it is the Conpty that would respond and not the actual terminal. To fix this issue, Conpty will send a DERQSS SGR query to the terminal during the startup. The query first sets the undercurl (4:3) and queries the SGR attributes. When a DECRPSS response is received in the input state machine engine, we'll check for the presence of the undercurl attribute in the response. If undercurl is present, we'll tell the adapter to start consuming SGR 4:X sequences. Conpty will ignore `SGR 4:X` sequences if the terminal doesn't support extended styles. This way, if the terminal never responded or the response didn't include the (`4:3`), and an application sent us (Conpty) a DECRQSS query `\x1b[0m;\x1b[4:3m\x1bP$qm` to detect support for extended style, our DECRPSS response will also not contain `SGR 4:X` either. ## References and Relevant Issues https://github.com/neovim/neovim/issues/26744 https://github.com/neovim/neovim/pull/28052 ## Validation Steps Performed - TBA ## PR Checklist - [ ] Tests added/passed
claunia added the pull-request label 2026-01-31 09:44:57 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#31082