fix(lazygit): only write palette escapes when a TUI can receive them - #2922
Open
wmaurer wants to merge 1 commit into
Open
fix(lazygit): only write palette escapes when a TUI can receive them#2922wmaurer wants to merge 1 commit into
wmaurer wants to merge 1 commit into
Conversation
With a GUI frontend (Neovide, neovim-qt, any --embed client) stdout is the msgpack-RPC channel, so writing OSC 4 palette escapes to it corrupts the protocol stream instead of reaching a terminal. Use vim.api.nvim_ui_send() on 0.12+ (routed to the TUI host terminal, no-op for GUIs) and fall back to the nvim_list_uis() check Neovim core uses in runtime/lua/vim/_defaults.lua on 0.10/0.11. On 0.9 the stdout_tty field does not exist yet, so the old behavior is kept there. Fixes folke#2921
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2921
Snacks.lazygitwrites OSC 4 palette escapes for numeric theme keys straight to stdout. With a GUI frontend (Neovide, neovim-qt, any--embedclient) stdout is the msgpack-RPC channel, so the bytes corrupt the protocol stream instead of reaching a terminal; Neovide logsERROR [neovide::bridge::session] ]4;241;...on every lazygit open.This PR guards the write the same way Neovim core does:
vim.api.nvim_ui_send(), which is routed to the TUI host terminal and is a no-op for GUIs; core's OSC 52 clipboard moved to it.nvim_list_uis()check fromruntime/lua/vim/_defaults.lua(ui.chan == 1 and ui.stdout_tty). Under Neovide the attached UI reportschan == 1, stdout_tty == false, sostdout_ttyis the discriminating field.stdout_ttyfield does not exist yet, so the old behavior is kept there.Same fix as AstroNvim/astroui#66, where this code was adapted to.
Tested on Neovim 0.12.4 with the repro from #2921: headless/GUI path no longer leaks the escape; under a real pty the escape still reaches the terminal.
stylua --checkandseleneare clean on the changed file.