microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.99k stars 29.19k forks source link

Notebook cell editor -- selection highlighting doesn't work #200406

Open zpincus opened 11 months ago

zpincus commented 11 months ago

Applies To

What happened?

When "editor.selectionHighlight" is set, in non-notebook windows, selecting a block of text will highlight matching blocks elsewhere in the document.

I seem to recall this used to be true in jupyter notebook cells as well, but it is no longer the case (for me at least). Here's an SO post from a couple years back demonstrating that selection highlighting was indeed once working in notebook cells: https://stackoverflow.com/questions/68527700/ipynb-highlight-other-occurrences-of-selected-variable-in-vscode-ipython-notebo).

This is independent of whether the kernel is local or remote, or any other settings that I have tried. I observe it on two different machines (one a Mac connected via the remote extension to a linux box; another a Mac editing locally -- and there is no settings sync between them or anything so these are ~independent configs...)

Unsure of whether this is a core vscode issue, or a vscode-jupyter one.

VS Code Version

Version: 1.84.2 (Universal) Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e Date: 2023-11-09T10:52:33.687Z Electron: 25.9.2 ElectronBuildId: 24603566 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Darwin arm64 23.1.0

Jupyter Extension Version

v2023.10.1100000000

Jupyter logs

No response

Coding Language and Runtime Version

No response

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

None

Yoyokrazy commented 11 months ago

Could you investigate this within the new stable release (1.85)? There have been a number of improvements to the multi document highlighting api, including a number of bugfixes, a change of the editor.occurrenceHighlight setting to an enum, and out of the box semantic highlighting for typescript.

zpincus commented 11 months ago

Unfortunately this is not fixed in the new release, I'm afraid.

Repro is easy ofc: run the command "Create: New Jupyter Notebook" (I haven't tested with other notebook languages/extensions), type in e.g. "foo bar foo" and select one of the "foo"s. Observe that the other is not highlighted.

Yoyokrazy commented 11 months ago

Hm, could you go ahead and create a fully empty profile on the latest release, and attempt it there? I followed that repro, and was able to get proper highlighting without any snags. See attached:

image
zpincus commented 11 months ago

I believe what you are seeing in the screenshot above is the "occurrence highlight" rather than the "selection highlight". If you turn the occurrences highlight setting to "off" there is no selection highlighting in the notebook when you select e.g. "foo", but there is still in a regular editor window.

See the two screenshots below. The first is with occurrence highlighting off; you can see in the text editor window that the first "foo" was manually highlighted and the second "foo" has a selection highlight. On the other hand, in the notebook editor, the first "foo" is also manually highlighted and the second does not get a highlight. This is with a new empty profile; I just switched the theme to light because it's quite hard to see the selection highlights in an inactive window otherwise...

The second screenshot shows the occurrence highlighting working fine when it is turned on.

FWIW I dislike the occurrence highlighting because it is visually intrusive to me for the highlights to change when I move the cursor around. I like the selection highlighting because it only happens when I actually select a block of text, not just when the cursor is in any given word. So it would certainly be nice if both options continued to work in the text editor and notebook editors... thanks!!

image image
Yoyokrazy commented 11 months ago

Ah yep, sorry bout the confusion there, you're spot on. Just did a little digging and it looks like this hasn't worked in a couple releases. This will make it onto the backlog of things for me to address within the cell editors, but can't promise any certain timing.

Looking at that SO post you sent earlier, I do tend to think that all screenshots in that post (OP's and the reply) are showing stationary cursors on a single character of the variable and would therefore be utilizing occurrence highlighting. The first image just appears to be using a block style cursor rather than the default line style we are used to these days. Nonetheless, I agree that the feature should work across editor types, and will look into this.

zpincus commented 11 months ago

Thanks! Appreciate your attention on this one! :)

Wmuntean commented 7 months ago

Any updates on this? Would be nice to have similar highlighting behavior between notebooks and editors.

vs-code-engineering[bot] commented 1 month ago

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!