Sublime Forum

ST3 Bug: view.settings() gets wonky

#1

view.settings() misbehaves after the same file is open on two different columns, and one copy gets closed. Running on Linux, Build 3033.

Here is the smallest plugin to reproduce this (I bound it to the ‘a’ key temporarily)

[code]import sublime
import sublime_plugin

class MyThing(sublime_plugin.TextCommand):
def run(self, edit, **kwargs):
SETTING_NAME = ‘foo’
DEFAULT = {‘a’: 5}
value = self.view.settings().get(SETTING_NAME)
print(“view=%d, current = %s” % (self.view.buffer_id(), value))
if value is None:
self.view.settings().set(SETTING_NAME, DEFAULT)
value = self.view.settings().get(SETTING_NAME)
print(“view=%d, fixed to = %s” % (self.view.buffer_id(), value))[/code]

Triggering the odd behavior:

  1. Switch to two-columns layout.
  2. open a file in the left column. Click ‘a’ to trigger the plugin.
  3. open the same file in the right column. Click ‘a’ to trigger the plugin.
  4. close the file in the right column.
  5. Switch to the left column, click ‘a’ to trigger the plugin.

At that point, it will turn out that something bad happened to view.settings(). It forgot the value assigned to it. Not only that, it will refuse future assignments:

view=31, current = None view=31, fixed to = None

So two things are broken:

  1. the setting value is lost after one view is closed.
  2. we are left with a broken settings object: we set a key, retrieve it a statement later but get None.

Another oddity, is that at the console self.settings.get(‘foo’) does seem to return the right thing.

I believe this is the culprit of what makes Vintage and Vintageous to get stuck in this scenario, since the view that’s left looses access to the ‘vintage’ key it’s using. References:

[1] ST3: can't insert text in Vintage insert mode
[2] github.com/guillermooo/Vintageous/issues/192

0 Likes

#2

Thanks for the report and detailed repro, this issue will be fixed in the next build.

0 Likes