mirror of
https://github.com/neovim/neovim.git
synced 2025-12-10 08:32:42 +00:00
Merge pull request #4186 from watiko/vim-7.4.929
vim-patch:7.4.{734,743,929}
This commit is contained in:
@@ -1538,9 +1538,11 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
curbuf->b_visual_mode_eval = VIsual_mode;
|
curbuf->b_visual_mode_eval = VIsual_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* In Select mode, a linewise selection is operated upon like a
|
// In Select mode, a linewise selection is operated upon like a
|
||||||
* characterwise selection. */
|
// characterwise selection.
|
||||||
if (VIsual_select && VIsual_mode == 'V') {
|
// Special case: gH<Del> deletes the last line.
|
||||||
|
if (VIsual_select && VIsual_mode == 'V'
|
||||||
|
&& cap->oap->op_type != OP_DELETE) {
|
||||||
if (lt(VIsual, curwin->w_cursor)) {
|
if (lt(VIsual, curwin->w_cursor)) {
|
||||||
VIsual.col = 0;
|
VIsual.col = 0;
|
||||||
curwin->w_cursor.col =
|
curwin->w_cursor.col =
|
||||||
@@ -1676,20 +1678,15 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
&& (include_line_break || !virtual_op)
|
&& (include_line_break || !virtual_op)
|
||||||
) {
|
) {
|
||||||
oap->inclusive = false;
|
oap->inclusive = false;
|
||||||
/* Try to include the newline, unless it's an operator
|
// Try to include the newline, unless it's an operator
|
||||||
* that works on lines only. */
|
// that works on lines only.
|
||||||
if (*p_sel != 'o' && !op_on_lines(oap->op_type)) {
|
if (*p_sel != 'o'
|
||||||
if (oap->end.lnum < curbuf->b_ml.ml_line_count) {
|
&& !op_on_lines(oap->op_type)
|
||||||
++oap->end.lnum;
|
&& oap->end.lnum < curbuf->b_ml.ml_line_count) {
|
||||||
oap->end.col = 0;
|
oap->end.lnum++;
|
||||||
oap->end.coladd = 0;
|
oap->end.col = 0;
|
||||||
++oap->line_count;
|
oap->end.coladd = 0;
|
||||||
} else {
|
oap->line_count++;
|
||||||
/* Cannot move below the last line, make the op
|
|
||||||
* inclusive to tell the operation to include the
|
|
||||||
* line break. */
|
|
||||||
oap->inclusive = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7748,6 +7745,10 @@ static void nv_put(cmdarg_T *cap)
|
|||||||
if (was_visual) {
|
if (was_visual) {
|
||||||
curbuf->b_visual.vi_start = curbuf->b_op_start;
|
curbuf->b_visual.vi_start = curbuf->b_op_start;
|
||||||
curbuf->b_visual.vi_end = curbuf->b_op_end;
|
curbuf->b_visual.vi_end = curbuf->b_op_end;
|
||||||
|
// need to adjust cursor position
|
||||||
|
if (*p_sel == 'e') {
|
||||||
|
inc(&curbuf->b_visual.vi_end);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When all lines were selected and deleted do_put() leaves an empty
|
/* When all lines were selected and deleted do_put() leaves an empty
|
||||||
|
|||||||
@@ -1555,55 +1555,31 @@ int op_delete(oparg_T *oap)
|
|||||||
if (gchar_cursor() != NUL)
|
if (gchar_cursor() != NUL)
|
||||||
curwin->w_cursor.coladd = 0;
|
curwin->w_cursor.coladd = 0;
|
||||||
}
|
}
|
||||||
if (oap->op_type == OP_DELETE
|
|
||||||
&& oap->inclusive
|
(void)del_bytes((long)n, !virtual_op,
|
||||||
&& oap->end.lnum == curbuf->b_ml.ml_line_count
|
oap->op_type == OP_DELETE && !oap->is_VIsual);
|
||||||
&& n > (int)STRLEN(ml_get(oap->end.lnum))) {
|
} else {
|
||||||
/* Special case: gH<Del> deletes the last line. */
|
// delete characters between lines
|
||||||
del_lines(1L, FALSE);
|
|
||||||
} else {
|
|
||||||
(void)del_bytes((long)n, !virtual_op, oap->op_type == OP_DELETE
|
|
||||||
&& !oap->is_VIsual
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else { /* delete characters between lines */
|
|
||||||
pos_T curpos;
|
pos_T curpos;
|
||||||
int delete_last_line;
|
|
||||||
|
|
||||||
/* save deleted and changed lines for undo */
|
/* save deleted and changed lines for undo */
|
||||||
if (u_save((linenr_T)(curwin->w_cursor.lnum - 1),
|
if (u_save((linenr_T)(curwin->w_cursor.lnum - 1),
|
||||||
(linenr_T)(curwin->w_cursor.lnum + oap->line_count)) == FAIL)
|
(linenr_T)(curwin->w_cursor.lnum + oap->line_count)) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
delete_last_line = (oap->end.lnum == curbuf->b_ml.ml_line_count);
|
truncate_line(true); // delete from cursor to end of line
|
||||||
truncate_line(TRUE); /* delete from cursor to end of line */
|
|
||||||
|
|
||||||
curpos = curwin->w_cursor; /* remember curwin->w_cursor */
|
curpos = curwin->w_cursor; // remember curwin->w_cursor
|
||||||
++curwin->w_cursor.lnum;
|
curwin->w_cursor.lnum++;
|
||||||
del_lines(oap->line_count - 2, FALSE);
|
del_lines(oap->line_count - 2, false);
|
||||||
|
|
||||||
if (delete_last_line)
|
|
||||||
oap->end.lnum = curbuf->b_ml.ml_line_count;
|
|
||||||
|
|
||||||
|
// delete from start of line until op_end
|
||||||
n = (oap->end.col + 1 - !oap->inclusive);
|
n = (oap->end.col + 1 - !oap->inclusive);
|
||||||
if (oap->inclusive && delete_last_line
|
curwin->w_cursor.col = 0;
|
||||||
&& n > (int)STRLEN(ml_get(oap->end.lnum))) {
|
(void)del_bytes((long)n, !virtual_op,
|
||||||
/* Special case: gH<Del> deletes the last line. */
|
oap->op_type == OP_DELETE && !oap->is_VIsual);
|
||||||
del_lines(1L, FALSE);
|
curwin->w_cursor = curpos; // restore curwin->w_cursor
|
||||||
curwin->w_cursor = curpos; /* restore curwin->w_cursor */
|
(void)do_join(2, false, false, false, false);
|
||||||
if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
|
|
||||||
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
|
||||||
} else {
|
|
||||||
/* delete from start of line until op_end */
|
|
||||||
curwin->w_cursor.col = 0;
|
|
||||||
(void)del_bytes((long)n, !virtual_op, oap->op_type == OP_DELETE
|
|
||||||
&& !oap->is_VIsual
|
|
||||||
);
|
|
||||||
curwin->w_cursor = curpos; /* restore curwin->w_cursor */
|
|
||||||
}
|
|
||||||
if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) {
|
|
||||||
do_join(2, FALSE, FALSE, FALSE, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2688,17 +2664,27 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
|
|
||||||
if (y_type == MLINE) {
|
if (y_type == MLINE) {
|
||||||
if (flags & PUT_LINE_SPLIT) {
|
if (flags & PUT_LINE_SPLIT) {
|
||||||
/* "p" or "P" in Visual mode: split the lines to put the text in
|
// "p" or "P" in Visual mode: split the lines to put the text in
|
||||||
* between. */
|
// between.
|
||||||
if (u_save_cursor() == FAIL)
|
if (u_save_cursor() == FAIL) {
|
||||||
goto end;
|
goto end;
|
||||||
ptr = vim_strsave(get_cursor_pos_ptr());
|
}
|
||||||
ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE);
|
char_u *p = get_cursor_pos_ptr();
|
||||||
|
if (dir == FORWARD && *p != NUL) {
|
||||||
|
mb_ptr_adv(p);
|
||||||
|
}
|
||||||
|
ptr = vim_strsave(p);
|
||||||
|
ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, false);
|
||||||
xfree(ptr);
|
xfree(ptr);
|
||||||
|
|
||||||
ptr = vim_strnsave(get_cursor_line_ptr(), curwin->w_cursor.col);
|
oldp = get_cursor_line_ptr();
|
||||||
ml_replace(curwin->w_cursor.lnum, ptr, FALSE);
|
p = oldp + curwin->w_cursor.col;
|
||||||
++nr_lines;
|
if (dir == FORWARD && *p != NUL) {
|
||||||
|
mb_ptr_adv(p);
|
||||||
|
}
|
||||||
|
ptr = vim_strnsave(oldp, p - oldp);
|
||||||
|
ml_replace(curwin->w_cursor.lnum, ptr, false);
|
||||||
|
nr_lines++;
|
||||||
dir = FORWARD;
|
dir = FORWARD;
|
||||||
}
|
}
|
||||||
if (flags & PUT_LINE_FORWARD) {
|
if (flags & PUT_LINE_FORWARD) {
|
||||||
|
|||||||
@@ -357,9 +357,9 @@ static int included_patches[] = {
|
|||||||
// 934 NA
|
// 934 NA
|
||||||
// 933,
|
// 933,
|
||||||
// 932,
|
// 932,
|
||||||
// 931,
|
// 931 NA
|
||||||
// 930 NA
|
// 930 NA
|
||||||
// 929,
|
929,
|
||||||
// 928 NA
|
// 928 NA
|
||||||
// 927 NA
|
// 927 NA
|
||||||
// 926,
|
// 926,
|
||||||
@@ -545,7 +545,7 @@ static int included_patches[] = {
|
|||||||
746,
|
746,
|
||||||
745,
|
745,
|
||||||
// 744 NA
|
// 744 NA
|
||||||
// 743,
|
743,
|
||||||
742,
|
742,
|
||||||
741,
|
741,
|
||||||
740,
|
740,
|
||||||
@@ -554,7 +554,7 @@ static int included_patches[] = {
|
|||||||
737,
|
737,
|
||||||
736,
|
736,
|
||||||
// 735 NA
|
// 735 NA
|
||||||
// 734,
|
734,
|
||||||
// 733,
|
// 733,
|
||||||
732,
|
732,
|
||||||
// 731 NA
|
// 731 NA
|
||||||
|
|||||||
@@ -24,6 +24,27 @@ local function source_user_functions()
|
|||||||
]])
|
]])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function put_abc()
|
||||||
|
source([[
|
||||||
|
$put ='a'
|
||||||
|
$put ='b'
|
||||||
|
$put ='c']])
|
||||||
|
end
|
||||||
|
|
||||||
|
local function put_aaabbbccc()
|
||||||
|
source([[
|
||||||
|
$put ='aaa'
|
||||||
|
$put ='bbb'
|
||||||
|
$put ='ccc']])
|
||||||
|
end
|
||||||
|
|
||||||
|
local function define_select_mode_maps()
|
||||||
|
source([[
|
||||||
|
snoremap <lt>End> <End>
|
||||||
|
snoremap <lt>Down> <Down>
|
||||||
|
snoremap <lt>Del> <Del>]])
|
||||||
|
end
|
||||||
|
|
||||||
describe('Visual mode and operator', function()
|
describe('Visual mode and operator', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
@@ -150,4 +171,228 @@ describe('Visual mode and operator', function()
|
|||||||
ok
|
ok
|
||||||
ok]])
|
ok]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe('characterwise visual mode:', function()
|
||||||
|
it('replace last line', function()
|
||||||
|
source([[
|
||||||
|
$put ='a'
|
||||||
|
let @" = 'x']])
|
||||||
|
feed('v$p')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
x]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('delete middle line', function()
|
||||||
|
put_abc()
|
||||||
|
feed('kkv$d')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
b
|
||||||
|
c]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('delete middle two line', function()
|
||||||
|
put_abc()
|
||||||
|
feed('kkvj$d')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
c]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('delete last line', function()
|
||||||
|
put_abc()
|
||||||
|
feed('v$d')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
a
|
||||||
|
b
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('delete last two line', function()
|
||||||
|
put_abc()
|
||||||
|
feed('kvj$d')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
a
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
describe('characterwise select mode:', function()
|
||||||
|
before_each(function()
|
||||||
|
define_select_mode_maps()
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('delete middle line', function()
|
||||||
|
put_abc()
|
||||||
|
feed('kkgh<End><Del>')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
b
|
||||||
|
c]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('delete middle two line', function()
|
||||||
|
put_abc()
|
||||||
|
feed('kkgh<Down><End><Del>')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
c]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('delete last line', function()
|
||||||
|
put_abc()
|
||||||
|
feed('gh<End><Del>')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
a
|
||||||
|
b
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('delete last two line', function()
|
||||||
|
put_abc()
|
||||||
|
feed('kgh<Down><End><Del>')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
a
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
describe('linewise select mode:', function()
|
||||||
|
before_each(function()
|
||||||
|
define_select_mode_maps()
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('delete middle line', function()
|
||||||
|
put_abc()
|
||||||
|
feed(' kkgH<Del> ')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
b
|
||||||
|
c]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('delete middle two line', function()
|
||||||
|
put_abc()
|
||||||
|
feed('kkgH<Down><Del>')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
c]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('delete last line', function()
|
||||||
|
put_abc()
|
||||||
|
feed('gH<Del>')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
a
|
||||||
|
b]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('delete last two line', function()
|
||||||
|
put_abc()
|
||||||
|
feed('kgH<Down><Del>')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
a]])
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
describe('v_p:', function()
|
||||||
|
it('replace last character with line register at middle line', function()
|
||||||
|
put_aaabbbccc()
|
||||||
|
execute('-2yank')
|
||||||
|
feed('k$vp')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
aaa
|
||||||
|
bb
|
||||||
|
aaa
|
||||||
|
|
||||||
|
ccc]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('replace last character with line register at middle line selecting newline', function()
|
||||||
|
put_aaabbbccc()
|
||||||
|
execute('-2yank')
|
||||||
|
feed('k$v$p')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
aaa
|
||||||
|
bb
|
||||||
|
aaa
|
||||||
|
ccc]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('replace last character with line register at last line', function()
|
||||||
|
put_aaabbbccc()
|
||||||
|
execute('-2yank')
|
||||||
|
feed('$vp')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
aaa
|
||||||
|
bbb
|
||||||
|
cc
|
||||||
|
aaa
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('replace last character with line register at last line selecting newline', function()
|
||||||
|
put_aaabbbccc()
|
||||||
|
execute('-2yank')
|
||||||
|
feed('$v$p')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
aaa
|
||||||
|
bbb
|
||||||
|
cc
|
||||||
|
aaa
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('gv in exclusive select mode after operation', function()
|
||||||
|
source([[
|
||||||
|
$put ='zzz '
|
||||||
|
$put ='äà '
|
||||||
|
set selection=exclusive]])
|
||||||
|
feed('kv3lyjv3lpgvcxxx<Esc>')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
zzz
|
||||||
|
xxx ]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('gv in exclusive select mode without operation', function()
|
||||||
|
source([[
|
||||||
|
$put ='zzz '
|
||||||
|
set selection=exclusive]])
|
||||||
|
feed('0v3l<Esc>gvcxxx<Esc>')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
xxx ]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user