@@ -242,6 +242,7 @@ function startClient(context: vscode.ExtensionContext) {
242
242
client . onReady ( ) . then ( ( ) => {
243
243
var updateSetting = new NotificationType < { section : string , value : any , global : boolean } > ( "coded/updateSetting" ) ;
244
244
client . onNotification ( updateSetting , ( arg : { section : string , value : any , global : boolean } ) => {
245
+ hideNextPotentialConfigUpdateWarning ( ) ;
245
246
config ( null ) . update ( arg . section , arg . value , arg . global ) ;
246
247
} ) ;
247
248
@@ -405,6 +406,7 @@ export function activate(context: vscode.ExtensionContext): CodedAPI {
405
406
406
407
context . subscriptions . push ( addSDLProviders ( ) ) ;
407
408
context . subscriptions . push ( addJSONProviders ( ) ) ;
409
+ context . subscriptions . push ( createConfigUpdateWatcher ( ) ) ;
408
410
409
411
context . subscriptions . push ( registerCompilerInstaller ( context ) ) ;
410
412
@@ -526,8 +528,10 @@ async function preStartup(context: vscode.ExtensionContext) {
526
528
}
527
529
}
528
530
529
- if ( updateSetting )
531
+ if ( updateSetting ) {
532
+ hideNextPotentialConfigUpdateWarning ( ) ;
530
533
await config ( null ) . update ( "dubPath" , path ) ;
534
+ }
531
535
return true ;
532
536
}
533
537
@@ -690,6 +694,7 @@ async function preStartup(context: vscode.ExtensionContext) {
690
694
}
691
695
692
696
if ( isLegacyBeta && servedReleaseChannel && ! servedReleaseChannel . globalValue ) {
697
+ hideNextPotentialConfigUpdateWarning ( ) ;
693
698
config ( null ) . update ( "servedReleaseChannel" , "nightly" , vscode . ConfigurationTarget . Global ) ;
694
699
channelString = "nightly" ;
695
700
@@ -703,9 +708,11 @@ async function preStartup(context: vscode.ExtensionContext) {
703
708
if ( item == userConfig ) {
704
709
vscode . commands . executeCommand ( "workbench.action.openGlobalSettings" ) ;
705
710
} else if ( item == stable ) {
711
+ hideNextPotentialConfigUpdateWarning ( ) ;
706
712
let done = config ( null ) . update ( "servedReleaseChannel" , "stable" , vscode . ConfigurationTarget . Global ) ;
707
713
didChangeReleaseChannel ( done ) ;
708
714
} else if ( item == beta ) {
715
+ hideNextPotentialConfigUpdateWarning ( ) ;
709
716
let done = config ( null ) . update ( "servedReleaseChannel" , "beta" , vscode . ConfigurationTarget . Global ) ;
710
717
didChangeReleaseChannel ( done ) ;
711
718
}
@@ -904,3 +911,49 @@ function shortenPath(p: string) {
904
911
} ) ;
905
912
return short ;
906
913
}
914
+
915
+ /**
916
+ * Watches for config updates that need a vscode window reload to be effective
917
+ * and shows a hint to the user in these cases.
918
+ */
919
+ function createConfigUpdateWatcher ( ) : vscode . Disposable {
920
+ return vscode . workspace . onDidChangeConfiguration ( ( e ) => {
921
+ const needReloadSettings = [
922
+ "d.servedPath" ,
923
+ "d.servedReleaseChannel" ,
924
+ "d.dcdServerPath" ,
925
+ "d.dcdClientPath" ,
926
+ "d.scanAllFolders" ,
927
+ "d.neverUseDub" ,
928
+ "d.disabledRootGlobs" ,
929
+ "d.extraRoots" ,
930
+ ] ;
931
+
932
+ if ( lastConfigUpdateWasInternal && new Date ( ) . getTime ( ) - lastConfigUpdateWasInternal < 1000 )
933
+ return ; // ignore config updates that come from code-d or serve-d
934
+
935
+ var changed : string | null = null ;
936
+ needReloadSettings . forEach ( setting => {
937
+ if ( ! changed && e . affectsConfiguration ( setting ) )
938
+ changed = setting ;
939
+ } ) ;
940
+
941
+ let reloadBtn = "Reload VSCode" ;
942
+ let ignoreBtn = "Ignore" ;
943
+
944
+ if ( changed )
945
+ vscode . window . showInformationMessage ( "You have changed code-d's `"
946
+ + changed + "` setting. To apply the new value, you need to reload VSCode." ,
947
+ reloadBtn , ignoreBtn )
948
+ . then ( btn => {
949
+ if ( btn == reloadBtn )
950
+ vscode . commands . executeCommand ( "workbench.action.reloadWindow" ) ;
951
+ } ) ;
952
+ } ) ;
953
+ }
954
+
955
+ var lastConfigUpdateWasInternal : number | null ;
956
+ export function hideNextPotentialConfigUpdateWarning ( ) {
957
+ lastConfigUpdateWasInternal = new Date ( ) . getTime ( ) ;
958
+ }
959
+
0 commit comments