SublimeText / PackageDev

Tools to ease the creation of snippets, syntax definitions, etc. for Sublime Text.
MIT License
436 stars 83 forks source link

list index out of range #153

Closed evandrocoan closed 7 years ago

evandrocoan commented 7 years ago

After changing the rulers on my project settings I got this on my console:

Exception IndexError: 'list index out of range' in <bound method SettingsListener.__del__ of <PackageDev.plugins_.settings.SettingsListener object at 0x06636C50>> ignored
reloading /D/User.sublime-project

But I got only this. No line errors, nothing more. How to find from where this message is coming from?

After seem this, I also tested it against the lasted change on master branch I got from: https://github.com/evandrocoan/PackageDev/pull/5 and got the same behavior.


Related:

  1. https://github.com/Monnoroch/ColorHighlighter/issues/370 AttributeError: 'bool' object has no attribute 'find'
FichteFoll commented 7 years ago

This might be an exception happening in sublime.PhantomSet.update, because I don't have any direct list access in that code. Looking into that code, the only line in that could happen is this one (the third):

        regions = self.view.query_phantoms([p.id for p in self.phantoms])
        for i in range(len(regions)):
            self.phantoms[i].region = regions[i]

I don't see a way in which this could cause i to be out of range for the self.phantoms list. The View.query_phantoms method is undocumented either way, so I say this is not of our business. The only thing that comes to my head would be a race condition.

Well okay, it could also happen later here:

                idx = self.phantoms.index(p)
                p.id = self.phantoms[idx].id

but, again, only with a race condition since the ValueError raised by a failing index call is caught.


Can you reproduce this reliably? If yes, we might be able to file an issue to the core tracker, but unless we can, we might as well mark this off as a race condition (and it's not our fault either way).

Furthermore, you mentioned you only changed the ruler setting for your project settings and not that you closed a view. I find this weird since Listener instances shouldn't be deleted unless the view is closed or is_applicable no longer returns true for a view, which only looks at a view's syntax setting. Are you sure you only changed the ruler setting and didn't close a view? In the latter case, we might be able to avoid the exception by checking whether the view has already been destroyed first with view.buffer_id().

evandrocoan commented 7 years ago

Can you reproduce this reliably?

Thanks for the efforts! I tried to create a way to reproduce this, but it stopped happening somehow. Perhaps it is because I restarted Sublime Text. I am closing it was I cannot reproduce it anymore on my installation.

Are you sure you only changed the ruler setting and didn't close a view?

I think not, I used this package I had been working on the last 3 days to change the setting, while I had the view opened. To edit the data file, it does this:

    if setting_file == current_project_file:
        data = view.window().project_data()

        if 'settings' not in data:
            data['settings'] = {}

        data['settings'][setting_name] = value
        view.window().set_project_data(data)
        return
  1. https://github.com/evandrocoan/SublimeQuickSettings/blob/ac5f8ea95984e56927b4d240f8ec1572934ca331/QuickSettigns.py#L241-L249

back