提交 5607d6b3 编写于 作者: M Matt Bierner 提交者: GitHub

Seed terminal find widget with current selection (#30351)

* Seed terminal find widget with current selection

Fixes #29712

Use the current selection as the search when we first show the find widget for the terminal

* Making requested changes
上级 9c82ae89
......@@ -194,7 +194,11 @@ export abstract class SimpleFindWidget extends Widget {
return this._domNode;
}
public reveal(): void {
public reveal(initialInput?: string): void {
if (initialInput) {
this._findInput.setValue(initialInput);
}
if (this._isVisible) {
this._findInput.select();
return;
......
......@@ -232,6 +232,11 @@ export interface ITerminalInstance {
*/
copySelection(): void;
/**
* Current selection in the terminal.
*/
readonly selection: string | undefined;
/**
* Clear current selection.
*/
......
......@@ -344,6 +344,10 @@ export class TerminalInstance implements ITerminalInstance {
}
}
get selection(): string | undefined {
return this.hasSelection() ? this._xterm.getSelection() : undefined;
}
public clearSelection(): void {
this._xterm.clearSelection();
}
......
......@@ -159,7 +159,12 @@ export class TerminalPanel extends Panel {
}
public focusFindWidget() {
this._findWidget.reveal();
const activeInstance = this._terminalService.getActiveInstance();
if (activeInstance && activeInstance.hasSelection()) {
this._findWidget.reveal(activeInstance.selection);
} else {
this._findWidget.reveal();
}
}
public hideFindWidget() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册