Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
PhantomSet.update does not always remove all phantoms #2897
In some situations phantoms no longer present in the
Steps to reproduce
For some reason this is easy triggered when using the ColorHints plugin and editing multiple colors on the same line. It also seems that undoing and redoing changes in rapid fashion frequently causes "dangling" phantoms. The ColorHints plugin builds a list of phantoms that should be displayed, and passes that on to
In this image on the lef you can see the list being printed, and currently it's empty. On the right you can see that 4 phantoms are still visually present in the view.
Some region "decorations" like phantoms, but the similar behavior has also been noticed in highlights like the ones produced by SublimeLinter: undoing changes sometimes makes highlights visually re-appear, but they're no longer attached to anything and cannot be removed.
@jskinner I have probably another case which I am able to stably and easily reproduce.
The plugin is https://github.com/jfcherng/open_in_browser.
Steps to reproduce as shown in the above gif.
Thanks for the repro, this will be fixed in the next build
The underlying phantom API is fine, the bug is in PhantomSet: it stores the known phantoms in a dict, but changes the value returned by
This line seems to be problematic. It's causing
I tried some
The following doesn't fix the original bug.
def __hash__(self): return hash(';'.join(map(str, [ self.region, self.content, self.layout, hash(self.on_navigate), ])))
The following fixes the original bug but it just re-renders everything which causes unwanted performance/visual issues.
def __hash__(self): return hash(self.id)
This may also be the reason for other relatd weird behavior, such as https://forum.sublimetext.com/t/dev-build-3118/21270/49?u=fichtefoll (unfortunately the webm is missing, but here's a reupload).
A proper workaround is below, which is derived from the implementation of PhantomSet in the most recent Sublime Text build: