sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
814 stars 40 forks source link

Regions with background remove syntax highlighting #3729

Open deathaxe opened 4 years ago

deathaxe commented 4 years ago

Description

LSP supports symbol highlighting. In VSCode related symbols are highlighted by a lightend background color. They are underlined in ST, because there's no sane scope to use, which defines a slightly dimmed/lightend background color by default. That may easily become super distracting in situations of larger blocks being highlighted.

One example is highlighting media queries by LSP-css.

grafik

But even if there was one, syntax highlighting is removed by adding regions with backgrounds.

Steps to reproduce

  1. Create the following debug.css file

    /* comment */
    @media (min-width: 700px) and (max-width: 2000px) {
       tr {
           color: red;
       }
    }
  2. Add the following rule for markup.symbol to your color scheme (override).

    {
       "scope": "markup.symbol",
       "background": "color(white alpha(10%))"
    },
  3. Open debug.css in ST.

  4. Run view.add_regions(key='symbol', regions=[sublime.Region(21,63)], scope="markup.symbol")

Expected behavior

If background of a region is defined with opacity (e.g.: 10%) syntax highlighting should be maintained as it is for diff regions already. Maybe some checks and limitations with regards to contrast may be taken into account, then.

Actual behavior

Syntax highlighting is removed.

grafik

Environment

wbond commented 4 years ago

I believe this is the intended behavior, due to the contrast issues you outlined.

Since we've added various mechanisms to the codebase in terms of ensuring contrast, it should be able to add the ability to accomplish this now. However, for backwards compatibility, it may require a different flag and extra details.

deathaxe commented 4 years ago

A flag to control that behaviour might even be useful for plugins to decide about the use case.