Vscode: selection highlight no longer shown in scrollbar ("overview ruler")

Created on 24 Nov 2016  路  22Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.7.2
  • OS Version: replicated on Win 10 x64 and OSX 10.11.6

when editing a *.js file, selecting a string (ex by double clicking it) no longer shows the matched strings in the scrollbar.

oddly, if i select a string and then restart vscode, the highlights do appear

see also issue #2998, which describes the same problem (was fixed but seems to have broken again)

02bc7a7a-d27e-11e5-9cd4-42ae840861f7

*as-designed feature-request

All 22 comments

seems to be affecting javascript source files (*.js) -- have not observed it in other file types

running a regular find also shows the matches correctly

For JavaScript and TypeScript files, document highlights are provided by TypeScript extension. However TypeScript ext is not providing correct word highlight items sometimes. Take a gulp file as example,

// Fast compile for development time
gulp.task('clean-client', util.rimraf('out'));
gulp.task('compile-client', ['clean-client'], compilation.compileTask('out', false));
gulp.task('watch-client', ['clean-client'], compilation.watchTask('out', false));

You can see correct decorations on the scroll bar when selecting gulp while you can't see anything if you select task. For TypeScript files, I can't reproduce this.

Has there been any progress on this? It's really annoying trying to work on angular code now, since I can no longer double click on "foo" in vm.foo and see all occurrences of the variable.

@conceptualspace I am a little bit puzzled. The screen shot you show is a plain text file so no JS.

@rebornix for JS to work correctly typings have to be installed using ATA which depends on a 'correct' package.json. Here is what I see:

capture

@mjbvz can you please investigate.

@MikeyBurkman do you have an small example to reproduce this.

just a note on the editor selection highlights:

  • if a file has an occurences provider, the selection highlights don't show up in the overview ruler (i.e. to not "fight" with the ones coming in from the occurences provider - wordHighlighter).
  • if a file does not have an occurences provider, the selection highlights show up in the overview ruler.

@dbaeumer The highlighting in the editor window works as expected. However, even though things appear highlighted in the editor, they do not show up in the scrollbar to the right.

You actually see the same behavior in TS as well as JS, if the type of the variable is any. This makes sense, as the type of most variables in JS are assumed by the editor to be any.

// Typescript
let myVar: any = {
  foo: 20
};
...
myVar.foo = 58;

If you double-click on myVar, you'll see myVar highlighted in both places in the editor, as well as seeing two occurrences in the scroll bar. However, if you double click on foo, you'll still see it highlighted both times in the editor, but you'll only see one occurrence in the scroll bar, in the exact location that is selected.

In that code snippet, if you remove the any type for myVar, and let type inference do its magic, then double-clicking foo will show two occurrences in the scrollbar, which is what you'd expect. This is true of both JS and TS files.

In a nutshell, the scrollbar highlighting only appears for occurrences that the editor is sure are matches. However, if the type is any, which it almost always is in JS files, then the scrollbar highlighting doesn't show anything, and this is not terribly useful behavior for JS.

@dbaeumer I simply grabbed the screenshot from the previous issue (#2998); be assured you can replicate against a js file

@alexandrudima It sounds like the current behavior is expected because TS has an occurrences provider. Is there an way to fall back to the old selection highlight behavior if we don't find any occurrences using our occurrences provider? Besides the any issues noted, there are lots of places in TS files where our occurrences provide fails, such as for occurrences of type declaration types themselves.

also experiencing this issue

https://github.com/Microsoft/vscode/issues/16042#issuecomment-266981606 explains what we have implemented.

IMHO TS should not fail to provide occurences, and if they do a bug should be logged on their side and fixed.

@alexandrudima -- can you clarify where this stands specifically in relation to javascript files?

in a vanilla install (no extensions), previous version of vscode showed selection highlights in the overview ruler. now they are absent. you're saying they have been offloaded intentionally?

I am also experiencing this issue, any fix?

Also getting this behavior for c++ sources. Searched occurrences appear in scroll bar, but selected one don't. It used to work (I think this appear with 1.16.x for cpp files)

I'm also seeing this issue in .JS files and it's very annoying. If there's already a method for highlighting matches to your selection built into VS Code I don't understand why it shouldn't be used if the occurrences provider fails. More occurrences highlighted are better than none.

If it bothered people it should just be a setting you can turn off.

For c++ file, not using "C_Cpp.intelliSenseEngine": "Default" config fixed my issue.

Resetting the intelliSense database, while leaving "C_Cpp.intelliSenseEngine": "Default", makes it work for a while, but then it stops working again.

I had exactly the same issue with vscode version 1.21.X(newest stable version) for c file. In my situation, I use "C_Cpp.intelliSenseEngine": "Default" settings, with macro definition in c_cpp_properties.json file. Finally I realized that the wrong macro definition lead to this problem. I define a variable in c_cpp_properties.json file like :
"defines": [
"VALUE = 1"
],
There are spaces before and after the '=' symbol, which corrupts intelliSenseEngine. After fixing this macro definition(the definition is rewritten as "VALUE=1", with no spaces), all works normally.The selection highlight can be shown in scrollbar.
Hope this can be a hint to you guys. And sorry for my poor English.

The only workaround I have found is to hit CTRL+F (Command+F on Mac) when the desired string is selected. I really want to have the language's occurrences provider overridden using a setting that highlights every single match as soon as the editor's selected text changes. JavaScript's occurrences provider doesn't pick up everything I need to help me refactor code faster. Microsoft: Please add a configuration setting!

Did anyone find a fix? I'm also having this annoying issue only with js/jsx files.

When editor.occurrencesHighlight is enabled then it works, but that setting is too annoying.

@mignz editor.occurrencesHighlight is enabled by default and the problem with it is that in a JavaScript file, what VS Code considers an occurrence is too narrow. The ruler (scrollbar) needs to show every match based on it simply being an exact match and not because VS Code parsed the JavaScript to guess if it's a match. It misses too much for it to be useful as it is.

Closing this as as-designed. As noted, disable editor.occurrencesHighlight to switch from semantic symbol occurrence highlighting and to simple word highlighting.

If you don't see semantic highlighting working as expected in a js file, other features such as intellisense likely won't work either. Please open a new issue with some example code and we can take a look

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukehoban picture lukehoban  路  3Comments

sirius1024 picture sirius1024  路  3Comments

omidgolparvar picture omidgolparvar  路  3Comments

biij5698 picture biij5698  路  3Comments

NikosEfthias picture NikosEfthias  路  3Comments