diff --git a/terminus-terminal/src/frontends/xtermFrontend.ts b/terminus-terminal/src/frontends/xtermFrontend.ts index 0feeab6d..d461315b 100644 --- a/terminus-terminal/src/frontends/xtermFrontend.ts +++ b/terminus-terminal/src/frontends/xtermFrontend.ts @@ -167,15 +167,28 @@ export class XTermFrontend extends Frontend { } copySelection (): void { - const text = this.getSelection() + let text = this.getSelection() + let lines = text.split('\n') + if (lines.some(x => x.length === this.xterm.cols)) { + text = '' + let lastLineWraps = false + for (let line of lines) { + if (!lastLineWraps) { + text += '\n' + } + text += line + lastLineWraps = line.length === this.xterm.cols + } + } + if (text.length < 1024 * 32) { require('electron').remote.clipboard.write({ - text: this.getSelection(), + text: text, html: this.getSelectionAsHTML(), }) } else { require('electron').remote.clipboard.write({ - text: this.getSelection(), + text: text, }) } }