Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

view.assign_syntax with scope:... instead of a file path #1239

Closed
2 of 3 tasks
keith-hall opened this issue Jun 13, 2016 · 4 comments
Closed
2 of 3 tasks

view.assign_syntax with scope:... instead of a file path #1239

keith-hall opened this issue Jun 13, 2016 · 4 comments

Comments

@keith-hall
Copy link
Collaborator

Summary

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

  1. Go to Tools -> Developer -> New Plugin
  2. Set the syntax to Plain Text.
  3. Open the ST console
  4. Type view.assign_syntax('scope:source.python')
  5. Notice that the file is correctly highlighted
  6. Notice that the syntax in the status bar shows scope:source
  7. 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
keith-hall added a commit to SublimeText/LINQPad that referenced this issue Jun 14, 2017
...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)
@keith-hall
Copy link
Collaborator Author

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.

@wbond wbond added this to the next dev cycle milestone Oct 9, 2019
@deathaxe
Copy link
Collaborator

ST 4050+ supports view.assign_syntax("scope:source.python").

@rwols
Copy link

rwols commented Feb 29, 2020

What happens in case multiple syntax files have the same base scope?

@FichteFoll
Copy link
Collaborator

Liklely the one with higher precedence (loaded later) wins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants