- As described in https://cirw.in/blog/bracketed-paste - Example support in vim: - https://github.com/ConradIrwin/vim-bracketed-paste/blob/master/plugin/bracketed-paste.vim - http://vimdoc.sourceforge.net/htmldoc/term.html#raw-terminal-mode - Required for e.g. ipython, via python-prompt-toolkit: - https://github.com/ipython/ipython - https://github.com/jonathanslenders/python-prompt-toolkit Repro: - Run `ipython` (version 6.2.1) - Copy multiple lines of text and paste into ipython prompt, e.g. ```py print(1) print(2) print(3) ``` - Before: first line would paste and run, and subsequent lines are lost - After: all lines paste into single prompt
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
/**
|
|
* Copyright (c) 2016 The xterm.js authors. All rights reserved.
|
|
* @license MIT
|
|
*/
|
|
|
|
import { assert } from 'chai';
|
|
import * as Terminal from '../Terminal';
|
|
import * as Clipboard from './Clipboard';
|
|
|
|
describe('evaluatePastedTextProcessing', () => {
|
|
it('should replace carriage return + line feed with line feed on windows', () => {
|
|
const pastedText = 'foo\r\nbar\r\n';
|
|
const processedText = Clipboard.prepareTextForTerminal(pastedText, false);
|
|
const windowsProcessedText = Clipboard.prepareTextForTerminal(pastedText, true);
|
|
|
|
assert.equal(processedText, 'foo\r\nbar\r\n');
|
|
assert.equal(windowsProcessedText, 'foo\rbar\r');
|
|
});
|
|
it('should bracket pasted text in bracketedPasteMode', () => {
|
|
const pastedText = 'foo bar';
|
|
const unbracketedText = Clipboard.bracketTextForPaste(pastedText, false);
|
|
const bracketedText = Clipboard.bracketTextForPaste(pastedText, true);
|
|
|
|
assert.equal(unbracketedText, 'foo bar');
|
|
assert.equal(bracketedText, '\x1b[200~foo bar\x1b[201~');
|
|
});
|
|
});
|