Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search highlight mostly hidden when semantic highlighting enabled #2522

Open
Maska opened this issue Sep 27, 2024 · 3 comments
Open

Search highlight mostly hidden when semantic highlighting enabled #2522

Maska opened this issue Sep 27, 2024 · 3 comments
Labels
sublime issue Issues related to shortcomings or bugs in the ST API

Comments

@Maska
Copy link

Maska commented Sep 27, 2024

Describe the bug

When semantic highlighting is used, ST's search highlight is mostly hidden for hits within semantic tokens.

To Reproduce

Steps to reproduce the behavior:

  1. Open Sublime Text in safe mode
  2. Install Package Control
  3. Upgrade Package Control to version 4
  4. Install LSP
  5. Install lsp-clangd (or some other LSP plugin capable of semantic highligting (haven't tested with others))
  6. Configure semantic highlighting for LSP
  7. In a file where LSP is active, search for strings that appear within semantic tokens

LSP.sublime-settings:

{
    "semantic_highlighting": true
}

The color for highlight is set so that hard-to-see highlights stand out better.
Mariana.sublime-color-scheme:

{
    "variables":
    {
    },
    "globals":
    {
        "highlight": "#00FF00"
    },
    "rules":
    [
        {
            "scope": "meta.semantic-token",
            "background": "#00000101"
        }
    ]
}

Example file with many sorts of occurrences of missing highlights when searching for "q":

void reproduce()
{
    // A semantic token gets a very faint highlight when searching.
    auto qqqq = "qqqqqqqq";

    // Error markings are drawn nicely.
    auto qqqqq qqqqqq;

    // Even-numbered rows.
    int qqqqqq;

    int qqqqqqq;

    // Odd-numbered rows. On some font sizes, the tops and bottoms are gone.
    int qqqqqqqq;

    int qqqqqqqqq;

    int i_hide_highlights_under_my_background;
    int qqqqqqqqqq;
    int i_hide_them_too;

    // qqqqqqqqqqqqq Comment highlights don't bother each other.
    // qqqqqqqqqqqqq But semantic tokens do bother comments.
    int qqqqqqqqqqq;
    // qqqqqqqqqqqqq

    // Highlight for selected text works.
    auto qq = 1;
    qq = 2;
    qq = 3;
    qq = 4;
}

Expected behavior

Search hits are highlighted very visibly, with surrounding, unbroken rounded rectangles, as shown in the image below.

safe mode mariana semantic highlighting false works as expected

In this screenshot, LSP's semantic highlighting is disabled.

Screenshots

safe mode mariana buggy

Search highlights are buggy.

safe mode mariana selected highlight works

Highlights for selected text occurrences work fine.

safe mode monokai buggy

The bug doesn't seem to depend on the theme used. Monokai and others suffer from it too.

safe mode mariana scale 100 font size 48

With display scale 100%, the partial highlights disappear completely. Font size 48 is used to bring up details.

Environment

  • OS: Windows 11 version 23H2 (OS Build 22631.3593)
  • Display scale 150%
  • Sublime Text version: 4180
  • LSP version: 2.2.0
  • Language servers used: Clangd 18.1.8, used through LSP-clangd 1.7.0

Additional context

This is likely related to #1934.

@rchl
Copy link
Member

rchl commented Sep 27, 2024

I haven't checked this locally but it looks like the upstream issue: sublimehq/sublime_text#817

It's also referenced in our list of blocking upstream issues: #2007

@Maska
Copy link
Author

Maska commented Sep 27, 2024

Thanks for the near-instant reply and for linking those resources. I'm not familiar with this project, so while searching with highlight-related terms, I didn't manage to find that list of upstream issues. This surely does seem to be one those.

@jwortmann
Copy link
Member

I've tried to fix it via SessionView.initialize_region_keys, but it does not work; apparently the find region key (https://forum.sublimetext.com/t/what-is-the-find-results-highlight-key/69032/4) is automatically initialized by ST as soon as a new view is created. We would need to initialize the semantic highlighting keys before that happens, so I don't think this can be fixed on the LSP side.

@rchl rchl added the sublime issue Issues related to shortcomings or bugs in the ST API label Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sublime issue Issues related to shortcomings or bugs in the ST API
Projects
None yet
Development

No branches or pull requests

3 participants