mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Merge pull request #136633 from marvinthepa/terminal-middle-paste
Middle-click paste in terminal on non-Linux
This commit is contained in:
commit
bd05f055e1
|
@ -75,6 +75,7 @@ export const enum TerminalSettingId {
|
||||||
TerminalTitle = 'terminal.integrated.tabs.title',
|
TerminalTitle = 'terminal.integrated.tabs.title',
|
||||||
TerminalDescription = 'terminal.integrated.tabs.description',
|
TerminalDescription = 'terminal.integrated.tabs.description',
|
||||||
RightClickBehavior = 'terminal.integrated.rightClickBehavior',
|
RightClickBehavior = 'terminal.integrated.rightClickBehavior',
|
||||||
|
MiddleClickBehavior = 'terminal.integrated.middleClickBehavior',
|
||||||
Cwd = 'terminal.integrated.cwd',
|
Cwd = 'terminal.integrated.cwd',
|
||||||
ConfirmOnExit = 'terminal.integrated.confirmOnExit',
|
ConfirmOnExit = 'terminal.integrated.confirmOnExit',
|
||||||
ConfirmOnKill = 'terminal.integrated.confirmOnKill',
|
ConfirmOnKill = 'terminal.integrated.confirmOnKill',
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { TerminalEditorInput } from 'vs/workbench/contrib/terminal/browser/termi
|
||||||
import { getTerminalActionBarArgs } from 'vs/workbench/contrib/terminal/browser/terminalMenus';
|
import { getTerminalActionBarArgs } from 'vs/workbench/contrib/terminal/browser/terminalMenus';
|
||||||
import { ITerminalProfileResolverService, ITerminalProfileService, TerminalCommandId } from 'vs/workbench/contrib/terminal/common/terminal';
|
import { ITerminalProfileResolverService, ITerminalProfileService, TerminalCommandId } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||||
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
|
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||||
import { isLinux, isMacintosh } from 'vs/base/common/platform';
|
import { isMacintosh } from 'vs/base/common/platform';
|
||||||
import { BrowserFeatures } from 'vs/base/browser/canIUse';
|
import { BrowserFeatures } from 'vs/base/browser/canIUse';
|
||||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||||
import { openContextMenu } from 'vs/workbench/contrib/terminal/browser/terminalContextMenu';
|
import { openContextMenu } from 'vs/workbench/contrib/terminal/browser/terminalContextMenu';
|
||||||
|
@ -123,15 +123,23 @@ export class TerminalEditor extends EditorPane {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._register(dom.addDisposableListener(this._editorInstanceElement, 'mousedown', async (event: MouseEvent) => {
|
this._register(dom.addDisposableListener(this._editorInstanceElement, 'mousedown', async (event: MouseEvent) => {
|
||||||
if (this._terminalEditorService.instances.length === 0) {
|
const terminal = this._terminalEditorService.activeInstance;
|
||||||
|
if (this._terminalEditorService.instances.length === 0 || !terminal) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.which === 2 && isLinux) {
|
if (event.which === 2) {
|
||||||
// Drop selection and focus terminal on Linux to enable middle button paste when click
|
switch (this._terminalConfigurationService.config.middleClickBehavior) {
|
||||||
// occurs on the selection itself.
|
case 'paste':
|
||||||
const terminal = this._terminalEditorService.activeInstance;
|
terminal.paste();
|
||||||
terminal?.focus();
|
break;
|
||||||
|
case 'default':
|
||||||
|
default:
|
||||||
|
// Drop selection and focus terminal on Linux to enable middle button paste
|
||||||
|
// when click occurs on the selection itself.
|
||||||
|
terminal.focus();
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else if (event.which === 3) {
|
} else if (event.which === 3) {
|
||||||
const rightClickBehavior = this._terminalConfigurationService.config.rightClickBehavior;
|
const rightClickBehavior = this._terminalConfigurationService.config.rightClickBehavior;
|
||||||
if (rightClickBehavior === 'nothing') {
|
if (rightClickBehavior === 'nothing') {
|
||||||
|
@ -141,11 +149,6 @@ export class TerminalEditor extends EditorPane {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (rightClickBehavior === 'copyPaste' || rightClickBehavior === 'paste') {
|
else if (rightClickBehavior === 'copyPaste' || rightClickBehavior === 'paste') {
|
||||||
const terminal = this._terminalEditorService.activeInstance;
|
|
||||||
if (!terminal) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// copyPaste: Shift+right click should open context menu
|
// copyPaste: Shift+right click should open context menu
|
||||||
if (rightClickBehavior === 'copyPaste' && event.shiftKey) {
|
if (rightClickBehavior === 'copyPaste' && event.shiftKey) {
|
||||||
openContextMenu(this.window, event, this._editorInput?.terminalInstance, this._instanceMenu, this._contextMenuService);
|
openContextMenu(this.window, event, this._editorInput?.terminalInstance, this._instanceMenu, this._contextMenuService);
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { ITerminalConfigurationService, ITerminalGroupService, ITerminalInstance, ITerminalService, TerminalConnectionState } from 'vs/workbench/contrib/terminal/browser/terminal';
|
import { ITerminalConfigurationService, ITerminalGroupService, ITerminalInstance, ITerminalService, TerminalConnectionState } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||||
import { TerminalTabsListSizes, TerminalTabList } from 'vs/workbench/contrib/terminal/browser/terminalTabsList';
|
import { TerminalTabsListSizes, TerminalTabList } from 'vs/workbench/contrib/terminal/browser/terminalTabsList';
|
||||||
import { isLinux, isMacintosh } from 'vs/base/common/platform';
|
import { isMacintosh } from 'vs/base/common/platform';
|
||||||
import * as dom from 'vs/base/browser/dom';
|
import * as dom from 'vs/base/browser/dom';
|
||||||
import { BrowserFeatures } from 'vs/base/browser/canIUse';
|
import { BrowserFeatures } from 'vs/base/browser/canIUse';
|
||||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||||
|
@ -339,10 +339,18 @@ export class TerminalTabbedView extends Disposable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.which === 2 && isLinux) {
|
if (event.which === 2) {
|
||||||
// Drop selection and focus terminal on Linux to enable middle button paste when click
|
switch (this._terminalConfigurationService.config.middleClickBehavior) {
|
||||||
// occurs on the selection itself.
|
case 'paste':
|
||||||
terminal.focus();
|
terminal.paste();
|
||||||
|
break;
|
||||||
|
case 'default':
|
||||||
|
default:
|
||||||
|
// Drop selection and focus terminal on Linux to enable middle button paste
|
||||||
|
// when click occurs on the selection itself.
|
||||||
|
terminal.focus();
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else if (event.which === 3) {
|
} else if (event.which === 3) {
|
||||||
const rightClickBehavior = this._terminalConfigurationService.config.rightClickBehavior;
|
const rightClickBehavior = this._terminalConfigurationService.config.rightClickBehavior;
|
||||||
if (rightClickBehavior === 'nothing') {
|
if (rightClickBehavior === 'nothing') {
|
||||||
|
|
|
@ -137,6 +137,7 @@ export interface ITerminalConfiguration {
|
||||||
macOptionClickForcesSelection: boolean;
|
macOptionClickForcesSelection: boolean;
|
||||||
gpuAcceleration: 'auto' | 'on' | 'canvas' | 'off';
|
gpuAcceleration: 'auto' | 'on' | 'canvas' | 'off';
|
||||||
rightClickBehavior: 'default' | 'copyPaste' | 'paste' | 'selectWord' | 'nothing';
|
rightClickBehavior: 'default' | 'copyPaste' | 'paste' | 'selectWord' | 'nothing';
|
||||||
|
middleClickBehavior: 'default' | 'paste';
|
||||||
cursorBlinking: boolean;
|
cursorBlinking: boolean;
|
||||||
cursorStyle: 'block' | 'underline' | 'line';
|
cursorStyle: 'block' | 'underline' | 'line';
|
||||||
cursorStyleInactive: 'outline' | 'block' | 'underline' | 'line' | 'none';
|
cursorStyleInactive: 'outline' | 'block' | 'underline' | 'line' | 'none';
|
||||||
|
|
|
@ -334,6 +334,16 @@ const terminalConfiguration: IConfigurationNode = {
|
||||||
default: isMacintosh ? 'selectWord' : isWindows ? 'copyPaste' : 'default',
|
default: isMacintosh ? 'selectWord' : isWindows ? 'copyPaste' : 'default',
|
||||||
description: localize('terminal.integrated.rightClickBehavior', "Controls how terminal reacts to right click.")
|
description: localize('terminal.integrated.rightClickBehavior', "Controls how terminal reacts to right click.")
|
||||||
},
|
},
|
||||||
|
[TerminalSettingId.MiddleClickBehavior]: {
|
||||||
|
type: 'string',
|
||||||
|
enum: ['default', 'paste'],
|
||||||
|
enumDescriptions: [
|
||||||
|
localize('terminal.integrated.middleClickBehavior.default', "The platform default to focus the terminal. On Linux this will also paste the selection."),
|
||||||
|
localize('terminal.integrated.middleClickBehavior.paste', "Paste on middle click."),
|
||||||
|
],
|
||||||
|
default: 'default',
|
||||||
|
description: localize('terminal.integrated.middleClickBehavior', "Controls how terminal reacts to middle click.")
|
||||||
|
},
|
||||||
[TerminalSettingId.Cwd]: {
|
[TerminalSettingId.Cwd]: {
|
||||||
restricted: true,
|
restricted: true,
|
||||||
description: localize('terminal.integrated.cwd', "An explicit start path where the terminal will be launched, this is used as the current working directory (cwd) for the shell process. This may be particularly useful in workspace settings if the root directory is not a convenient cwd."),
|
description: localize('terminal.integrated.cwd', "An explicit start path where the terminal will be launched, this is used as the current working directory (cwd) for the shell process. This may be particularly useful in workspace settings if the root directory is not a convenient cwd."),
|
||||||
|
|
Loading…
Reference in a new issue