Sublime Forum

[BUG ST2/3] set_syntax_file() clear 'is_widget' setting


view.set_syntax_file() remove the ‘is_widget’ setting of the view.

If you type this code (line after line) in the console:

v = window.show_input_panel('test', '', None, None,None) print(v.settings().get('is_widget')) v.set_syntax_file('Python.tmLanguage') print(v.settings().get('is_widget'))
you’ll notice that the first print statement write True, and the second None.
So keybindings that use a context on setting.is_widget does not work correctly.

1 Like

Switch focus from panel or overlay to text of document from within plugin
Toggle the minimap only with large files

Nice catch. I have always wondered why “is_widget” seemed so flaky.



There’s a simple workaround in this issue:

Now maybe this is not the only thing (API or command) that change this setting, only Jon can tell…



Please look at it.



I suggest logging it here:

1 Like


Also take a look here (and reference the threads)



Just as an experiment, I tried a few things and discovered that it re-attains it’s is_widget setting if you show the input panel again (it re-uses the same view object). Although, it loses the syntax that was set, so it’s not a valid workaround.

>>> v = window.show_input_panel('test', '', None, None, None)
>>> print(v.settings().get('is_widget'), v.settings().get('syntax'),, v.settings().get('gutter'))
True Packages/Text/Plain text.tmLanguage 3 False
>>> v.assign_syntax('Packages/Python/Python.sublime-syntax')
>>> print(v.settings().get('is_widget'), v.settings().get('syntax'),, v.settings().get('gutter'))
None Packages/Python/Python.sublime-syntax 3 True
>>> v2 = window.show_input_panel('test', '', None, None, None)
>>> print(v2.settings().get('is_widget'), v2.settings().get('syntax'),, v2.settings().get('gutter'), v == v2)
True Packages/Text/Plain text.tmLanguage 3 False True

So it looks like there is some internal logic that shows the gutter and removes the is_widget setting when a syntax definition is applied to the view