Check if the entire file matches a selector in is_typescript
#705
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.
When we introduced our new
.jsfile support, we accidentally started trying to parse files with<script>blocks in them whenever the user tried interacting with an element (#703); however, this was actually a longer-running problem (#665). This PR fixes both.The root problem is that file type detection is based on scopes, which are determined by grammar files (
tmLanguagefiles).[1] This is usually good for syntax highlighting because it means that grammars can embed each other, so the HTML and Vue grammars can say "ah, a<script>tag! I should launch into the JavaScript grammar!" or something similar.Except our implementation looks at the entire file instead of just the containing scope, and as soon as the user clicks into one of these JS/TS scopes, we'd query the scope at the current location, see
source.jsorsource.tsand we'd say "that's for us!" and try to parse/type-check the whole file.With this change, we'll only try to analyze the view if the entire file is one big TypeScript or JavaScript scope.
Fixes #665.
Fixes #703.
[1] I'm not sure why we don't use file extensions, but I assume there was a good reason for them at the time.