mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-27 10:37:38 +01:00
Dynamically updates diff context to cause updates
Important for menu recalc based on diff contexts
This commit is contained in:
@@ -348,21 +348,19 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._diffComputationResult = null;
|
||||
|
||||
const leftContextKeyService = this._contextKeyService.createScoped();
|
||||
leftContextKeyService.createKey('isInDiffLeftEditor', true);
|
||||
|
||||
const leftServices = new ServiceCollection();
|
||||
leftServices.set(IContextKeyService, leftContextKeyService);
|
||||
const leftScopedInstantiationService = instantiationService.createChild(leftServices);
|
||||
|
||||
const rightContextKeyService = this._contextKeyService.createScoped();
|
||||
rightContextKeyService.createKey('isInDiffRightEditor', true);
|
||||
|
||||
const rightServices = new ServiceCollection();
|
||||
rightServices.set(IContextKeyService, rightContextKeyService);
|
||||
const rightScopedInstantiationService = instantiationService.createChild(rightServices);
|
||||
|
||||
this.originalEditor = this._createLeftHandSideEditor(options, leftScopedInstantiationService);
|
||||
this.modifiedEditor = this._createRightHandSideEditor(options, rightScopedInstantiationService);
|
||||
this.originalEditor = this._createLeftHandSideEditor(options, leftScopedInstantiationService, leftContextKeyService);
|
||||
this.modifiedEditor = this._createRightHandSideEditor(options, rightScopedInstantiationService, rightContextKeyService);
|
||||
|
||||
this._originalOverviewRuler = null;
|
||||
this._modifiedOverviewRuler = null;
|
||||
@@ -372,8 +370,6 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._containerDomElement.appendChild(this._reviewPane.shadow.domNode);
|
||||
this._containerDomElement.appendChild(this._reviewPane.actionBarContainer.domNode);
|
||||
|
||||
|
||||
|
||||
// enableSplitViewResizing
|
||||
this._enableSplitViewResizing = true;
|
||||
if (typeof options.enableSplitViewResizing !== 'undefined') {
|
||||
@@ -480,7 +476,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._layoutOverviewRulers();
|
||||
}
|
||||
|
||||
private _createLeftHandSideEditor(options: IDiffEditorOptions, instantiationService: IInstantiationService): CodeEditorWidget {
|
||||
private _createLeftHandSideEditor(options: IDiffEditorOptions, instantiationService: IInstantiationService, contextKeyService: IContextKeyService): CodeEditorWidget {
|
||||
const editor = this._createInnerEditor(instantiationService, this._originalDomNode, this._adjustOptionsForLeftHandSide(options, this._originalIsEditable, this._originalCodeLens));
|
||||
|
||||
this._register(editor.onDidScrollChange((e) => {
|
||||
@@ -510,10 +506,14 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
}
|
||||
}));
|
||||
|
||||
const isInDiffLeftEditorKey = contextKeyService.createKey<boolean>('isInDiffLeftEditor', undefined);
|
||||
this._register(Event.any(editor.onDidFocusEditorText, editor.onDidFocusEditorWidget)(() => isInDiffLeftEditorKey.set(true)));
|
||||
this._register(Event.any(editor.onDidBlurEditorText, editor.onDidBlurEditorWidget)(() => isInDiffLeftEditorKey.set(false)));
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
private _createRightHandSideEditor(options: IDiffEditorOptions, instantiationService: IInstantiationService): CodeEditorWidget {
|
||||
private _createRightHandSideEditor(options: IDiffEditorOptions, instantiationService: IInstantiationService, contextKeyService: IContextKeyService): CodeEditorWidget {
|
||||
const editor = this._createInnerEditor(instantiationService, this._modifiedDomNode, this._adjustOptionsForRightHandSide(options, this._modifiedCodeLens));
|
||||
|
||||
this._register(editor.onDidScrollChange((e) => {
|
||||
@@ -555,6 +555,10 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
}
|
||||
}));
|
||||
|
||||
const isInDiffRightEditorKey = contextKeyService.createKey<boolean>('isInDiffRightEditor', undefined);
|
||||
this._register(Event.any(editor.onDidFocusEditorText, editor.onDidFocusEditorWidget)(() => isInDiffRightEditorKey.set(true)));
|
||||
this._register(Event.any(editor.onDidBlurEditorText, editor.onDidBlurEditorWidget)(() => isInDiffRightEditorKey.set(false)));
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user