@@ -43,17 +43,8 @@ const documentSelector: DocumentSelector = [
43
43
44
44
export async function activate ( context : vscode . ExtensionContext ) : Promise < IPowerShellExtensionClient > {
45
45
logger = new Logger ( ) ;
46
- // Enables a reload-on-save for faster development
47
46
if ( context . extensionMode === vscode . ExtensionMode . Development ) {
48
- const watcher = vscode . workspace . createFileSystemWatcher (
49
- new vscode . RelativePattern ( context . extensionPath , "dist/*.js" ) ,
50
- ) ;
51
-
52
- context . subscriptions . push ( watcher ) ;
53
- watcher . onDidChange ( ( { fsPath } ) => {
54
- vscode . window . showInformationMessage ( `${ fsPath . split ( context . extensionPath , 2 ) [ 1 ] } changed. Reloading Extension Host...` ) ;
55
- vscode . commands . executeCommand ( "workbench.action.restartExtensionHost" ) ;
56
- } ) ;
47
+ restartOnExtensionFileChanges ( context ) ;
57
48
}
58
49
59
50
// Register a command that waits for the Externsion Terminal to be active. Can be used by .NET Attach Tasks
@@ -229,6 +220,19 @@ export async function activate(context: vscode.ExtensionContext): Promise<IPower
229
220
} ;
230
221
}
231
222
223
+ /** Restarts the extension host when extension file changes are detected. Useful for development.. */
224
+ function restartOnExtensionFileChanges ( context : vscode . ExtensionContext ) : void {
225
+ const watcher = vscode . workspace . createFileSystemWatcher (
226
+ new vscode . RelativePattern ( context . extensionPath , "dist/*.js" )
227
+ ) ;
228
+
229
+ context . subscriptions . push ( watcher ) ;
230
+ watcher . onDidChange ( ( { fsPath } ) => {
231
+ vscode . window . showInformationMessage ( `${ fsPath . split ( context . extensionPath , 2 ) [ 1 ] } changed. Reloading Extension Host...` ) ;
232
+ vscode . commands . executeCommand ( "workbench.action.restartExtensionHost" ) ;
233
+ } ) ;
234
+ }
235
+
232
236
export async function deactivate ( ) : Promise < void > {
233
237
// Clean up all extension features
234
238
for ( const commandRegistration of commandRegistrations ) {
0 commit comments