Skip to content

Commit

Permalink
right click context menu for inline diff actions
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Sep 3, 2019
1 parent 13b681e commit cd3481d
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions src/vs/editor/browser/widget/inlineDiffMargin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,12 @@ export class InlineDiffMargin extends Disposable {
}));
}

this._register(dom.addStandardDisposableListener(this._diffActions, 'mousedown', e => {
const { top, height } = dom.getDomNodePagePosition(this._diffActions);
let pad = Math.floor(lineHeight / 3);
e.preventDefault();
const showContextMenu = (x: number, y: number) => {
this._contextMenuService.showContextMenu({
getAnchor: () => {
return {
x: e.posx,
y: top + height + pad
x,
y
};
},
getActions: () => {
Expand All @@ -141,6 +138,15 @@ export class InlineDiffMargin extends Disposable {
},
autoSelectFirstItem: true
});
};

this._register(dom.addStandardDisposableListener(this._diffActions, 'mousedown', e => {
const { top, height } = dom.getDomNodePagePosition(this._diffActions);
let pad = Math.floor(lineHeight / 3);
e.preventDefault();

showContextMenu(e.posx, top + height + pad);

}));

this._register(editor.onMouseMove((e: editorBrowser.IEditorMouseEvent) => {
Expand All @@ -157,6 +163,22 @@ export class InlineDiffMargin extends Disposable {
this.visibility = false;
}
}));

this._register(editor.onMouseDown((e: editorBrowser.IEditorMouseEvent) => {
if (!e.event.rightButton) {
return;
}

if (e.target.type === editorBrowser.MouseTargetType.CONTENT_VIEW_ZONE || e.target.type === editorBrowser.MouseTargetType.GUTTER_VIEW_ZONE) {
const viewZoneId = e.target.detail.viewZoneId;

if (viewZoneId === this._viewZoneId) {
e.event.preventDefault();
currentLineNumberOffset = this._updateLightBulbPosition(this._marginDomNode, e.event.browserEvent.y, lineHeight);
showContextMenu(e.event.posx, e.event.posy + lineHeight);
}
}
}));
}

private _updateLightBulbPosition(marginDomNode: HTMLElement, y: number, lineHeight: number): number {
Expand Down

0 comments on commit cd3481d

Please sign in to comment.