automatically trim trailing newline when pasting

This commit is contained in:
Eugene Pankov 2021-09-24 23:43:57 +02:00
parent 924fb90220
commit ed71b499b9
No known key found for this signature in database
GPG key ID: 5896FCBBDD1CF4F4

View file

@ -422,15 +422,16 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
async paste (): Promise<void> {
let data = this.platform.readClipboard()
if (this.config.store.terminal.bracketedPaste && this.frontend?.supportsBracketedPaste()) {
data = `\x1b[200~${data}\x1b[201~`
}
if (this.hostApp.platform === Platform.Windows) {
data = data.replaceAll('\r\n', '\r')
} else {
data = data.replaceAll('\n', '\r')
}
if (data.endsWith('\n')) {
data = data.substring(0, data.length - 1)
}
if (!this.alternateScreenActive) {
data = data.trim()
@ -451,6 +452,10 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
}
}
}
if (this.config.store.terminal.bracketedPaste && this.frontend?.supportsBracketedPaste()) {
data = `\x1b[200~${data}\x1b[201~`
}
this.sendInput(data)
}