提交 ddac9846 编写于 作者: S Sandeep Somavarapu

Fix #89339

上级 29f6ab04
......@@ -31,12 +31,12 @@ import { KeybindingParser } from 'vs/base/common/keybindingParser';
import { EditorOption } from 'vs/editor/common/config/editorOptions';
import { equals } from 'vs/base/common/arrays';
import { assertIsDefined } from 'vs/base/common/types';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { isEqual } from 'vs/base/common/resources';
const NLS_LAUNCH_MESSAGE = nls.localize('defineKeybinding.start', "Define Keybinding");
const NLS_KB_LAYOUT_ERROR_MESSAGE = nls.localize('defineKeybinding.kbLayoutErrorMessage', "You won't be able to produce this key combination under your current keyboard layout.");
const INTERESTING_FILE = /keybindings\.json$/;
export class DefineKeybindingController extends Disposable implements IEditorContribution {
public static readonly ID = 'editor.contrib.defineKeybinding';
......@@ -50,7 +50,8 @@ export class DefineKeybindingController extends Disposable implements IEditorCon
constructor(
private _editor: ICodeEditor,
@IInstantiationService private readonly _instantiationService: IInstantiationService
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@IEnvironmentService private readonly _environmentService: IEnvironmentService
) {
super();
......@@ -69,7 +70,7 @@ export class DefineKeybindingController extends Disposable implements IEditorCon
}
private _update(): void {
if (!isInterestingEditorModel(this._editor)) {
if (!isInterestingEditorModel(this._editor, this._environmentService)) {
this._disposeKeybindingWidgetRenderer();
this._disposeKeybindingDecorationRenderer();
return;
......@@ -363,7 +364,7 @@ class DefineKeybindingCommand extends EditorCommand {
}
runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor): void {
if (!isInterestingEditorModel(editor) || editor.getOption(EditorOption.readOnly)) {
if (!isInterestingEditorModel(editor, accessor.get(IEnvironmentService)) || editor.getOption(EditorOption.readOnly)) {
return;
}
const controller = DefineKeybindingController.get(editor);
......@@ -373,13 +374,12 @@ class DefineKeybindingCommand extends EditorCommand {
}
}
function isInterestingEditorModel(editor: ICodeEditor): boolean {
function isInterestingEditorModel(editor: ICodeEditor, environmentService: IEnvironmentService): boolean {
const model = editor.getModel();
if (!model) {
return false;
}
const url = model.uri.toString();
return INTERESTING_FILE.test(url);
return isEqual(model.uri, environmentService.keybindingsResource);
}
registerEditorContribution(DefineKeybindingController.ID, DefineKeybindingController);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册