8

Just installed Eclipse Juno Release, Build id: 20120614-1722.

I have 'Mark Occurrences' turned on, and I can see that it does indeed mark some of the occurrences in the JS file I'm editing. However, there's a function call that it doesn't mark.

var trackView = function() {
    saveData();
},
saveData = function() {
    // do something
};

When I click into the saveData occurrence where it is defined (line 4), it highlights, but it doesn't highlight the occurrence on line 2 where the function is being called. When I click into the saveData occurrence on line 2, neither highlights.

Any ideas?

Jeff Ludden
  • 296
  • 1
  • 3
  • 6
  • Does it help if you say `var saveData = function(){` or `function saveData(){` ? – Thilo Aug 29 '12 at 23:47
  • I have the same problem in Eclipse Juno SR2. Sometimes the mark occurences function works, and sometimes not. I have not changed the settings for mark occurences, and I have disabled the shortcut for doing so. – Stig Runar Vangen Mar 08 '13 at 10:22

10 Answers10

21

The bug report in Eclipse also mentions another workaround: select something in the Outline view, and then select the field in your source again.

This works mostly always for me.

rdvdijk
  • 4,400
  • 26
  • 30
Tom
  • 1,414
  • 12
  • 21
  • 1
    This seems to work for me. The cause seems to be ctrl-clicking something which opens a new editor (ie a method on a different class). Selecting something in Outline seems to unstick the selection. – Mar Apr 25 '13 at 18:47
18

If you toggle from eclipse window to another window using ATL+TAB and come back to Eclipse window it is higlighted.

Subas Raj
  • 181
  • 1
  • 2
  • 6
    +1 but a better workaround is to use Shift+Alt+O+O - the double "O" will toggle marked occurrences off then on again (which save cycling through windows or doing Alt+Tab then Shift+Alt+Tab) – earcam Apr 25 '13 at 15:52
  • You save my life. Using Shift+Alt+O to turn off and on again doesn't work for me. Clicking something in Outline doesn't work for me either. You save my life. Thanks. – nicky_zs Dec 23 '14 at 06:08
10

This is a known bug in Eclipse Juno and is actively (as of this writing) being investigated by Eclipse developers.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=400661

https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509


UPDATE 6/2: This bug has been resolved in Release 4.2.2

https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509

Doug Ayers
  • 934
  • 1
  • 8
  • 20
9

If you uncheck the below option it will work fine

Preference > Java > Editor > Mark Ocurrences > Uncheck: Keep marks when the selection changes.

Sniper
  • 2,412
  • 11
  • 44
  • 49
  • I don't know why, but (suddenly) this section was completely unchecked in my Kepler version and I was wondering, why highlighting didn't work anymore. – Torsten Mar 02 '14 at 16:55
4

This is a bug in Eclipse - the occurrence-highlight seems to "stick" to the first thing you point to.

Two "solutions" that at least get the highlight stuck on a new item (!!):

  1. As @Subas Raj mentioned, defocus and refocus the window - when you come back, your current position is occurrence-highlighted. Either hit AltTab twice, or use your mouse to click/focus some other window, then back.
  2. As @Leo and @Gorky mentions, hit AltShiftO twice. This is the shortcut for toggling highlight occurrences, and when you turn it back on, your current position is occurrence-highlighted.

And finally, a third ACTUAL solution: Replace one specific jar with a patched one: https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509#c60

.. or upgrade to M7 (4.3), which now are released: https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509#c62

stolsvik
  • 5,253
  • 7
  • 43
  • 52
2

All configuration and settings for "Mark Occurrences" are proper but it seems this is Eclipse JUNO problem. I have been observing this issue and tried to resolve many way but in Juno, highlighting occurrences is not consistent.

Sometimes it works pretty fast, sometimes it takes time to highlight, sometimes it doesn't at all.

Also observed that once we restart Eclipse, things works proper but gradually, highlighting occurrences become slow and stops also.

~Chirag

Chirag Katudia
  • 511
  • 5
  • 6
  • I confirm this too, although only in Ubuntu (12.04). It's so annoying sometimes. I find that closing the current tab and reopening "fixes" the issue, but it's still a pain to do it. :\ –  Mar 27 '13 at 01:52
1

Go to Window -> Preferences -> General -> Editors -> Text Editors -> Annotations

Under both Occurrences & Write Occurrences, make sure you have the Text as Highlighted option selected.

Also, under General -> JavaScript -> Editor -> Mark Occurrences make sure all of the check boxes are checked.

Display name
  • 1,109
  • 1
  • 15
  • 31
  • Yes, already have all of them checked, in both places you mention. Separating out the function in their own var statement did not help either. So long Eclipse. – Jeff Ludden Aug 30 '12 at 00:41
1

I unchecked General -- Appearance Use mixed fonts and colors for labels and now it works better...

dew
  • 11
  • 1
0

Same as I encountered, you can try to click "Toggle Mark Occurrences" twice (turn it off and turn on) or you can also try to use Alt+Shift+O twice. And can also try the solution of @Subas Raj, is good.

0

For now there is only workaround (push "Alt + Shift + O" twice):

Cannot highlight all occurrences of a selected word in Eclipse

Community
  • 1
  • 1
Gorky
  • 161
  • 2
  • 14