@@ -144,31 +144,59 @@ async function calculateRanges(
144144 ) ;
145145}
146146
147- export async function activate ( context : vscode . ExtensionContext ) {
147+ function loadSettings ( ) {
148148 const config = vscode . workspace . getConfiguration ( ) ;
149- let isEnabled = config . get < boolean > ( 'codeFader.enabled' ) ;
150- const isAutoUnfold = config . get < boolean > ( 'codeFader.autoUnfold' ) ;
149+
151150 const decorationSetting = Object . assign (
152151 {
153152 opacity : '0.2' ,
154153 backgroundColor : 'transparent' ,
155- border : 'none' ,
156154 } as vscode . ThemableDecorationRenderOptions ,
157155 config . get < vscode . ThemableDecorationRenderOptions > ( 'codeFader.decoration' )
158156 ) ;
159157 let codeDecoration =
160158 vscode . window . createTextEditorDecorationType ( decorationSetting ) ;
161159
160+ let isEnabled = config . get < boolean > ( 'codeFader.enabled' ) ;
161+ const isAutoUnfold = config . get < boolean > ( 'codeFader.autoUnfold' ) ;
162+
163+ return { isEnabled, codeDecoration, isAutoUnfold } ;
164+ }
165+
166+ function subscribeSelectionHighlightBorderChange (
167+ context : vscode . ExtensionContext
168+ ) {
169+ let isPromptVisible = false ;
170+
171+ async function showReloadPrompt ( ) {
172+ if ( isPromptVisible ) return ;
173+
174+ isPromptVisible = true ;
175+ const selection = await vscode . window . showInformationMessage (
176+ 'Configuration changes have been detected. Reload now?' ,
177+ 'Reload'
178+ ) ;
179+ isPromptVisible = false ;
180+
181+ if ( selection === 'Reload' ) {
182+ vscode . commands . executeCommand ( 'workbench.action.reloadWindow' ) ;
183+ }
184+ }
185+
186+ // Listen for Configuration Change Events
162187 context . subscriptions . push (
163188 vscode . workspace . onDidChangeConfiguration ( ( event ) => {
164189 if ( event . affectsConfiguration ( 'codeFader.enabled' ) ) {
165- const updatedValue = vscode . workspace
166- . getConfiguration ( )
167- . get < boolean > ( 'codeFader.enabled' ) ;
168- isEnabled = updatedValue ;
190+ showReloadPrompt ( ) ;
169191 }
170192 } )
171193 ) ;
194+ }
195+
196+ export async function activate ( context : vscode . ExtensionContext ) {
197+ subscribeSelectionHighlightBorderChange ( context ) ;
198+
199+ let { isEnabled, codeDecoration, isAutoUnfold } = loadSettings ( ) ;
172200
173201 let selectionVersion = 0 ;
174202
0 commit comments