-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Improve syntax parsing #1315
Merged
Merged
Improve syntax parsing #1315
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes #1028 For a lot of files `yaml.safe_load` fails if the lib does not support the used yaml format. It is also very slow to parse all syntax files. Since we only use relatively simple information here, t.i. a single key, we just run a regex and extract the useful information.
Fixes #666 Note: for the least surprise we first parse the "tmLanguage" files, followed by "sublime-syntax" so that the latter overrule the former. Note: we don't have any way to tell which is the currently preferred syntax. We just use the last syntax we iterated over.
Since we cannot actually know the correct syntax just by looking at our map, we just choose the arbitrary `[-1]` last item, we try harder to just take the syntax using an open view. If we ever found such a syntax we also remember this choice.
In the status view we show short relative paths to a file. These come from git and thus have always "/" as the path separator. Since we construt absolute paths here, we should also `normpath`.
The help docs are saved with mac line endings. We convert to plain "\n" newline characters because that's internally the format Sublime uses and wants.
Got this when Sublime Text starts.
ST4 4074 on macOS by the way. |
It turns out that it was caused by this syntax file. Maybe it was caused by the comments? |
Pretty |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1028
Fixes #666
Avoid yaml parse errors by extracting the wanted key "file_extensions" via an ordinary regex. This is actually faster as well. By a lot.
Additionally, parse "tmLanguage" syntaxes because why not.
For a better "guess" for which syntax to use look at actual views currently open. Remember these used syntaxes.
Side fix: