The list of already-marked words (_keys) is a class attribute of StickysearchCommand, so it is shared by every view and window. Once a word has been marked in one tab, "add"/"set" for the same word in any other tab does not highlight anything there: the plugin thinks it is already marked and just jumps to the next match instead. The comment in run() ("keep sticky per window (each window has its own set)") describes the intended behaviour, but the state is global.
class StickysearchCommand(sublime_plugin.TextCommand):
_keys = [] # shared by all views
...
if key not in self._keys:
self.mark(key, regions); self._keys.append(key)
else:
self.jump_to_next_match(selected_region, regions)
Reproduced by running the command class (Sublime stubbed, package code unchanged) on two views that both contain foo, pressing "add" with the cursor on foo in each:
regions marked in view A: {'StickySearch\bfoo\b': 2}
regions marked in view B: {} (same word 'foo' in both views)
Same root cause the other way round: clear in one tab drops keys that other tabs still show as highlighted, so those highlights can no longer be cleared with the command.
Fix: keep the marked keys per view (e.g. derive them from view.settings() or a dict keyed by view.id()), or check view.get_regions(key) instead of a global list.
Found while testing packages from the Package Control catalog.
The list of already-marked words (
_keys) is a class attribute ofStickysearchCommand, so it is shared by every view and window. Once a word has been marked in one tab, "add"/"set" for the same word in any other tab does not highlight anything there: the plugin thinks it is already marked and just jumps to the next match instead. The comment inrun()("keep sticky per window (each window has its own set)") describes the intended behaviour, but the state is global.Reproduced by running the command class (Sublime stubbed, package code unchanged) on two views that both contain
foo, pressing "add" with the cursor onfooin each:Same root cause the other way round:
clearin one tab drops keys that other tabs still show as highlighted, so those highlights can no longer be cleared with the command.Fix: keep the marked keys per view (e.g. derive them from
view.settings()or a dict keyed byview.id()), or checkview.get_regions(key)instead of a global list.Found while testing packages from the Package Control catalog.