[vim] fix blockwise yank

This commit is contained in:
nightwing 2019-05-14 14:18:39 +04:00 committed by Marijn Haverbeke
parent 1b3c322c43
commit a86e85864c
2 changed files with 26 additions and 7 deletions

View File

@ -2570,7 +2570,17 @@
}
var linewise = register.linewise;
var blockwise = register.blockwise;
if (linewise) {
if (blockwise) {
text = text.split('\n');
if (linewise) {
text.pop();
}
for (var i = 0; i < text.length; i++) {
text[i] = (text[i] == '') ? ' ' : text[i];
}
cur.ch += actionArgs.after ? 1 : 0;
cur.ch = Math.min(lineLength(cm, cur.line), cur.ch);
} else if (linewise) {
if(vim.visualMode) {
text = vim.visualLine ? text.slice(0, -1) : '\n' + text.slice(0, text.length - 1) + '\n';
} else if (actionArgs.after) {
@ -2582,12 +2592,6 @@
cur.ch = 0;
}
} else {
if (blockwise) {
text = text.split('\n');
for (var i = 0; i < text.length; i++) {
text[i] = (text[i] == '') ? ' ' : text[i];
}
}
cur.ch += actionArgs.after ? 1 : 0;
}
var curPosFinal;

View File

@ -1428,6 +1428,21 @@ testVim('Y', function(cm, vim, helpers) {
is(register.linewise);
helpers.assertCursorAt(0, 3);
}, { value: ' word1\nword2\n word3' });
testVim('Yy_blockwise', function(cm, vim, helpers) {
helpers.doKeys('<C-v>', 'j', '2', 'l', 'Y');
helpers.doKeys('G', 'p', 'g', 'g');
helpers.doKeys('<C-v>', 'j', '2', 'l', 'y');
helpers.assertCursorAt(0, 0);
helpers.doKeys('$', 'p');
eq('123456123\n123456123\n123456\n123456', cm.getValue());
var register = helpers.getRegisterController().getRegister();
eq('123\n123', register.toString());
is(register.blockwise);
helpers.assertCursorAt(0, 6);
helpers.doKeys('$', 'j', 'p');
helpers.doKeys('$', 'j', 'P');
eq("123456123\n123456123123\n123456 121233\n123456 123", cm.getValue());
}, { value: '123456\n123456\n' });
testVim('~', function(cm, vim, helpers) {
helpers.doKeys('3', '~');
eq('ABCdefg', cm.getValue());