From b86be33915e70c58e9f78b616210b0ebc29edd2e Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Thu, 9 Mar 2023 09:41:37 -0800 Subject: [PATCH] Add `editorLineNumber` context key (#176659) --- .../codeEditor/browser/editorLineNumberMenu.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/contrib/codeEditor/browser/editorLineNumberMenu.ts b/src/vs/workbench/contrib/codeEditor/browser/editorLineNumberMenu.ts index 8959bc97cbfa8..d7e5aff76ef63 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/editorLineNumberMenu.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/editorLineNumberMenu.ts @@ -62,21 +62,22 @@ export class EditorLineNumberContextMenu extends Disposable implements IEditorCo } public show(e: IEditorMouseEvent) { - // on macOS ctrl+click is interpreted as right click - if (!e.event.rightButton && !(isMacintosh && e.event.leftButton && e.event.ctrlKey)) { - return; - } - - const menu = this.menuService.createMenu(MenuId.EditorLineNumberContext, this.contextKeyService); - const model = this.editor.getModel(); - if (!e.target.position || !model || e.target.type !== MouseTargetType.GUTTER_LINE_NUMBERS && e.target.type !== MouseTargetType.GUTTER_GLYPH_MARGIN) { + + // on macOS ctrl+click is interpreted as right click + if (!e.event.rightButton && !(isMacintosh && e.event.leftButton && e.event.ctrlKey) + || e.target.type !== MouseTargetType.GUTTER_LINE_NUMBERS && e.target.type !== MouseTargetType.GUTTER_GLYPH_MARGIN + || !e.target.position || !model + ) { return; } const anchor = { x: e.event.posx, y: e.event.posy }; const lineNumber = e.target.position.lineNumber; + const contextKeyService = this.contextKeyService.createOverlay([['editorLineNumber', lineNumber]]); + const menu = this.menuService.createMenu(MenuId.EditorLineNumberContext, contextKeyService); + const actions: IAction[][] = []; this.instantiationService.invokeFunction(accessor => {