дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 03:05:40 +02:00
Copying files in the project view wrote only the file list to the OS clipboard, so pasting into an editor did nothing. The copy now also writes the newline-separated paths as text, which other applications can paste. WKWebView hides that text when file URLs are present and delivers a paste event with only Files, so the IDE editor and terminal still received nothing. A shared helper now reads the OS file list when a paste has files but no text, and inserts the paths. It covers Cmd+V and context-menu Paste in the editor, the terminal and embedded terminals. Markdown image paste runs first and keeps its behaviour. Verified on macOS. The Windows clipboard change was tested by the contributor at the clipboard level only. Refs #573 Co-authored-by: a-rookie-of-C-language <[email protected]>
25 рядки
698 B
TypeScript
25 рядки
698 B
TypeScript
import { pasteClipboardFiles, readClipboardText } from "@/platform/clipboard";
|
|
|
|
export function installTerminalPaste(host: HTMLElement, paste: (text: string) => void): () => void {
|
|
let alive = true;
|
|
const onPaste = (event: ClipboardEvent) => {
|
|
pasteClipboardFiles(event, (text) => {
|
|
if (alive) paste(text);
|
|
});
|
|
};
|
|
host.addEventListener("paste", onPaste, true);
|
|
return () => {
|
|
alive = false;
|
|
host.removeEventListener("paste", onPaste, true);
|
|
};
|
|
}
|
|
|
|
export async function pasteTerminalClipboard(paste: (text: string) => void) {
|
|
try {
|
|
const text = await readClipboardText();
|
|
if (text) paste(text);
|
|
} catch {
|
|
/* Clipboard access may be denied. */
|
|
}
|
|
}
|