@@ -48,38 +48,60 @@ function getCurrentTypeScriptPluginStatus(enabledHybridMode: boolean) {
48
48
return enabledHybridMode || config . server . hybridMode === 'typeScriptPluginOnly' ;
49
49
}
50
50
51
- function getCurrentHybridModeStatus ( report = false ) {
52
- if ( config . server . hybridMode === 'typeScriptPluginOnly' ) {
51
+ function isExtensionCompatibleWithHybridMode ( extension : vscode . Extension < any > ) {
52
+ if (
53
+ extension . id === 'Vue.volar'
54
+ || extension . id === 'unifiedjs.vscode-mdx'
55
+ || extension . id === 'astro-build.astro-vscode'
56
+ || extension . id === 'ije.esm-vscode'
57
+ || extension . id === 'johnsoncodehk.vscode-tsslint'
58
+ || extension . id === 'VisualStudioExptTeam.vscodeintellicode'
59
+ || extension . id === 'bierner.lit-html'
60
+ || extension . id === 'jenkey2011.string-highlight'
61
+ ) {
62
+ return true ;
63
+ }
64
+ if (
65
+ extension . id === 'styled-components.vscode-styled-components'
66
+ || extension . id === 'Divlo.vscode-styled-jsx-languageserver'
67
+ || extension . id === 'nrwl.angular-console'
68
+ ) {
53
69
return false ;
54
70
}
55
- else if ( config . server . hybridMode === 'auto' ) {
56
- const unknownExtensions : string [ ] = [ ] ;
57
- for ( const extension of vscode . extensions . all ) {
71
+ if ( extension . id === 'denoland.vscode-deno' ) {
72
+ return ! vscode . workspace . getConfiguration ( 'deno' ) . get < boolean > ( 'enable' ) ;
73
+ }
74
+ if ( extension . id === 'svelte.svelte-vscode' ) {
75
+ return semver . gte ( extension . packageJSON . version , '108.4.0' ) ;
76
+ }
77
+ }
78
+
79
+ function getCurrentHybridModeStatus ( report = false ) {
80
+
81
+ const incompatibleExtensions : string [ ] = [ ] ;
82
+ const unknownExtensions : string [ ] = [ ] ;
83
+
84
+ for ( const extension of vscode . extensions . all ) {
85
+ const compatible = isExtensionCompatibleWithHybridMode ( extension ) ;
86
+ if ( compatible === false ) {
87
+ incompatibleExtensions . push ( extension . id ) ;
88
+ }
89
+ else if ( compatible === undefined ) {
58
90
const hasTsPlugin = ! ! extension . packageJSON ?. contributes ?. typescriptServerPlugins ;
59
91
if ( hasTsPlugin ) {
60
- if (
61
- extension . id === 'Vue.volar'
62
- || extension . id === 'unifiedjs.vscode-mdx'
63
- || extension . id === 'astro-build.astro-vscode'
64
- || extension . id === 'ije.esm-vscode'
65
- || extension . id === 'johnsoncodehk.vscode-tsslint'
66
- || extension . id === 'VisualStudioExptTeam.vscodeintellicode'
67
- || extension . id === 'bierner.lit-html'
68
- || ( extension . id === 'denoland.vscode-deno' && ! vscode . workspace . getConfiguration ( 'deno' ) . get < boolean > ( 'enable' ) )
69
- || extension . id === 'jenkey2011.string-highlight'
70
- || ( extension . id === 'svelte.svelte-vscode' && semver . gte ( extension . packageJSON . version , '108.4.0' ) )
71
- ) {
72
- continue ;
73
- }
74
- else {
75
- unknownExtensions . push ( extension . id ) ;
76
- }
92
+ unknownExtensions . push ( extension . id ) ;
77
93
}
78
94
}
79
- if ( unknownExtensions . length ) {
95
+ }
96
+
97
+ if ( config . server . hybridMode === 'typeScriptPluginOnly' ) {
98
+ return false ;
99
+ }
100
+ else if ( config . server . hybridMode === 'auto' ) {
101
+ if ( incompatibleExtensions . length || unknownExtensions . length ) {
80
102
if ( report ) {
81
103
vscode . window . showInformationMessage (
82
- `Hybrid Mode is disabled automatically because there is a potentially incompatible ${ unknownExtensions . join ( ', ' ) } TypeScript plugin installed.` ,
104
+ `Hybrid Mode is disabled automatically because there is a potentially incompatible ${ [ ... incompatibleExtensions , ... unknownExtensions ] . join ( ', ' ) } TypeScript plugin installed.` ,
83
105
'Open Settings' ,
84
106
'Report a false positive' ,
85
107
) . then ( value => {
@@ -116,6 +138,20 @@ function getCurrentHybridModeStatus(report = false) {
116
138
return true ;
117
139
}
118
140
else {
141
+ if ( config . server . hybridMode && incompatibleExtensions . length && report ) {
142
+ vscode . window . showWarningMessage (
143
+ `You have explicitly enabled Hybrid Mode, but you have installed known incompatible extensions: ${ incompatibleExtensions . join ( ', ' ) } . You may want to change vue.server.hybridMode to "auto" to avoid compatibility issues.` ,
144
+ 'Open Settings' ,
145
+ 'Report a false positive' ,
146
+ ) . then ( value => {
147
+ if ( value === 'Open Settings' ) {
148
+ vscode . commands . executeCommand ( 'workbench.action.openSettings' , 'vue.server.hybridMode' ) ;
149
+ }
150
+ else if ( value == 'Report a false positive' ) {
151
+ vscode . env . openExternal ( vscode . Uri . parse ( 'https://github.com/vuejs/language-tools/pull/4206' ) ) ;
152
+ }
153
+ } ) ;
154
+ }
119
155
return config . server . hybridMode ;
120
156
}
121
157
0 commit comments