55
66import { Event } from 'vs/base/common/event' ;
77import { Lazy } from 'vs/base/common/lazy' ;
8- import { IDisposable } from 'vs/base/common/lifecycle' ;
8+ import { DisposableStore , IDisposable } from 'vs/base/common/lifecycle' ;
99import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
1010import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService' ;
1111import { StableEditorScrollState } from 'vs/editor/browser/stableEditorScroll' ;
@@ -17,9 +17,10 @@ import { IEditorDecorationsCollection } from 'vs/editor/common/editorCommon';
1717import { ICursorStateComputer , IModelDecorationOptions , IModelDeltaDecoration , ITextModel , IValidEditOperation } from 'vs/editor/common/model' ;
1818import { IEditorWorkerService } from 'vs/editor/common/services/editorWorker' ;
1919import { localize } from 'vs/nls' ;
20+ import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
2021import { IContextKey , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
2122import { IInstantiationService , ServicesAccessor } from 'vs/platform/instantiation/common/instantiation' ;
22- import { IStorageService , StorageScope , StorageTarget } from 'vs/platform/storage/common/storage' ;
23+ import { IStorageService } from 'vs/platform/storage/common/storage' ;
2324import { InlineChatFileCreatePreviewWidget , InlineChatLivePreviewWidget } from 'vs/workbench/contrib/inlineChat/browser/inlineChatLivePreviewWidget' ;
2425import { EditResponse , Session } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession' ;
2526import { InlineChatWidget } from 'vs/workbench/contrib/inlineChat/browser/inlineChatWidget' ;
@@ -222,11 +223,12 @@ class InlineDiffDecorations {
222223
223224export class LiveStrategy extends EditModeStrategy {
224225
225- private static _inlineDiffStorageKey : string = 'interactiveEditor.storage.inlineDiff' ;
226226 protected _diffEnabled : boolean = false ;
227227
228228 private readonly _inlineDiffDecorations : InlineDiffDecorations ;
229229 private readonly _ctxShowingDiff : IContextKey < boolean > ;
230+ private readonly _store : DisposableStore = new DisposableStore ( ) ;
231+
230232 private _lastResponse ?: EditResponse ;
231233 private _editCount : number = 0 ;
232234
@@ -235,29 +237,36 @@ export class LiveStrategy extends EditModeStrategy {
235237 protected readonly _editor : ICodeEditor ,
236238 protected readonly _widget : InlineChatWidget ,
237239 @IContextKeyService contextKeyService : IContextKeyService ,
240+ @IConfigurationService configService : IConfigurationService ,
238241 @IStorageService protected _storageService : IStorageService ,
239242 @IBulkEditService protected readonly _bulkEditService : IBulkEditService ,
240243 @IEditorWorkerService protected readonly _editorWorkerService : IEditorWorkerService ,
241244 @IInstantiationService private readonly _instaService : IInstantiationService ,
242245 ) {
243246 super ( ) ;
244- this . _diffEnabled = _storageService . getBoolean ( LiveStrategy . _inlineDiffStorageKey , StorageScope . PROFILE , true ) ;
247+ this . _diffEnabled = configService . getValue < boolean > ( 'inlineChat.showDiff' ) ;
245248
246249 this . _inlineDiffDecorations = new InlineDiffDecorations ( this . _editor , this . _diffEnabled ) ;
247250 this . _ctxShowingDiff = CTX_INLINE_CHAT_SHOWING_DIFF . bindTo ( contextKeyService ) ;
248251 this . _ctxShowingDiff . set ( this . _diffEnabled ) ;
249252 this . _inlineDiffDecorations . visible = this . _diffEnabled ;
253+
254+ this . _store . add ( configService . onDidChangeConfiguration ( e => {
255+ if ( e . affectsConfiguration ( 'inlineChat.showDiff' ) ) {
256+ this . toggleDiff ( ) ;
257+ }
258+ } ) ) ;
250259 }
251260
252261 override dispose ( ) : void {
253262 this . _inlineDiffDecorations . clear ( ) ;
254263 this . _ctxShowingDiff . reset ( ) ;
264+ this . _store . dispose ( ) ;
255265 }
256266
257267 toggleDiff ( ) : void {
258268 this . _diffEnabled = ! this . _diffEnabled ;
259269 this . _ctxShowingDiff . set ( this . _diffEnabled ) ;
260- this . _storageService . store ( LiveStrategy . _inlineDiffStorageKey , this . _diffEnabled , StorageScope . PROFILE , StorageTarget . USER ) ;
261270 this . _doToggleDiff ( ) ;
262271 }
263272
@@ -384,12 +393,13 @@ export class LivePreviewStrategy extends LiveStrategy {
384393 editor : ICodeEditor ,
385394 widget : InlineChatWidget ,
386395 @IContextKeyService contextKeyService : IContextKeyService ,
396+ @IConfigurationService configService : IConfigurationService ,
387397 @IStorageService storageService : IStorageService ,
388398 @IBulkEditService bulkEditService : IBulkEditService ,
389399 @IEditorWorkerService editorWorkerService : IEditorWorkerService ,
390400 @IInstantiationService instaService : IInstantiationService ,
391401 ) {
392- super ( session , editor , widget , contextKeyService , storageService , bulkEditService , editorWorkerService , instaService ) ;
402+ super ( session , editor , widget , contextKeyService , configService , storageService , bulkEditService , editorWorkerService , instaService ) ;
393403
394404 this . _diffZone = new Lazy ( ( ) => instaService . createInstance ( InlineChatLivePreviewWidget , editor , session ) ) ;
395405 this . _previewZone = new Lazy ( ( ) => instaService . createInstance ( InlineChatFileCreatePreviewWidget , editor ) ) ;
0 commit comments