mirror of
https://github.com/Eugeny/tabby.git
synced 2025-09-24 09:06:03 +00:00
warn on multi-line paste (fixed #2131)
This commit is contained in:
@@ -291,7 +291,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
|||||||
this.frontend.write(data)
|
this.frontend.write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
paste (): void {
|
async paste (): Promise<void> {
|
||||||
let data = this.electron.clipboard.readText() as string
|
let data = this.electron.clipboard.readText() as string
|
||||||
if (this.config.store.terminal.bracketedPaste) {
|
if (this.config.store.terminal.bracketedPaste) {
|
||||||
data = '\x1b[200~' + data + '\x1b[201~'
|
data = '\x1b[200~' + data + '\x1b[201~'
|
||||||
@@ -301,6 +301,28 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
|||||||
} else {
|
} else {
|
||||||
data = data.replace(/\n/g, '\r')
|
data = data.replace(/\n/g, '\r')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.includes('\r')) {
|
||||||
|
const canTrim = !data.trim().includes('\r')
|
||||||
|
const buttons = canTrim ? ['Paste', 'Trim whitespace and paste', 'Cancel'] : ['Paste', 'Cancel']
|
||||||
|
const result = (await this.electron.showMessageBox(
|
||||||
|
this.hostApp.getWindow(),
|
||||||
|
{
|
||||||
|
type: 'warning',
|
||||||
|
detail: data,
|
||||||
|
message: `Paste multiple lines?`,
|
||||||
|
buttons,
|
||||||
|
defaultId: 0,
|
||||||
|
cancelId: buttons.length - 1,
|
||||||
|
}
|
||||||
|
)).response
|
||||||
|
if (result === buttons.length - 1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (result === 1) {
|
||||||
|
data = data.trim()
|
||||||
|
}
|
||||||
|
}
|
||||||
this.sendInput(data)
|
this.sendInput(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user