Skip to content

Commit

Permalink
Add editorLineNumber context key (#176659)
Browse files Browse the repository at this point in the history
  • Loading branch information
joyceerhl authored Mar 9, 2023
1 parent 8aef575 commit b86be33
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit b86be33

Please sign in to comment.