File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 1
1
import * as vscode from "vscode" ;
2
2
import { Client } from "./client" ;
3
+ import { restartExtHostOnChangeIfNeeded } from "./util" ;
3
4
4
5
export function registerEnablementCommands ( context : vscode . ExtensionContext ) : void {
5
6
context . subscriptions . push ( vscode . commands . registerCommand ( "typescript.native-preview.enable" , ( ) => {
@@ -50,7 +51,7 @@ async function updateUseTsgoSetting(enable: boolean): Promise<void> {
50
51
}
51
52
// Update the setting and restart the extension host (needed to change the state of the built-in TS extension)
52
53
await tsConfig . update ( "experimental.useTsgo" , enable , target ) ;
53
- await vscode . commands . executeCommand ( "workbench.action.restartExtensionHost" ) ;
54
+ await restartExtHostOnChangeIfNeeded ( ) ;
54
55
}
55
56
56
57
/**
Original file line number Diff line number Diff line change 6
6
registerLanguageCommands ,
7
7
} from "./commands" ;
8
8
import { setupStatusBar } from "./statusBar" ;
9
+ import { needsExtHostRestartOnChange } from "./util" ;
9
10
import { setupVersionStatusItem } from "./versionStatusItem" ;
10
11
11
12
export async function activate ( context : vscode . ExtensionContext ) {
@@ -15,14 +16,11 @@ export async function activate(context: vscode.ExtensionContext) {
15
16
const traceOutput = vscode . window . createOutputChannel ( "typescript-native-preview (LSP)" ) ;
16
17
context . subscriptions . push ( output , traceOutput ) ;
17
18
18
- const majorVersion = parseInt ( vscode . version . split ( "." ) [ 0 ] ) ;
19
- const minorVersion = parseInt ( vscode . version . split ( "." ) [ 1 ] ) ;
20
- const needsExtHostRestartOnChange = majorVersion <= 1 && minorVersion < 105 ;
21
19
let disposeLanguageFeatures : vscode . Disposable | undefined ;
22
20
23
21
context . subscriptions . push ( vscode . workspace . onDidChangeConfiguration ( async event => {
24
22
if ( event . affectsConfiguration ( "typescript.experimental.useTsgo" ) ) {
25
- if ( needsExtHostRestartOnChange ) {
23
+ if ( needsExtHostRestartOnChange ( ) ) {
26
24
// Delay because the command to change the config setting will restart
27
25
// the extension host, so no need to show a message
28
26
setTimeout ( async ( ) => {
Original file line number Diff line number Diff line change @@ -89,3 +89,15 @@ export function getLanguageForUri(uri: vscode.Uri): string | undefined {
89
89
return undefined ;
90
90
}
91
91
}
92
+
93
+ export function needsExtHostRestartOnChange ( ) {
94
+ const majorVersion = parseInt ( vscode . version . split ( "." ) [ 0 ] ) ;
95
+ const minorVersion = parseInt ( vscode . version . split ( "." ) [ 1 ] ) ;
96
+ return majorVersion <= 1 && minorVersion < 105 ;
97
+ }
98
+
99
+ export async function restartExtHostOnChangeIfNeeded ( ) : Promise < void > {
100
+ if ( needsExtHostRestartOnChange ( ) ) {
101
+ await vscode . commands . executeCommand ( "workbench.action.restartExtensionHost" ) ;
102
+ }
103
+ }
You can’t perform that action at this time.
0 commit comments