mirror of
https://github.com/Microsoft/vscode
synced 2024-07-17 11:07:22 +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',
|
||||
TerminalDescription = 'terminal.integrated.tabs.description',
|
||||
RightClickBehavior = 'terminal.integrated.rightClickBehavior',
|
||||
MiddleClickBehavior = 'terminal.integrated.middleClickBehavior',
|
||||
Cwd = 'terminal.integrated.cwd',
|
||||
ConfirmOnExit = 'terminal.integrated.confirmOnExit',
|
||||
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 { ITerminalProfileResolverService, ITerminalProfileService, TerminalCommandId } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
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 { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { openContextMenu } from 'vs/workbench/contrib/terminal/browser/terminalContextMenu';
|
||||
|
@ -123,15 +123,23 @@ export class TerminalEditor extends EditorPane {
|
|||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
if (event.which === 2 && isLinux) {
|
||||
// Drop selection and focus terminal on Linux to enable middle button paste when click
|
||||
// occurs on the selection itself.
|
||||
const terminal = this._terminalEditorService.activeInstance;
|
||||
terminal?.focus();
|
||||
if (event.which === 2) {
|
||||
switch (this._terminalConfigurationService.config.middleClickBehavior) {
|
||||
case 'paste':
|
||||
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) {
|
||||
const rightClickBehavior = this._terminalConfigurationService.config.rightClickBehavior;
|
||||
if (rightClickBehavior === 'nothing') {
|
||||
|
@ -141,11 +149,6 @@ export class TerminalEditor extends EditorPane {
|
|||
return;
|
||||
}
|
||||
else if (rightClickBehavior === 'copyPaste' || rightClickBehavior === 'paste') {
|
||||
const terminal = this._terminalEditorService.activeInstance;
|
||||
if (!terminal) {
|
||||
return;
|
||||
}
|
||||
|
||||
// copyPaste: Shift+right click should open context menu
|
||||
if (rightClickBehavior === 'copyPaste' && event.shiftKey) {
|
||||
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 { ITerminalConfigurationService, ITerminalGroupService, ITerminalInstance, ITerminalService, TerminalConnectionState } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
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 { BrowserFeatures } from 'vs/base/browser/canIUse';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
|
@ -339,10 +339,18 @@ export class TerminalTabbedView extends Disposable {
|
|||
return;
|
||||
}
|
||||
|
||||
if (event.which === 2 && isLinux) {
|
||||
// Drop selection and focus terminal on Linux to enable middle button paste when click
|
||||
// occurs on the selection itself.
|
||||
terminal.focus();
|
||||
if (event.which === 2) {
|
||||
switch (this._terminalConfigurationService.config.middleClickBehavior) {
|
||||
case 'paste':
|
||||
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) {
|
||||
const rightClickBehavior = this._terminalConfigurationService.config.rightClickBehavior;
|
||||
if (rightClickBehavior === 'nothing') {
|
||||
|
|
|
@ -137,6 +137,7 @@ export interface ITerminalConfiguration {
|
|||
macOptionClickForcesSelection: boolean;
|
||||
gpuAcceleration: 'auto' | 'on' | 'canvas' | 'off';
|
||||
rightClickBehavior: 'default' | 'copyPaste' | 'paste' | 'selectWord' | 'nothing';
|
||||
middleClickBehavior: 'default' | 'paste';
|
||||
cursorBlinking: boolean;
|
||||
cursorStyle: 'block' | 'underline' | 'line';
|
||||
cursorStyleInactive: 'outline' | 'block' | 'underline' | 'line' | 'none';
|
||||
|
|
|
@ -334,6 +334,16 @@ const terminalConfiguration: IConfigurationNode = {
|
|||
default: isMacintosh ? 'selectWord' : isWindows ? 'copyPaste' : 'default',
|
||||
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]: {
|
||||
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."),
|
||||
|
|
Loading…
Reference in a new issue