Skip to content

Commit 073a3d9

Browse files
committed
Don't allow context menu when no terminals exist
Fixes microsoft#107655
1 parent eb4f908 commit 073a3d9

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/vs/workbench/contrib/terminal/browser/terminalTabbedView.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -340,25 +340,19 @@ export class TerminalTabbedView extends Disposable {
340340
event.stopPropagation();
341341
}));
342342
this._register(dom.addDisposableListener(terminalContainer, 'mousedown', async (event: MouseEvent) => {
343-
if (this._terminalGroupService.instances.length === 0) {
343+
const terminal = this._terminalGroupService.activeInstance;
344+
if (this._terminalGroupService.instances.length === 0 || !terminal) {
345+
this._cancelContextMenu = true;
344346
return;
345347
}
346348

347349
if (event.which === 2 && isLinux) {
348350
// Drop selection and focus terminal on Linux to enable middle button paste when click
349351
// occurs on the selection itself.
350-
const terminal = this._terminalGroupService.activeInstance;
351-
if (terminal) {
352-
terminal.focus();
353-
}
352+
terminal.focus();
354353
} else if (event.which === 3) {
355354
const rightClickBehavior = this._terminalService.configHelper.config.rightClickBehavior;
356355
if (rightClickBehavior === 'copyPaste' || rightClickBehavior === 'paste') {
357-
const terminal = this._terminalGroupService.activeInstance;
358-
if (!terminal) {
359-
return;
360-
}
361-
362356
// copyPaste: Shift+right click should open context menu
363357
if (rightClickBehavior === 'copyPaste' && event.shiftKey) {
364358
openContextMenu(event, this._parentElement, this._instanceMenu, this._contextMenuService);

0 commit comments

Comments
 (0)