You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Spurious OSC 11 command ends up writing to terminal or even executing as commands when opening vim #18714
I have an issue with 11;rgb:1e1e/1e1e/1e1e;1R sometimes appearing. It's infrequent (once or twice a day). It can happen either when I ctrl-C to cancel a running script, or when launching neovim. The former is no big deal, it just appears as text at my prompt that I can delete. But if it happens when launching vim the effect is to overwrite one character with the letter g (and leave :1e1e/1e1e/1e1e in my command history). This can be incredibly frustrating/damaging if I don't notice at the time.
I think this is an issue with Windows Terminal. I've moved over from PuTTy and never experienced it there.
If it's not a bug per-se, any pointers anyone can give me to fix this would be hugely appreciated!
Steps to reproduce
Open a file in neovim
Expected Behavior
The file opens, unedited
Actual Behavior
The file opens, and a single character will be replaced by a g. Only very occasionally, maybe one in 100 attempts.
You can try setting that back to a more sensible value and see if it makes any difference, i.e. add something like set -sg escape-time 500 in your .tmux.conf file.
The proximal root cause is that vim is requesting a terminal cursor color report. It's weird to me that they're dropping it on the floor when it finally comes back to them...
So it's not just vim. I have a startup script in my .bashrc that outputs a couple of log files, uptime information and duf. If I hit ctrl-C while the log files are churning out to the screen, it reliably aborts when duf runs (but before duf outputs anything).
my command prompt ends up with 11;rgb:1e1e/1e1e/1e1e;1R
I ran it a few times and got different post-PS1 debug tap outputs:
In /this/ instance, I think that "somebody" is duf. If I comment duf out of my startup script, ctrl-C just dumps me to an empty prompt, every time. If I have duf in the script, ctrl-C dumps me (at the point duf is called) to the prompt with the OSC weirdness.
So, if this was my only issue, I could just remove duf from my startup script.
But the infinitely more pressing issue, is these characters being input to neovim once every couple of days or so. You can imagine how frustrating it is when a single letter of code somewhere in your file gets overwritten with a g, and you don't notice!
Presumably the problem anyway isn't WHO'S requesting the fg color report, but how WT handles that. I've tried going back to PuTTy for a few days, and the issue does not seem to happen in PuTTy, so either they're handling the report better, or maybe they just ignore it and never respond. I'm ok with either 😁
If I have duf in the script, ctrl-C dumps me (at the point duf is called) to the prompt with the OSC weirdness.
This is between you and duf. They (more specifically the termenv library that they use) are sending an OSC 11 query to determine the terminal background color, so they can select an appropriate theme to match that. You're assumedly then aborting the app with Ctrl+C before it has had a chance to read the response. It's possible there may be a way for them to shutdown more gracefully when you do that, but that's something best discussed with them.
the infinitely more pressing issue, is these characters being input to neovim
I think neovim does have an escape timeout similar to tmux, so that might be a factor, but I can't see how any of these query responses would then end up overwriting your buffer even if the escape did timeout. It might be something specific to your configuration, but I don't know enough about neovim to know if that's a reasonable hypothesis. You could try starting it with --clean for a while to see if that helps.
Otherwise, if you manage to capture a log from the debug tap when the problem actually occurs, that might help determine where it's going wrong.
the issue does not seem to happen in PuTTy
PuTTY doesn't support the XTerm palette sequences (it uses a completely different system), so that's likely why it doesn't have the same problem. Strangely it does actually support OSC 4 queries, but you can't set the palette with OSC 4, and the OSC 10+ sequences have no effect at all.
I don't believe anything in my config is causing it per se, but I don't doubt that it's probably a race condition kicked off by, well, something in my config. The fact that it happens so infrequently doesn't help. I suspect its maybe more prone to occurrence when my internet connection is being spotty, so I'm going to have a play with clumsy in a few days when I get a chance to try to make it more repeatable.
downhiller I forgot to mention, if it's timing related, you should be able to reproduce the issue more easily using something like trickly/tritty, which will allow you to simulate a very slow connection. For example, you can start a shell at 57600 baud with tritty -b 57600,
(Please ignore the trailing sequences showing the window is focused in or out)
Could reproduce with 1.22.11141.0, every time I attach to an existing tmux session.
Zentino (@zent1n0) If you're using tmux, that's issue #18004, and you can usually fix the problem by adjusting the tmux escape-time option to something like 500.
Activity
DHowett commentedon Mar 26, 2025
Thanks for reporting!
It looks like this might be a /duplicate of #18004, and may be remediated by changing the escape dwell time.
downhiller commentedon Mar 26, 2025
But......... I'm not using tmux.
DHowett commentedon Mar 26, 2025
ARGH, sorry about that!
DHowett commentedon Mar 26, 2025
The proximal root cause is that vim is requesting a terminal cursor color report. It's weird to me that they're dropping it on the floor when it finally comes back to them...
Can you grab a log via the debug tap?
downhiller commentedon Mar 27, 2025
Trying now. As I mentioned it only happens occasionally, and easy to miss even when it does. 🤞
downhiller commentedon Mar 27, 2025
So it's not just vim. I have a startup script in my .bashrc that outputs a couple of log files, uptime information and
duf. If I hit ctrl-C while the log files are churning out to the screen, it reliably aborts when duf runs (but before duf outputs anything).my command prompt ends up with
11;rgb:1e1e/1e1e/1e1e;1RI ran it a few times and got different post-PS1 debug tap outputs:
␛]11;rgb:1e1e/1e1e/1e1e␛\␛[46;1R␛[67;46;3;0;8;1_␇11;rgb:1e1e/1e1e/1e1e␇;1R␛[17;29;0;0;0;1_␇11;rgb:1e1e/1e1e/1e1e␇;1R␛[67;46;3;0;8;1_␛[17;29;0;0;0;1_␛]11;rgb:1e1e/1e1e/1e1e␛\␛[46;1R␛[17;29;0;0;0;1_␇11;rgb:1e1e/1e1e/1e1e␇;1RNot sure if that's of any help to you 🤷♂️
DHowett commentedon Mar 27, 2025
I'd love to see a full debug tap log if possible. Somebody is requesting the color report and ignoring it, after all... :)
The hallmark to look for is
␛]11;?in white (whereas red is responses and input 🙂)downhiller commentedon Mar 27, 2025
Is this enough? That's all white, other than the
␛]11;rgb:1e1e/1e1e/1e1e␛\␛[46;1Rtowards the end which is red.As you can see I have a tarty PS1, but it's all properly escaped and I don't believe it should cause issues.
downhiller commentedon Mar 27, 2025
This is my PS1, if you think I'm wrong and it's relevant:
downhiller commentedon Mar 27, 2025
screenshot of PS1 as it's a bit more readable that way.
DHowett commentedon Mar 27, 2025
Weird! There's definitely somebody requesting a foreground color report right before your prompt but after the application output...
downhiller commentedon Mar 28, 2025
In /this/ instance, I think that "somebody" is duf. If I comment duf out of my startup script, ctrl-C just dumps me to an empty prompt, every time. If I have duf in the script, ctrl-C dumps me (at the point duf is called) to the prompt with the OSC weirdness.
So, if this was my only issue, I could just remove duf from my startup script.
But the infinitely more pressing issue, is these characters being input to neovim once every couple of days or so. You can imagine how frustrating it is when a single letter of code somewhere in your file gets overwritten with a g, and you don't notice!
Presumably the problem anyway isn't WHO'S requesting the fg color report, but how WT handles that. I've tried going back to PuTTy for a few days, and the issue does not seem to happen in PuTTy, so either they're handling the report better, or maybe they just ignore it and never respond. I'm ok with either 😁
j4james commentedon Mar 30, 2025
This is between you and duf. They (more specifically the termenv library that they use) are sending an
OSC 11query to determine the terminal background color, so they can select an appropriate theme to match that. You're assumedly then aborting the app with Ctrl+C before it has had a chance to read the response. It's possible there may be a way for them to shutdown more gracefully when you do that, but that's something best discussed with them.I think neovim does have an escape timeout similar to tmux, so that might be a factor, but I can't see how any of these query responses would then end up overwriting your buffer even if the escape did timeout. It might be something specific to your configuration, but I don't know enough about neovim to know if that's a reasonable hypothesis. You could try starting it with
--cleanfor a while to see if that helps.Otherwise, if you manage to capture a log from the debug tap when the problem actually occurs, that might help determine where it's going wrong.
PuTTY doesn't support the XTerm palette sequences (it uses a completely different system), so that's likely why it doesn't have the same problem. Strangely it does actually support
OSC 4queries, but you can't set the palette withOSC 4, and theOSC 10+ sequences have no effect at all.downhiller commentedon Mar 31, 2025
I don't believe anything in my config is causing it per se, but I don't doubt that it's probably a race condition kicked off by, well, something in my config. The fact that it happens so infrequently doesn't help. I suspect its maybe more prone to occurrence when my internet connection is being spotty, so I'm going to have a play with clumsy in a few days when I get a chance to try to make it more repeatable.
j4james commentedon Apr 2, 2025
downhiller I forgot to mention, if it's timing related, you should be able to reproduce the issue more easily using something like trickly/tritty, which will allow you to simulate a very slow connection. For example, you can start a shell at 57600 baud with
tritty -b 57600,zent1n0 commentedon Jul 13, 2025
Could reproduce with 1.22.11141.0, every time I attach to an existing tmux session.
j4james commentedon Jul 13, 2025
Zentino (@zent1n0) If you're using tmux, that's issue #18004, and you can usually fix the problem by adjusting the tmux
escape-timeoption to something like 500.ChanthMiao commentedon Aug 16, 2025
downhiller Did you try it with wsl? I mean, run ssh.exe in a wsl instance.
If I run run or attench tmux by ssh.exe with wsl, it just works well.
Fix Windows Terminal and OSC issue