Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hediet authored Jul 4, 2023
1 parent 3df0903 commit 854108f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/vs/editor/browser/widget/codeEditorWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { editorErrorForeground, editorHintForeground, editorInfoForeground, edit
import { VerticalRevealType } from 'vs/editor/common/viewEvents';
import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { ContextKeyValue, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
Expand Down Expand Up @@ -1911,6 +1911,10 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
private removeDropIndicator(): void {
this._dropIntoEditorDecorations.clear();
}

public setContextValue(key: string, value: ContextKeyValue): void {
this._contextKeyService.createKey(key, value);
}
}

const enum BooleanEventValue {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { OverviewRulerPart } from 'vs/editor/browser/widget/diffEditorWidget2/ov
import { EditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { IContentSizeChangedEvent } from 'vs/editor/common/editorCommon';
import { localize } from 'vs/nls';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { DiffEditorOptions } from './diffEditorOptions';

Expand All @@ -30,7 +29,6 @@ export class DiffEditorEditors extends Disposable {
private readonly _options: DiffEditorOptions,
codeEditorWidgetOptions: IDiffCodeEditorWidgetOptions,
private readonly _createInnerEditor: (instantiationService: IInstantiationService, container: HTMLElement, options: Readonly<IEditorOptions>, editorWidgetOptions: ICodeEditorWidgetOptions) => CodeEditorWidget,
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
@IInstantiationService private readonly _instantiationService: IInstantiationService
) {
super();
Expand All @@ -56,17 +54,13 @@ export class DiffEditorEditors extends Disposable {

private _createLeftHandSideEditor(options: Readonly<IDiffEditorConstructionOptions>, codeEditorWidgetOptions: ICodeEditorWidgetOptions): CodeEditorWidget {
const editor = this._constructInnerEditor(this._instantiationService, this.originalEditorElement, this._adjustOptionsForLeftHandSide(options), codeEditorWidgetOptions);
const isInDiffLeftEditorKey = this._contextKeyService.createKey<boolean>('isInDiffLeftEditor', editor.hasWidgetFocus());
this._register(editor.onDidFocusEditorWidget(() => isInDiffLeftEditorKey.set(true)));
this._register(editor.onDidBlurEditorWidget(() => isInDiffLeftEditorKey.set(false)));
editor.setContextValue('isInDiffLeftEditor', true);
return editor;
}

private _createRightHandSideEditor(options: Readonly<IDiffEditorConstructionOptions>, codeEditorWidgetOptions: ICodeEditorWidgetOptions): CodeEditorWidget {
const editor = this._constructInnerEditor(this._instantiationService, this.modifiedEditorElement, this._adjustOptionsForRightHandSide(options), codeEditorWidgetOptions);
const isInDiffRightEditorKey = this._contextKeyService.createKey<boolean>('isInDiffRightEditor', editor.hasWidgetFocus());
this._register(editor.onDidFocusEditorWidget(() => isInDiffRightEditorKey.set(true)));
this._register(editor.onDidBlurEditorWidget(() => isInDiffRightEditorKey.set(false)));
editor.setContextValue('isInDiffRightEditor', true);
return editor;
}

Expand Down

0 comments on commit 854108f

Please sign in to comment.