Vscode: [theming] editor.selectionForeground is not working

Created on 18 Oct 2017  ·  19Comments  ·  Source: microsoft/vscode

  • VSCode Version: Code 1.17.2 (b813d12980308015bcd2b3a2f6efa5c810c33ba5, 2017-10-16T13:57:00.652Z)
  • OS Version: Linux x64 4.8.0-59-generic

Steps to Reproduce:

  1. Add customization for workbench.colorCustomizations.editor.selectionForeground
  2. Save settings

Expected result: a text selection should use the configured foreground color
Actual result: it doesn't.

I notice that the tooltip in the settings editor says "Color of the selected text for high contrast". I'm not sure what that means, my only thought was that it might apply to the "High Contrast" theme I see mentioned in the docs. I tried to switch to that theme, but it doesn't make any difference whatsoever (seriously, none at all - it's weird because I thought I did that before and things looked different then - is high contrast broken now?).

In any case, I'd like to see selection foreground color implemented regardless of theme. For presentation purposes, I want a bright selection background color (my preference is bright yellow), and this is generally incompatible with any kind of syntax-highlight colored text.

image

debt editor-theming feature-request themes

Most helpful comment

Bump. Syntax highlighters use many colours, is very hard to set a selection background color that allow an acceptable contrast with the selected text. I can suggest to remove all the token colors for selected text in order to inherit the color from another token, like the editor.foreground or something else.

All 19 comments

It was only supported for high contrast themes.
I changed it to work for any theme.

Note that when you set the editor foreground color there won't be any token colors inside the selected range.
@alexandrudima FYI, speak up if you see a problem.

I've had to revert the commit because it causes #36760

@aeschli Please create PR for changes in this area in the future.

@aeschli any plans to revisit this? it makes stuff very hard to read at times.

Is there an issue for the underlying problem in the renderer that causes times to go up when foreground color is set? It's certainly a bug/flaw in the renderer that the respective developers should look at. There is no logical reason why changing the foreground color should cause repaint time to go up when changing the background color does not. The area that needs to be repainted is exactly the same. In fact because the foreground color makes the syntax coloring go away it should in theory be possible to make rendering faster for selected text with both foreground and background color.

Besides, shouldn't the user decide if the drop in performance bothers him? After all, no one is saying that any of the default themes shipped with VS Code should use the option. This issue would only arise for a user who decides to install an extra theme.

Maybe the respective developers could also look into whether it would be possible to implement a color inversion option for selected text with better performance. I'm thinking of 3 possible ways:

  • swap background and foreground color, e.g. red text on black background => black text on red background
  • invert the color at the byte level in the framebuffer (i.e. X => 255-X)
  • swap colors around in the frame buffer (e.g. R => G => B => R)

It's not really important that the foreground color in particular be implemented. We just need some way to make it more readable. At least one of the above options should be implementable without performance drop.

I would very much expect the behavior described in the reverted fix:

Note that when you set the editor foreground color there won't be any token colors inside the selected range.

It is unfortunate this feature seems to not be compatible with "low" contrast themes.

bump pls

This issue turned a year old a few days ago. Here's a bump - still no good presentation solution with VS Code!

Bump for revisit to this issue.

Bump again for revisit.

Having this issue in 1.36.0.

Bump. Syntax highlighters use many colours, is very hard to set a selection background color that allow an acceptable contrast with the selected text. I can suggest to remove all the token colors for selected text in order to inherit the color from another token, like the editor.foreground or something else.

@aeschli This issue will be two years old soon and I'm reminded every time I present using VS Code. Can we ever expect something to be done about this? It really doesn't look like a satisfactory solution would be too complicated...

Having this issue in
Version: 1.39.2 (user setup)
Commit: 6ab598523be7a800d7f3eb4d92d7ab9a66069390
Date: 2019-10-15T15:35:18.241Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 6.1.7601

How you use this cuz I can't get it? o_O

editor.selectionForeground

I've tried this in settings.json, but with no success❗

"workbench.colorCustomizations": { editor.selectionForeground }

I think a good way of pointing out the current selection is to use a border. That would bypass all the issues about conflicts with syntax coloring. Strangely, you can set a border on the selectionhighlight (texts that are identical to the selection), but not the selection itself, arguably the most important surface of real estate in the whole application - where things will actually happen when you type on the keyboard.
This does not work in the current version, however (18 feb 2020). I opened an issue to that effect: https://github.com/microsoft/vscode/issues/90807

Bump for revisit.

Still doesn't work
ver 1.47

Was this page helpful?
0 / 5 - 0 ratings