Repository navigation
Description
I've been using WSL for a while and it's been great, but using nvim with this issue still pending is at times unusable. Other terminals are not having this issue (see ConEmu or Hyper for example). I hope this issue gets re-opened.
Originally posted by Dimitar Dimitrov (@n1ghtmare) in #1203 (comment)
I'm with Dimitar Dimitrov (@n1ghtmare) on this one. Most syntax highlighting colors in Vim have a wide array of colors that very much clash with the cursor color when the cursor color isn't able to be swapped to a contrasted color dynamically. This has been demonstrated in the few screenshots I uploaded before. It affects everyone using terminal Vim or another terminal based text editor.
I know pianocomposer321 said to pick a better color for the cursor but this doesn't make a difference in the end. If he adjusted his screenshot to be over a comment instead of the keyword then the comment's character under the cursor would be invisible. Also in his current screenshot the contrast is very low, it would certainly not be good enough for a video recording or giving a talk.
As good as the MS terminal is, I still tend to use wsltty (which dynamically sets its cursor color based on contrast calculations) in my day to day because having a block cursor in terminal Vim is much better than the vintage cursor in the MS terminal. Not just from a legibility POV, but it allows you to configure Vim so that your cursor shape changes from the block cursor to a line cursor depending on if you're in normal or insert mode.
Originally posted by Nick Janetakis (@nickjj) in #1203 (comment)
Subscribers, thumbs-uppers from that comment: krage, Jay Freeman (saurik) (@saurik), krage
Activity
skyline75489 commentedon Mar 25, 2021
Is this blocked by #6193 or other issues? Or we can just implement the algorithm for calculating the contrasted color and call it a day
zadjii-msft commentedon Mar 25, 2021
I KNEW THERE WAS AN EXISTING ISSUE!
Part of the trick here is that when the
Rendereris drawing runs of text, it doesn't know where the cursor is. So it needs to be able to split the run with the cursor in it, so it can draw {text left of the cursor, text where the cursor is, text to the right of the cursor }.Presumably, if there's a way of doing it without doing all the work in #6193, that'd be cool. I had all these ideas before in #6151 for different ways of specifying how the text at the cursor should look. Something like
"cursorTextColor": null|"textForeground"|"#rrggbb".DHowett commentedon Mar 26, 2021
The thing I was toying with--which initially made me think that this would be easy--was drawing a D2D "fill effect" (that is: a command buffer that produces a flood fill) through the image/effect drawing pipeline with the XOR composition mode. It was promising, but it only worked where we weren't already drawing a background. Everything goes pear-shaped when you are drawing a background color. 😄
DHowett commentedon Mar 26, 2021
However, it looks like we can use the 2-pass cursor renderer Mike Griese (@zadjii-msft) wrote to backplate the color for a destination-inversion cursor.
DHowett commentedon Mar 26, 2021
nickjj commentedon Mar 27, 2021
Looks like a really good start, nice work. Could this be something that gets backported into the current stable release as a hotfix once you're happy with its performance and stability? It feels like such a huge feature that it transforms the entire experience for anyone who might be using Vim.
57 remaining items
lhecker commentedon May 4, 2023
The "automated" mode is ~4 lines of code and took me <5min to write and test, whereas the other issues/feature-requests require a lot more work. Given that I'm technically already 110% booked out with work for months on end, I think you can see why I've picked the easy option for now. 🥲
You could try god's intended cursors right now, if you're curious. 😏
Here is a preview build based on that PR. I put it on my own host for convenience (and because the file will automatically expire in a week that way), but it's properly built and digitally signed by Microsoft. Please let me know if you find any issues with the way the cursors work now!
3N4N commentedon May 5, 2023
Awesome! Been using for a few hours. Works great! Thanks a bunch.
avih commentedon May 6, 2023
IMHO, if you insist on choosing the FG color yourself and not letting the user specify it, then just pick either black or white - whichever has the better contrast to the chosen cursor BG color.
IMO it would pretty much gurante to look better than any attempt to preserve the underlaying FG color but still modifying it so that it has some contrast to the BG.
Just see how many failed atempts there were at that, to realise that it's not as simple as you think to do what the user prefer automatically.
nickjj commentedon May 6, 2023
I think if we stick with setting it manually then we're not going to address the root issue where characters are invisible based on syntax highlighting in terminal based editors such as Vim. You're going to have a wide range of dark and light text based on any variant of color themes.
vim: enable guicursor on ms-terminal
Use Oklab for text and cursor contrast adjustments (#15283)
habamax commentedon May 8, 2023
I have used vim for a long time in different terminals that allow setting
bgandfgfor a cursor -- never had an issue with syntax highlighting and cursor. If your terminal background is black, set cursor colors to white and black, do the opposite if terminal background is light/white. It always worked, it would have worked in windows terminal too.But anyway, if that new implementation would let us distinguish what is under cursor, I am all for it.
nickjj commentedon May 9, 2023
Maxim Kim (@habamax) This issue has multiple screenshots showing how it would be an issue with a statically configured cursor color.
Here's a screenshot you posted a while back:

Your screenshot is also a near-best case scenario because you have pretty bright colors and there's only a few colors shown at once.
habamax commentedon May 9, 2023
Nick Janetakis (@nickjj) it is about other terminals that allow setup of cursor background AND FOREGROUND colors. Like gnome-terminal, for example:

Use Oklab for text and cursor contrast adjustments (#15283)
gaoqiangks commentedon Jun 24, 2023
So, what's the solution? Many issues are closed but I still cann't find a solution.
lhecker commentedon Jun 24, 2023
Did you try Windows Terminal Preview 1.18 yet? If that doesn’t work for you it’d be great if you could open a new issue with a screenshot showing the problem and I‘ll try to fix it ASAP. 🙂
If you’re asking about setting individual foreground and background colors for the cursor, I don’t think we have an issue tracking specifically that yet, but I‘ve already made it my goal to implement that for 1.19 anyways.
gaoqiangks commentedon Jun 25, 2023
WT Preview 1.18 is much better. Thank you!
weibeld commentedon Jul 26, 2023
This is now being discusses in #15766.