Skip to content

Commit 3a6966f

Browse files
authored
Merge pull request microsoft#104953 from microsoft/eamodio/diff-context
2 parents 33027a2 + b4eb8cf commit 3a6966f

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/vs/editor/browser/widget/diffEditorWidget.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,21 +351,19 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
351351
this._diffComputationResult = null;
352352

353353
const leftContextKeyService = this._contextKeyService.createScoped();
354-
leftContextKeyService.createKey('isInDiffLeftEditor', true);
355354

356355
const leftServices = new ServiceCollection();
357356
leftServices.set(IContextKeyService, leftContextKeyService);
358357
const leftScopedInstantiationService = instantiationService.createChild(leftServices);
359358

360359
const rightContextKeyService = this._contextKeyService.createScoped();
361-
rightContextKeyService.createKey('isInDiffRightEditor', true);
362360

363361
const rightServices = new ServiceCollection();
364362
rightServices.set(IContextKeyService, rightContextKeyService);
365363
const rightScopedInstantiationService = instantiationService.createChild(rightServices);
366364

367-
this.originalEditor = this._createLeftHandSideEditor(options, leftScopedInstantiationService);
368-
this.modifiedEditor = this._createRightHandSideEditor(options, rightScopedInstantiationService);
365+
this.originalEditor = this._createLeftHandSideEditor(options, leftScopedInstantiationService, leftContextKeyService);
366+
this.modifiedEditor = this._createRightHandSideEditor(options, rightScopedInstantiationService, rightContextKeyService);
369367

370368
this._originalOverviewRuler = null;
371369
this._modifiedOverviewRuler = null;
@@ -375,8 +373,6 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
375373
this._containerDomElement.appendChild(this._reviewPane.shadow.domNode);
376374
this._containerDomElement.appendChild(this._reviewPane.actionBarContainer.domNode);
377375

378-
379-
380376
// enableSplitViewResizing
381377
this._enableSplitViewResizing = true;
382378
if (typeof options.enableSplitViewResizing !== 'undefined') {
@@ -487,7 +483,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
487483
this._layoutOverviewRulers();
488484
}
489485

490-
private _createLeftHandSideEditor(options: editorBrowser.IDiffEditorConstructionOptions, instantiationService: IInstantiationService): CodeEditorWidget {
486+
private _createLeftHandSideEditor(options: editorBrowser.IDiffEditorConstructionOptions, instantiationService: IInstantiationService, contextKeyService: IContextKeyService): CodeEditorWidget {
491487
const editor = this._createInnerEditor(instantiationService, this._originalDomNode, this._adjustOptionsForLeftHandSide(options, this._originalIsEditable, this._originalCodeLens));
492488

493489
this._register(editor.onDidScrollChange((e) => {
@@ -517,6 +513,10 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
517513
}
518514
}));
519515

516+
const isInDiffLeftEditorKey = contextKeyService.createKey<boolean>('isInDiffLeftEditor', undefined);
517+
this._register(editor.onDidFocusEditorWidget(() => isInDiffLeftEditorKey.set(true)));
518+
this._register(editor.onDidBlurEditorWidget(() => isInDiffLeftEditorKey.set(false)));
519+
520520
this._register(editor.onDidContentSizeChange(e => {
521521
const width = this.originalEditor.getContentWidth() + this.modifiedEditor.getContentWidth() + DiffEditorWidget.ONE_OVERVIEW_WIDTH;
522522
const height = Math.max(this.modifiedEditor.getContentHeight(), this.originalEditor.getContentHeight());
@@ -532,7 +532,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
532532
return editor;
533533
}
534534

535-
private _createRightHandSideEditor(options: editorBrowser.IDiffEditorConstructionOptions, instantiationService: IInstantiationService): CodeEditorWidget {
535+
private _createRightHandSideEditor(options: editorBrowser.IDiffEditorConstructionOptions, instantiationService: IInstantiationService, contextKeyService: IContextKeyService): CodeEditorWidget {
536536
const editor = this._createInnerEditor(instantiationService, this._modifiedDomNode, this._adjustOptionsForRightHandSide(options, this._modifiedCodeLens));
537537

538538
this._register(editor.onDidScrollChange((e) => {
@@ -574,6 +574,10 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
574574
}
575575
}));
576576

577+
const isInDiffRightEditorKey = contextKeyService.createKey<boolean>('isInDiffRightEditor', undefined);
578+
this._register(editor.onDidFocusEditorWidget(() => isInDiffRightEditorKey.set(true)));
579+
this._register(editor.onDidBlurEditorWidget(() => isInDiffRightEditorKey.set(false)));
580+
577581
this._register(editor.onDidContentSizeChange(e => {
578582
const width = this.originalEditor.getContentWidth() + this.modifiedEditor.getContentWidth() + DiffEditorWidget.ONE_OVERVIEW_WIDTH;
579583
const height = Math.max(this.modifiedEditor.getContentHeight(), this.originalEditor.getContentHeight());

0 commit comments

Comments
 (0)