mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-15 21:01:05 +01:00
@@ -842,6 +842,12 @@ export interface ITerminalInstance extends IBaseTerminalInstance {
|
||||
*/
|
||||
pasteSelection(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Override the copy on selection feature with a custom value.
|
||||
* @param value Whether to enable copySelection.
|
||||
*/
|
||||
overrideCopyOnSelection(value: boolean): IDisposable;
|
||||
|
||||
/**
|
||||
* Send text to the terminal instance. The text is written to the stdin of the underlying pty
|
||||
* process (shell) of the terminal instance.
|
||||
|
||||
@@ -1745,12 +1745,24 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
||||
private async _onSelectionChange(): Promise<void> {
|
||||
this._onDidChangeSelection.fire(this);
|
||||
if (this._configurationService.getValue(TerminalSettingId.CopyOnSelection)) {
|
||||
if (this._overrideCopySelection === false) {
|
||||
return;
|
||||
}
|
||||
if (this.hasSelection()) {
|
||||
await this.copySelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private _overrideCopySelection: boolean | undefined = undefined;
|
||||
overrideCopyOnSelection(value: boolean): IDisposable {
|
||||
if (this._overrideCopySelection !== undefined) {
|
||||
throw new Error('Cannot set a copy on selection override multiple times');
|
||||
}
|
||||
this._overrideCopySelection = value;
|
||||
return toDisposable(() => this._overrideCopySelection = undefined);
|
||||
}
|
||||
|
||||
@debounce(2000)
|
||||
private async _updateProcessCwd(): Promise<void> {
|
||||
if (this.isDisposed || this.shellLaunchConfig.customPtyImplementation) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import type { ISearchOptions } from '@xterm/addon-search';
|
||||
import { TerminalCommandId } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { openContextMenu } from 'vs/workbench/contrib/terminalContrib/find/browser/textInputContextMenu';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
const TERMINAL_FIND_WIDGET_INITIAL_WIDTH = 419;
|
||||
|
||||
@@ -25,6 +26,8 @@ export class TerminalFindWidget extends SimpleFindWidget {
|
||||
private _findWidgetFocused: IContextKey<boolean>;
|
||||
private _findWidgetVisible: IContextKey<boolean>;
|
||||
|
||||
private _overrideCopyOnSelectionDisposable: IDisposable | undefined;
|
||||
|
||||
constructor(
|
||||
private _instance: ITerminalInstance | IDetachedTerminalInstance,
|
||||
@IContextViewService _contextViewService: IContextViewService,
|
||||
@@ -143,10 +146,14 @@ export class TerminalFindWidget extends SimpleFindWidget {
|
||||
}
|
||||
|
||||
protected _onFocusTrackerFocus() {
|
||||
if ('overrideCopyOnSelection' in this._instance) {
|
||||
this._overrideCopyOnSelectionDisposable = this._instance.overrideCopyOnSelection(false);
|
||||
}
|
||||
this._findWidgetFocused.set(true);
|
||||
}
|
||||
|
||||
protected _onFocusTrackerBlur() {
|
||||
this._overrideCopyOnSelectionDisposable?.dispose();
|
||||
this._instance.xterm?.clearActiveSearchDecoration();
|
||||
this._findWidgetFocused.reset();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user