Closed rchl closed 1 year ago
Can you add this after line 424
in your WakaTime.py
file:
print("SELECTIONS: ", selections)
Then check your ST console for the output? What I want to find is the value of selections
because right before selections[0]
the code checks to make sure selections
is defined which should guarantee it has at least one item in the list. So, an IndexError
doesn't make sense.
I don't have a way to reproduce it at the moment but "truthy" check is not enough due to how Selections object is implemented in ST. It defines:
def __bool__(self):
return self.view_id != 0
which doesn't check number of selections. The 3.8 plugin host does:
def __bool__(self) -> bool:
""" The selection is ``True`` when not empty. """
return self.view_id != 0 and len(self) > 0
but that fix didn't trickle down to the old host.
So the explicit len(...)
check is needed.
Oh, that's not normal in Python but I was assuming it behaved like a Python list. I'll submit a patch now.
Fixed in v11.0.8 released just now.
I'm randomly getting errors like:
It's not really that important how it's triggered IMO because in the ST API it's not guaranteed that selection is non-empty so plugin should never assume so and always check first.