When we introduced our new .js file 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 (tmLanguage files).[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.js or source.ts and 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.
When we introduced our new
.js
file 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 (
tmLanguage
files).[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.js
orsource.ts
and 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.