fix(tui): disable DECRQM and DECRQSS queries for Terminal.app (#28453)

**Problems**

When launching Neovim on Terminal.app on macOS (Apple Terminal),
it briefly shows like
`p$qm+q5463;524742;73657472676266;73657472676262$qm` in orange
background color partially on the screen.

**Solution**

Since Terminal.app seems not supporting DECRQM and DECRQSS queries,
calling `tui_request_term_mode` and `tui_query_extended_underline`
caused this unexpected output.

Therefore, if we know it's Apple Terminal (when `nsterm` is `true`),
don't call these checks.

Tested on Terminal.app (2.14, 453) on macOS 14.4.1.

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Gregory Anders <greg@gpanders.com>
This commit is contained in:
Yoshimasa Niwa 2024-04-22 17:17:43 -07:00 committed by GitHub
parent 39fc340276
commit cb2b5e2780
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -410,11 +410,15 @@ static void terminfo_start(TUIData *tui)
// Query support for mode 2026 (Synchronized Output). Some terminals also
// support an older DCS sequence for synchronized output, but we will only use
// mode 2026
tui_request_term_mode(tui, kTermModeSynchronizedOutput);
// mode 2026.
// Some terminals (such as Terminal.app) do not support DECRQM, so skip the query.
if (!nsterm) {
tui_request_term_mode(tui, kTermModeSynchronizedOutput);
}
// Don't use DECRQSS in screen or tmux, as they behave strangely when receiving it.
if (tui->unibi_ext.set_underline_style == -1 && !(screen || tmux)) {
// Terminal.app also doesn't support DECRQSS.
if (tui->unibi_ext.set_underline_style == -1 && !(screen || tmux || nsterm)) {
// Query the terminal to see if it supports extended underline.
tui_query_extended_underline(tui);
}