@@ -16,6 +16,7 @@ import * as languageConfigurations from './utils/languageConfigurations';
1616import { standardLanguageDescriptions } from './utils/languageDescription' ;
1717import ManagedFileContextManager from './utils/managedFileContext' ;
1818import { lazy , Lazy } from './utils/lazy' ;
19+ import TypeScriptServiceClient from './typescriptServiceClient' ;
1920
2021export function activate (
2122 context : vscode . ExtensionContext
@@ -27,26 +28,21 @@ export function activate(
2728
2829 const lazyClientHost = createLazyClientHost ( context , plugins , commandManager ) ;
2930
30- context . subscriptions . push ( new ManagedFileContextManager ( resource => {
31- // Don't force evaluation here.
32- if ( lazyClientHost . hasValue ) {
33- return lazyClientHost . value . serviceClient . normalizePath ( resource ) ;
34- }
35- return null ;
36- } ) ) ;
37-
3831 registerCommands ( commandManager , lazyClientHost ) ;
3932 context . subscriptions . push ( new TypeScriptTaskProviderManager ( lazyClientHost . map ( x => x . serviceClient ) ) ) ;
4033 context . subscriptions . push ( vscode . languages . setLanguageConfiguration ( languageModeIds . jsxTags , languageConfigurations . jsxTags ) ) ;
4134
42-
4335 const supportedLanguage = [ ] . concat . apply ( [ ] , standardLanguageDescriptions . map ( x => x . modeIds ) . concat ( plugins . map ( x => x . languages ) ) ) ;
4436 function didOpenTextDocument ( textDocument : vscode . TextDocument ) : boolean {
45- if ( supportedLanguage . indexOf ( textDocument . languageId ) >= 0 ) {
37+ if ( isSupportedDocument ( supportedLanguage , textDocument ) ) {
4638 openListener . dispose ( ) ;
4739 // Force activation
4840 // tslint:disable-next-line:no-unused-expression
4941 void lazyClientHost . value ;
42+
43+ context . subscriptions . push ( new ManagedFileContextManager ( resource => {
44+ return lazyClientHost . value . serviceClient . normalizePath ( resource ) ;
45+ } ) ) ;
5046 return true ;
5147 }
5248 return false ;
@@ -89,3 +85,19 @@ function registerCommands(
8985 commandManager . register ( new commands . TypeScriptGoToProjectConfigCommand ( lazyClientHost ) ) ;
9086 commandManager . register ( new commands . JavaScriptGoToProjectConfigCommand ( lazyClientHost ) ) ;
9187}
88+
89+
90+ function isSupportedDocument (
91+ supportedLanguage : string [ ] ,
92+ document : vscode . TextDocument
93+ ) : boolean {
94+ if ( supportedLanguage . indexOf ( document . languageId ) < 0 ) {
95+ return false ;
96+ }
97+ const scheme = document . uri . scheme ;
98+ return (
99+ scheme === TypeScriptServiceClient . WALK_THROUGH_SNIPPET_SCHEME
100+ || scheme === 'untitled'
101+ || scheme === 'file'
102+ ) ;
103+ }
0 commit comments