Sublime Forum

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

#1

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
#2

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

0 Likes

#3

There’s a simple workaround in this issue: github.com/randy3k/AlignTab/issues/16

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

0 Likes

#4

Bump!
Please look at it.

0 Likes

#5

I suggest logging it here:

1 Like

#6

Also take a look here (and reference the threads)

0 Likes

#7

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.id(), 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.id(), 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.id(), 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

0 Likes