You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to use the view.assign_syntax API with a scope: reference instead of a path to a syntax definition file. This causes inconsistent behavior.
Expected behavior
The syntax shown in the status bar should be correct.
Using view.settings().get('syntax') should return the path to the syntax definition that is being used. (It is possible to get the base scope through other means, so the value of this setting should be kept consistent, and thus always return a path to the relevant syntax definition file.)
Actual behavior
view.settings().get('syntax') returns the value that was passed to view.assign_syntax.
The syntax shown in the status bar is the value that was passed to view.assign_syntax before the ..
Example steps to reproduce
Go to Tools -> Developer -> New Plugin
Set the syntax to Plain Text.
Open the ST console
Type view.assign_syntax('scope:source.python')
Notice that the file is correctly highlighted
Notice that the syntax in the status bar shows scope:source
Type view.settings().get('syntax') in the console. Notice that the result is 'scope:source.python' and not 'Packages/Python/Python.sublime-syntax'
Environment
Operating system and version:
Windows 7 x64
Mac OSX (untested)
Linux: Ubuntu 16.04 x64
Sublime Text:
Build 3113 & 3114
The text was updated successfully, but these errors were encountered:
...because quite often the output is not JSON - i.e. when dumping a string etc.
...and because the Default `exec.py` implementation doesn't clear the syntax when using other build systems that don't specify it, so subsequent builds (i.e. non-LINQPad related) would also be highlighted as JSON
...because [there are compatibility issues when using `scope:`](sublimehq/sublime_text#1239)
Side note, the reason why assign_syntax is preferred to settings().set('syntax'... is if you just set the syntax setting, as opposed to using assign_syntax, then the syntax won't be applied properly - syntax highlighting will be fine, but the preferences won't get setup for the view. e.g., if you want the settings in C++.sublime-settings to be applied, then you need to use assign_syntax().
Therefore it seems reasonable that assign_syntax could also, in the future, handle scope: correctly. But this may be unnecessary if #2186 is implemented.
Summary
It is possible to use the
view.assign_syntax
API with ascope:
reference instead of a path to a syntax definition file. This causes inconsistent behavior.Expected behavior
The syntax shown in the status bar should be correct.
Using
view.settings().get('syntax')
should return the path to the syntax definition that is being used. (It is possible to get the base scope through other means, so the value of this setting should be kept consistent, and thus always return a path to the relevant syntax definition file.)Actual behavior
view.settings().get('syntax')
returns the value that was passed toview.assign_syntax
.The syntax shown in the status bar is the value that was passed to
view.assign_syntax
before the.
.Example steps to reproduce
Tools
->Developer
->New Plugin
Plain Text
.view.assign_syntax('scope:source.python')
scope:source
view.settings().get('syntax')
in the console. Notice that the result is'scope:source.python'
and not'Packages/Python/Python.sublime-syntax'
Environment
The text was updated successfully, but these errors were encountered: