Skip to content

Commit 368c536

Browse files
author
Benjamin Pasero
committed
1 parent 0786a41 commit 368c536

5 files changed

Lines changed: 20 additions & 29 deletions

File tree

src/vs/base/browser/dom.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ export function isHTMLElement(o: any): o is HTMLElement {
820820
export const EventType = {
821821
// Mouse
822822
CLICK: 'click',
823+
AUXCLICK: 'auxclick',
823824
DBLCLICK: 'dblclick',
824825
MOUSE_UP: 'mouseup',
825826
MOUSE_DOWN: 'mousedown',

src/vs/workbench/browser/parts/editor/editorGroupView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
275275
}));
276276

277277
// Close empty editor group via middle mouse click
278-
this._register(addDisposableListener(this.element, EventType.MOUSE_UP, e => {
278+
this._register(addDisposableListener(this.element, EventType.AUXCLICK, e => {
279279
if (this.isEmpty && e.button === 1 /* Middle Button */) {
280-
EventHelper.stop(e);
280+
EventHelper.stop(e, true);
281281

282282
this.accessor.removeGroup(this);
283283
}

src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ export class NoTabsTitleControl extends TitleControl {
6767
this._register(addDisposableListener(titleContainer, EventType.DBLCLICK, (e: MouseEvent) => this.onTitleDoubleClick(e)));
6868

6969
// Detect mouse click
70-
this._register(addDisposableListener(titleContainer, EventType.MOUSE_UP, (e: MouseEvent) => this.onTitleClick(e)));
70+
this._register(addDisposableListener(titleContainer, EventType.AUXCLICK, (e: MouseEvent) => this.onTitleAuxClick(e)));
7171

7272
// Detect touch
73-
this._register(addDisposableListener(titleContainer, TouchEventType.Tap, (e: GestureEvent) => this.onTitleClick(e)));
73+
this._register(addDisposableListener(titleContainer, TouchEventType.Tap, (e: GestureEvent) => this.onTitleTap(e)));
7474

7575
// Context Menu
7676
this._register(addDisposableListener(titleContainer, EventType.CONTEXT_MENU, (e: Event) => {
@@ -98,25 +98,21 @@ export class NoTabsTitleControl extends TitleControl {
9898
this.group.pinEditor();
9999
}
100100

101-
private onTitleClick(e: MouseEvent | GestureEvent): void {
102-
if (e instanceof MouseEvent) {
103-
// Close editor on middle mouse click
104-
if (e.button === 1 /* Middle Button */) {
105-
EventHelper.stop(e, true /* for https://github.com/Microsoft/vscode/issues/56715 */);
101+
private onTitleAuxClick(e: MouseEvent): void {
102+
if (e.button === 1 /* Middle Button */ && this.group.activeEditor) {
103+
EventHelper.stop(e, true /* for https://github.com/Microsoft/vscode/issues/56715 */);
106104

107-
if (this.group.activeEditor) {
108-
this.group.closeEditor(this.group.activeEditor);
109-
}
110-
}
111-
} else {
112-
// TODO@rebornix
113-
// gesture tap should open the quick access
114-
// editorGroupView will focus on the editor again when there are mouse/pointer/touch down events
115-
// we need to wait a bit as `GesureEvent.Tap` is generated from `touchstart` and then `touchend` evnets, which are not an atom event.
116-
setTimeout(() => this.quickInputService.quickAccess.show(), 50);
105+
this.group.closeEditor(this.group.activeEditor);
117106
}
118107
}
119108

109+
private onTitleTap(e: GestureEvent): void {
110+
// TODO@rebornix gesture tap should open the quick access
111+
// editorGroupView will focus on the editor again when there are mouse/pointer/touch down events
112+
// we need to wait a bit as `GesureEvent.Tap` is generated from `touchstart` and then `touchend` evnets, which are not an atom event.
113+
setTimeout(() => this.quickInputService.quickAccess.show(), 50);
114+
}
115+
120116
getPreferredHeight(): number {
121117
return EDITOR_TITLE_HEIGHT;
122118
}

src/vs/workbench/browser/parts/editor/tabsTitleControl.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,6 @@ export class TabsTitleControl extends TitleControl {
601601
const disposables = new DisposableStore();
602602

603603
const handleClickOrTouch = (e: MouseEvent | GestureEvent): void => {
604-
tab.blur();
605-
606604
if (e instanceof MouseEvent && e.button !== 0) {
607605
if (e.button === 1) {
608606
e.preventDefault(); // required to prevent auto-scrolling (https://github.com/Microsoft/vscode/issues/16690)
@@ -643,13 +641,9 @@ export class TabsTitleControl extends TitleControl {
643641
}));
644642

645643
// Close on mouse middle click
646-
disposables.add(addDisposableListener(tab, EventType.MOUSE_UP, (e: MouseEvent) => {
647-
EventHelper.stop(e);
648-
649-
tab.blur();
650-
644+
disposables.add(addDisposableListener(tab, EventType.AUXCLICK, (e: MouseEvent) => {
651645
if (e.button === 1 /* Middle Button*/) {
652-
e.stopPropagation(); // for https://github.com/Microsoft/vscode/issues/56715
646+
EventHelper.stop(e, true /* for https://github.com/Microsoft/vscode/issues/56715 */);
653647

654648
this.blockRevealActiveTabOnce();
655649
this.closeOneEditorAction.run({ groupId: this.group.id, editorIndex: index });

src/vs/workbench/browser/parts/notifications/notificationsViewer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,9 @@ export class NotificationTemplateRenderer extends Disposable {
307307

308308
// Container
309309
toggleClass(this.template.container, 'expanded', notification.expanded);
310-
this.inputDisposables.add(addDisposableListener(this.template.container, EventType.MOUSE_UP, e => {
310+
this.inputDisposables.add(addDisposableListener(this.template.container, EventType.AUXCLICK, e => {
311311
if (!notification.hasProgress && e.button === 1 /* Middle Button */) {
312-
EventHelper.stop(e);
312+
EventHelper.stop(e, true);
313313

314314
notification.close();
315315
}

0 commit comments

Comments
 (0)