mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-03-01 03:51:59 +01:00
fix multi-input paste (#2000)
a fix for #1862. so now when pasting information into a terminal when multi-input is active, the data will be sent to all terminals in the tab.
This commit is contained in:
parent
217ab4a2e3
commit
2df1c2e7bd
@ -152,6 +152,7 @@ export class TermWrap {
|
||||
sendDataHandler: (data: string) => void;
|
||||
onSearchResultsDidChange?: (result: { resultIndex: number; resultCount: number }) => void;
|
||||
private toDispose: TermTypes.IDisposable[] = [];
|
||||
pasteActive: boolean = false;
|
||||
|
||||
constructor(
|
||||
blockId: string,
|
||||
@ -217,6 +218,19 @@ export class TermWrap {
|
||||
this.handleResize_debounced = debounce(50, this.handleResize.bind(this));
|
||||
this.terminal.open(this.connectElem);
|
||||
this.handleResize();
|
||||
let pasteEventHandler = () => {
|
||||
this.pasteActive = true;
|
||||
setTimeout(() => {
|
||||
this.pasteActive = false;
|
||||
}, 30);
|
||||
};
|
||||
pasteEventHandler = pasteEventHandler.bind(this);
|
||||
this.connectElem.addEventListener("paste", pasteEventHandler, true);
|
||||
this.toDispose.push({
|
||||
dispose: () => {
|
||||
this.connectElem.removeEventListener("paste", pasteEventHandler, true);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async initTerminal() {
|
||||
@ -263,6 +277,12 @@ export class TermWrap {
|
||||
if (!this.loaded) {
|
||||
return;
|
||||
}
|
||||
if (this.pasteActive) {
|
||||
this.pasteActive = false;
|
||||
if (this.multiInputCallback) {
|
||||
this.multiInputCallback(data);
|
||||
}
|
||||
}
|
||||
this.sendDataHandler?.(data);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user