mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-18 01:20:52 +01:00
Move management of inDiffEditor to the other editor context keys
This commit is contained in:
@@ -1720,6 +1720,7 @@ class EditorContextKeysManager extends Disposable {
|
||||
private readonly _editorTextFocus: IContextKey<boolean>;
|
||||
private readonly _editorTabMovesFocus: IContextKey<boolean>;
|
||||
private readonly _editorReadonly: IContextKey<boolean>;
|
||||
private readonly _inDiffEditor: IContextKey<boolean>;
|
||||
private readonly _editorColumnSelection: IContextKey<boolean>;
|
||||
private readonly _hasMultipleSelections: IContextKey<boolean>;
|
||||
private readonly _hasNonEmptySelection: IContextKey<boolean>;
|
||||
@@ -1742,6 +1743,7 @@ class EditorContextKeysManager extends Disposable {
|
||||
this._editorTextFocus = EditorContextKeys.editorTextFocus.bindTo(contextKeyService);
|
||||
this._editorTabMovesFocus = EditorContextKeys.tabMovesFocus.bindTo(contextKeyService);
|
||||
this._editorReadonly = EditorContextKeys.readOnly.bindTo(contextKeyService);
|
||||
this._inDiffEditor = EditorContextKeys.inDiffEditor.bindTo(contextKeyService);
|
||||
this._editorColumnSelection = EditorContextKeys.columnSelection.bindTo(contextKeyService);
|
||||
this._hasMultipleSelections = EditorContextKeys.hasMultipleSelections.bindTo(contextKeyService);
|
||||
this._hasNonEmptySelection = EditorContextKeys.hasNonEmptySelection.bindTo(contextKeyService);
|
||||
@@ -1770,6 +1772,7 @@ class EditorContextKeysManager extends Disposable {
|
||||
|
||||
this._editorTabMovesFocus.set(options.get(EditorOption.tabFocusMode));
|
||||
this._editorReadonly.set(options.get(EditorOption.readOnly));
|
||||
this._inDiffEditor.set(options.get(EditorOption.inDiffEditor));
|
||||
this._editorColumnSelection.set(options.get(EditorOption.columnSelection));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ export namespace EditorContextKeys {
|
||||
export const textInputFocus = new RawContextKey<boolean>('textInputFocus', false);
|
||||
|
||||
export const readOnly = new RawContextKey<boolean>('editorReadonly', false);
|
||||
export const inDiffEditor = new RawContextKey<boolean>('inDiffEditor', false);
|
||||
export const columnSelection = new RawContextKey<boolean>('editorColumnSelection', false);
|
||||
export const writable = readOnly.toNegated();
|
||||
export const hasNonEmptySelection = new RawContextKey<boolean>('editorHasSelection', false);
|
||||
|
||||
@@ -19,11 +19,11 @@ import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/commo
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { DefaultSettingsEditorContribution } from 'vs/workbench/contrib/preferences/browser/preferencesEditor';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
|
||||
const transientWordWrapState = 'transientWordWrapState';
|
||||
const isWordWrapMinifiedKey = 'isWordWrapMinified';
|
||||
const isDominatedByLongLinesKey = 'isDominatedByLongLines';
|
||||
const inDiffEditorKey = 'inDiffEditor';
|
||||
|
||||
/**
|
||||
* State written/read by the toggle word wrap action and associated with a particular model.
|
||||
@@ -179,7 +179,6 @@ class ToggleWordWrapController extends Disposable implements IEditorContribution
|
||||
const wrappingInfo = options.get(EditorOption.wrappingInfo);
|
||||
const isWordWrapMinified = this.contextKeyService.createKey(isWordWrapMinifiedKey, wrappingInfo.isWordWrapMinified);
|
||||
const isDominatedByLongLines = this.contextKeyService.createKey(isDominatedByLongLinesKey, wrappingInfo.isDominatedByLongLines);
|
||||
const inDiffEditor = this.contextKeyService.createKey(inDiffEditorKey, options.get(EditorOption.inDiffEditor));
|
||||
let currentlyApplyingEditorConfig = false;
|
||||
|
||||
this._register(editor.onDidChangeConfiguration((e) => {
|
||||
@@ -190,7 +189,6 @@ class ToggleWordWrapController extends Disposable implements IEditorContribution
|
||||
const wrappingInfo = options.get(EditorOption.wrappingInfo);
|
||||
isWordWrapMinified.set(wrappingInfo.isWordWrapMinified);
|
||||
isDominatedByLongLines.set(wrappingInfo.isDominatedByLongLines);
|
||||
inDiffEditor.set(options.get(EditorOption.inDiffEditor));
|
||||
if (!currentlyApplyingEditorConfig) {
|
||||
// I am not the cause of the word wrap getting changed
|
||||
ensureWordWrapSettings();
|
||||
@@ -282,7 +280,6 @@ MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
|
||||
group: 'navigation',
|
||||
order: 1,
|
||||
when: ContextKeyExpr.and(
|
||||
ContextKeyExpr.not(inDiffEditorKey),
|
||||
ContextKeyExpr.has(isDominatedByLongLinesKey),
|
||||
ContextKeyExpr.has(isWordWrapMinifiedKey)
|
||||
)
|
||||
@@ -298,7 +295,7 @@ MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
|
||||
group: 'navigation',
|
||||
order: 1,
|
||||
when: ContextKeyExpr.and(
|
||||
ContextKeyExpr.not(inDiffEditorKey),
|
||||
EditorContextKeys.inDiffEditor.negate(),
|
||||
ContextKeyExpr.has(isDominatedByLongLinesKey),
|
||||
ContextKeyExpr.not(isWordWrapMinifiedKey)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user