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
Text selection highlight is not shown on decorations w/background colors #75642
If a decoration is set and includes a background color, selection highlight is not rendered.
In the following image, text decorations (with a background value) exist on the keywords and symbols, but not the whitespace. The entire section is selected. Notice that the whitespace receives a selection highlight color, but the decorated text does not.
Daniel Imms (@Tyriar) , This was duped incorrectly. The cpptools issue should be duped to this, not vice version. (I work on cpptools). The issue is, generally, that if there is a background color specified on a TextEditorDecoration, no highlight selection color will be applied to it when that text is selected. We can work around the issue in cpptools when the desired background color happens to be the same as the editor background color (so, setting a background color is unnecessary, and avoided). But, the issue remains in the general case. Please apply selection highlight color on TextEditorDecorations when they have a background color specified, and their text is selected.
Colen Garoutte-Carson (@Colengms) ah sorry I thought it was just a limitation of how you did semantic coloring but it I've also seen this issue in the git diff decorations:
This is as designed. Using a color with opacity 100% will result in other things not being visible. The solution is to use a color with an opacity < 100%.
I'm almost certain this should not have been closed. The proposed solution does not work. Setting the (only available) "opacity" property of DecorationRenderOptions to 0.5, for example, has no effect on the visibility of the text selection highlight. As you can see, both the selected and unselected text (w/ red background) in the example below appear the same, despite opacity 0.5 being used.
Using an alpha channel value in the background color itself does not appear to be accepted.
The opacity property would seem to only apply to the foreground color. Setting the editor background to another color, for example, I can see that the decoration's background color is not blended with it at all.
Furthermore, even if this worked, it would not be a good design to require that anyone who sets a background color on a decoration to use (at this point ambiguous) semi-transparency in order to avoid an issue that would cause user text selection not to be apparent when selecting text within the decoration. The text selection color should either be blended/inversed with the background color, or replace the background color, so that selection is apparent.
I am seeing something strange. I am seeing different results running from source or running from a built version at the same commit. I am using the following to reproduce:
Activity
Tyriar commentedon Jun 20, 2019
/duplicate microsoft/vscode-cpptools#3780
Colengms commentedon Jun 20, 2019
Daniel Imms (@Tyriar) , This was duped incorrectly. The cpptools issue should be duped to this, not vice version. (I work on cpptools). The issue is, generally, that if there is a background color specified on a TextEditorDecoration, no highlight selection color will be applied to it when that text is selected. We can work around the issue in cpptools when the desired background color happens to be the same as the editor background color (so, setting a background color is unnecessary, and avoided). But, the issue remains in the general case. Please apply selection highlight color on TextEditorDecorations when they have a background color specified, and their text is selected.
Colengms commentedon Jun 20, 2019
Tyriar commentedon Jun 20, 2019
Colen Garoutte-Carson (@Colengms) ah sorry I thought it was just a limitation of how you did semantic coloring but it I've also seen this issue in the git diff decorations:
alexdima commentedon Aug 5, 2019
This is as designed. Using a color with opacity 100% will result in other things not being visible. The solution is to use a color with an opacity < 100%.
Tyriar commentedon Aug 5, 2019
cc João Moreno (@joaomoreno), see the image in #75642 (comment)
Colengms commentedon Aug 5, 2019
I'm almost certain this should not have been closed. The proposed solution does not work. Setting the (only available) "opacity" property of DecorationRenderOptions to 0.5, for example, has no effect on the visibility of the text selection highlight. As you can see, both the selected and unselected text (w/ red background) in the example below appear the same, despite opacity 0.5 being used.
Using an alpha channel value in the background color itself does not appear to be accepted.
The opacity property would seem to only apply to the foreground color. Setting the editor background to another color, for example, I can see that the decoration's background color is not blended with it at all.
Furthermore, even if this worked, it would not be a good design to require that anyone who sets a background color on a decoration to use (at this point ambiguous) semi-transparency in order to avoid an issue that would cause user text selection not to be apparent when selecting text within the decoration. The text selection color should either be blended/inversed with the background color, or replace the background color, so that selection is apparent.
alexdima commentedon Aug 6, 2019
I am seeing something strange. I am seeing different results running from source or running from a built version at the same commit. I am using the following to reproduce:
package.json:index.js:running from source
running from a built version
alexdima commentedon Aug 6, 2019
Well, after debugging I can no longer reproduce this in the built version...
alexdima commentedon Aug 6, 2019
Ok, now I understand this weirdness, I am running into a code cache bug. I've created #78542 to track that.
In any case, going back to our issue. I can set an opacity and it is respected. See the above sample code:

