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

Don't highlight literals #172

Closed
byehack opened this issue Jul 24, 2020 · 11 comments
Closed

Don't highlight literals #172

byehack opened this issue Jul 24, 2020 · 11 comments
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@byehack
Copy link

byehack commented Jul 24, 2020

  • Language Server version: 2020.7.3
  • OS and version: Version: 1.47.2 (user setup)
    Commit: 17299e413d5590b14ab0340ea477cdd86ff13daf
    Date: 2020-07-15T18:22:06.216Z
    Electron: 7.3.2
    Chrome: 78.0.3904.130
    Node.js: 12.8.1
    V8: 7.8.279.23-electron.0
    OS: Windows_NT x64 10.0.18362
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.7

image

@erictraut
Copy link
Contributor

Thanks for submitting a bug report.

What behavior do you consider a bug?

Highlighting a string when you click in it is intended behavior — part of a language feature called "semantic highlighting". When you click on a string literal (or any identifier), the editor will highlight it and any other instances of it within the file. In the case of identifiers, it will also distinguish between writes and reads of that symbol, providing subtly different color hints for each.

@jakebailey
Copy link
Member

jakebailey commented Jul 24, 2020

In MPLS, we disabled any sort of highlighting inside literals (sans fstring sections) as they were a bit distracting, so this is probably a behavior difference from that.

@erictraut
Copy link
Contributor

We could consider doing there here too, but it would be inconsistent with other language servers.

@jakebailey
Copy link
Member

jakebailey commented Jul 24, 2020

I don't think that's entirely true. I tested Go and TypeScript, and neither do this. (Nor do they enable hovers.)

@erictraut
Copy link
Contributor

TypeScript's semantic highlight feature does highlight string literals. It doesn't include the quotes in the selection, but I decided when implementing the Python version that it made sense to include the quotes and the string type that precedes the quote.

@byehack
Copy link
Author

byehack commented Jul 24, 2020

Thanks for submitting a bug report.

What behavior do you consider a bug?

Highlighting a string when you click in it is intended behavior — part of a language feature called "semantic highlighting". When you click on a string literal (or any identifier), the editor will highlight it and any other instances of it within the file. In the case of identifiers, it will also distinguish between writes and reads of that symbol, providing subtly different color hints for each.

when i disabled pylance:

image

@jakebailey
Copy link
Member

Go differs in that literals are not types, so that's probably part of the reason they don't do it. But I was wrong about TypeScript. I had to pick a small string to get TypeScript do to it (my multi-line example did not have this behavior).

But, I still don't think highlighting literals like this is very useful. I'd rather we only did it to actual bound names.

@byehack For reference, that is VS Code's default behavior where it doesn't know anything but the words in the file. If you were to say write:

test = 1234
"this is a test"

And then selected test, it's probably going to highlight it in both places.

The difference here is that we are highlighting the string literal as its own thing.

@byehack
Copy link
Author

byehack commented Jul 24, 2020

image

after disable pylance:

image

@jakebailey jakebailey added the needs decision Do we want this enhancement? label Jul 27, 2020
@jakebailey jakebailey changed the title bug: auto highlight string. Don't highlight literals Jul 27, 2020
@rwols
Copy link

rwols commented Jul 30, 2020

But, I still don't think highlighting literals like this is very useful. I'd rather we only did it to actual bound names.

Agreed. Just to give another example, clangd also doesn't highlight literals.

@jakebailey jakebailey added the enhancement New feature or request label Aug 14, 2020
@rholland
Copy link

I agree that it is distracting. I prefer that it can optionally be turned off.

@jakebailey jakebailey removed the needs decision Do we want this enhancement? label Sep 21, 2020
@jakebailey jakebailey added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Sep 21, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2020.9.6, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202096-23-september-2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

5 participants