@@ -485,7 +485,7 @@ function activate(context) {
485
485
const themeConfigPath = path . resolve ( __dirname , themeConfigPaths [ vibrancyTheme ] ) ;
486
486
const themeConfig = require ( themeConfigPath ) ;
487
487
const enableAutoTheme = vscode . workspace . getConfiguration ( ) . get ( "vscode_vibrancy.enableAutoTheme" ) ;
488
-
488
+
489
489
// Get the current settings
490
490
const terminalColorConfig = vscode . workspace . getConfiguration ( ) . inspect ( "workbench.colorCustomizations" ) ;
491
491
const gpuAccelerationConfig = vscode . workspace . getConfiguration ( ) . inspect ( "terminal.integrated.gpuAcceleration" ) ;
@@ -495,15 +495,15 @@ function activate(context) {
495
495
496
496
// Fetch previous values from global state
497
497
let previousCustomizations = context . globalState . get ( 'customizations' ) || { } ;
498
-
498
+
499
499
// Get current values
500
500
const currentColorCustomizations = terminalColorConfig ?. globalValue || { } ;
501
501
const currentBackground = currentColorCustomizations ?. [ "terminal.background" ] ;
502
502
const currentGpuAcceleration = gpuAccelerationConfig ?. globalValue ;
503
503
const currentApplyToAllProfiles = applyToAllProfilesConfig ?. globalValue ;
504
504
const currentSystemColorTheme = systemColorTheme ?. globalValue ;
505
505
const currentAutoDetectColorScheme = autoDetectColorScheme ?. globalValue ;
506
-
506
+
507
507
// Store original values if not already saved
508
508
if ( ! previousCustomizations . saved ) {
509
509
previousCustomizations = {
@@ -515,16 +515,15 @@ function activate(context) {
515
515
autoDetectColorScheme : currentAutoDetectColorScheme ,
516
516
} ;
517
517
}
518
-
518
+
519
519
try {
520
- // Remove "workbench.colorCustomizations" from applyToAllProfiles if it's there to fix an issue this caused with profiles
521
- if ( ! previousCustomizations . removedFromApplyToAllProfiles && currentApplyToAllProfiles . includes ( "workbench.colorCustomizations" ) ) {
520
+ // Remove "workbench.colorCustomizations" from applyToAllProfiles if it's there
521
+ if ( ! previousCustomizations . removedFromApplyToAllProfiles && currentApplyToAllProfiles ? .includes ( "workbench.colorCustomizations" ) ) {
522
522
const updatedApplyToAllProfiles = currentApplyToAllProfiles . filter ( setting => setting !== "workbench.colorCustomizations" ) ;
523
523
await vscode . workspace . getConfiguration ( ) . update ( "workbench.settings.applyToAllProfiles" , updatedApplyToAllProfiles , vscode . ConfigurationTarget . Global ) ;
524
524
525
525
// Notify user of the change
526
526
vscode . window . showInformationMessage ( localize ( 'messages.applyToAllProfiles' ) ) ;
527
-
528
527
}
529
528
// Ensure this fix is only applied once
530
529
previousCustomizations . removedFromApplyToAllProfiles = true ;
@@ -537,23 +536,38 @@ function activate(context) {
537
536
"terminal.background" : "#00000000"
538
537
} ;
539
538
}
540
-
539
+
541
540
await vscode . workspace . getConfiguration ( ) . update ( "workbench.colorCustomizations" , newColorCustomization , vscode . ConfigurationTarget . Global ) ;
542
541
await vscode . workspace . getConfiguration ( ) . update ( "terminal.integrated.gpuAcceleration" , "off" , vscode . ConfigurationTarget . Global ) ;
543
-
542
+
543
+ // Handle auto theme settings
544
544
if ( enableAutoTheme ) {
545
- // Allow VSCode to auto-detect the color theme
546
- vscode . workspace . getConfiguration ( ) . update ( "window.systemColorTheme" , undefined , vscode . ConfigurationTarget . Global ) ;
547
- vscode . workspace . getConfiguration ( ) . update ( "window.autoDetectColorScheme" , true , vscode . ConfigurationTarget . Global ) ;
545
+ try {
546
+ await vscode . workspace . getConfiguration ( ) . update ( "window.autoDetectColorScheme" , true , vscode . ConfigurationTarget . Global ) ;
547
+ } catch ( error ) {
548
+ console . warn ( "window.autoDetectColorScheme is not supported in this version of VSCode." ) ;
549
+ }
550
+ try {
551
+ await vscode . workspace . getConfiguration ( ) . update ( "window.systemColorTheme" , undefined , vscode . ConfigurationTarget . Global ) ;
552
+ } catch ( error ) {
553
+ console . warn ( "window.systemColorTheme is not supported in this version of VSCode." ) ;
554
+ }
548
555
} else {
549
- // Sync VSCode color theme with Vibrancy theme
550
- vscode . workspace . getConfiguration ( ) . update ( "window.systemColorTheme" , themeConfig . systemColorTheme , vscode . ConfigurationTarget . Global ) ;
551
- vscode . workspace . getConfiguration ( ) . update ( "window.autoDetectColorScheme" , false , vscode . ConfigurationTarget . Global ) ;
556
+ try {
557
+ await vscode . workspace . getConfiguration ( ) . update ( "window.systemColorTheme" , themeConfig . systemColorTheme , vscode . ConfigurationTarget . Global ) ;
558
+ } catch ( error ) {
559
+ console . warn ( "window.systemColorTheme is not supported in this version of VSCode." ) ;
560
+ }
561
+ try {
562
+ await vscode . workspace . getConfiguration ( ) . update ( "window.autoDetectColorScheme" , false , vscode . ConfigurationTarget . Global ) ;
563
+ } catch ( error ) {
564
+ console . warn ( "window.autoDetectColorScheme is not supported in this version of VSCode." ) ;
565
+ }
552
566
}
553
567
} catch ( error ) {
554
568
console . error ( "Error updating settings:" , error ) ;
555
569
}
556
-
570
+
557
571
// Save user customizations
558
572
await context . globalState . update ( 'customizations' , previousCustomizations ) ;
559
573
}
@@ -586,9 +600,17 @@ function activate(context) {
586
600
await vscode . workspace . getConfiguration ( ) . update ( "workbench.colorCustomizations" , restoredColorCustomizations , vscode . ConfigurationTarget . Global ) ;
587
601
}
588
602
603
+ try {
604
+ await vscode . workspace . getConfiguration ( ) . update ( "window.systemColorTheme" , previousCustomizations . systemColorTheme , vscode . ConfigurationTarget . Global ) ;
605
+ } catch ( error ) {
606
+ console . warn ( "window.systemColorTheme is not supported in this version of VSCode." ) ;
607
+ }
608
+ try {
609
+ await vscode . workspace . getConfiguration ( ) . update ( "window.autoDetectColorScheme" , previousCustomizations . autoDetectColorScheme , vscode . ConfigurationTarget . Global ) ;
610
+ } catch ( error ) {
611
+ console . warn ( "window.autoDetectColorScheme is not supported in this version of VSCode." ) ;
612
+ }
589
613
await vscode . workspace . getConfiguration ( ) . update ( "terminal.integrated.gpuAcceleration" , previousCustomizations . gpuAcceleration , vscode . ConfigurationTarget . Global ) ;
590
- await vscode . workspace . getConfiguration ( ) . update ( "window.systemColorTheme" , previousCustomizations . systemColorTheme , vscode . ConfigurationTarget . Global ) ;
591
- await vscode . workspace . getConfiguration ( ) . update ( "window.autoDetectColorScheme" , previousCustomizations . autoDetectColorScheme , vscode . ConfigurationTarget . Global ) ;
592
614
593
615
// Preserve the removedFromApplyToAllProfiles flag
594
616
const removedFromApplyToAllProfiles = previousCustomizations . removedFromApplyToAllProfiles ;
@@ -601,30 +623,33 @@ function activate(context) {
601
623
}
602
624
}
603
625
604
- async function getActiveFlagPath ( ) {
626
+ async function getLocalConfigPath ( ) {
605
627
const envPaths = ( await import ( 'env-paths' ) ) . default ;
606
-
607
- const paths = envPaths ( 'vscode-vibrancy' ) ;
608
- const activeFlagPath = path . join ( paths . config , 'active' ) ;
628
+ const paths = envPaths ( 'vscode-vibrancy-continued' ) ;
629
+ const configFilePath = path . join ( paths . config , 'config.json' ) ;
609
630
610
631
// Ensure the directory exists recursively
611
632
await fs . mkdir ( paths . config , { recursive : true } ) . catch ( ( ) =>
612
633
console . warn ( `Failed to create directory: ${ paths . config } ` )
613
634
) ;
614
635
615
- return activeFlagPath ;
616
- }
636
+ return configFilePath ;
637
+ }
617
638
618
- // This function will create or remove the active flag file
619
- async function setActiveFlag ( state ) {
620
- const activeFlagPath = await getActiveFlagPath ( ) ;
639
+ async function setLocalConfig ( state , paths ) {
640
+ const configFilePath = await getLocalConfigPath ( ) ;
621
641
622
642
if ( state ) {
623
- await fs . writeFile ( activeFlagPath , '' ) ;
643
+ const configData = {
644
+ workbenchHtmlPath : paths . workbenchHtmlPath ,
645
+ jsPath : paths . jsPath ,
646
+ electronJsPath : paths . electronJsPath
647
+ } ;
648
+ await fs . writeFile ( configFilePath , JSON . stringify ( configData , null , 2 ) , 'utf-8' ) ;
624
649
} else {
625
- await fs . unlink ( activeFlagPath ) . catch ( ( ) => { } ) ;
650
+ await fs . unlink ( configFilePath ) . catch ( ( ) => { } ) ;
626
651
}
627
- }
652
+ }
628
653
629
654
630
655
// #### main commands ######################################################
@@ -656,7 +681,11 @@ function activate(context) {
656
681
await changeVSCodeSettings ( ) ;
657
682
await checkColorTheme ( ) ;
658
683
await checkElectronDeprecatedType ( ) ;
659
- await setActiveFlag ( true ) ;
684
+ await setLocalConfig ( true , {
685
+ workbenchHtmlPath : HTMLFile ,
686
+ jsPath : JSFile ,
687
+ electronJsPath : ElectronJSFile
688
+ } ) ;
660
689
} catch ( error ) {
661
690
if ( error && ( error . code === 'EPERM' || error . code === 'EACCES' ) ) {
662
691
vscode . window . showInformationMessage ( localize ( 'messages.admin' ) + error ) ;
@@ -678,7 +707,7 @@ function activate(context) {
678
707
// uninstall old version
679
708
await fs . stat ( HTMLFile ) ;
680
709
await uninstallHTML ( ) ;
681
- await setActiveFlag ( false ) ;
710
+ await setLocalConfig ( false ) ;
682
711
} finally {
683
712
684
713
}
0 commit comments