Compare commits

...

5 Commits

Author SHA1 Message Date
Bram Moolenaar
955f198fc5 patch 8.0.0307: asan detects a memory error when EXITFREE is defined
Problem:    Asan detects a memory error when EXITFREE is defined. (Dominique
            Pelle)
Solution:   In getvcol() check for ml_get_buf() returning an empty string.
            Also skip adjusting the scroll position.  Set "exiting" in
            mch_exit() for all systems.
2017-02-05 15:10:51 +01:00
Bram Moolenaar
e971df39a5 patch 8.0.0306: mode() not sufficiently tested
Problem:    mode() not sufficiently tested.
Solution:   Add more tests. (Yegappan Lakshmanan)
2017-02-05 14:15:29 +01:00
Bram Moolenaar
aaaf57d8a9 patch 8.0.0305: invalid memory access when option has duplicate flag
Problem:    Invalid memory access when option has duplicate flag.
Solution:   Correct pointer computation. (Dominique Pelle, closes #1442)
2017-02-05 14:13:20 +01:00
Bram Moolenaar
1fb0d49803 patch 8.0.0304: assign test fails in the GUI
Problem:    Assign test fails in the GUI.
Solution:   Skip the test for setting t_k1.
2017-02-04 21:50:19 +01:00
Bram Moolenaar
a1891848d9 patch 8.0.0303: bracketed paste does not work in Visual mode
Problem:    Bracketed paste does not work in Visual mode.
Solution:   Delete the text before pasting
2017-02-04 21:34:31 +01:00
14 changed files with 151 additions and 18 deletions

View File

@@ -1296,6 +1296,10 @@ getvcol(
posptr = NULL; /* continue until the NUL */
else
{
/* Special check for an empty line, which can happen on exit, when
* ml_get_buf() always returns an empty string. */
if (*ptr == NUL)
pos->col = 0;
posptr = ptr + pos->col;
#ifdef FEAT_MBYTE
if (has_mbyte)

View File

@@ -9050,6 +9050,34 @@ nv_edit(cmdarg_T *cap)
/* drop the pasted text */
bracketed_paste(PASTE_INSERT, TRUE, NULL);
}
else if (cap->cmdchar == K_PS && VIsual_active)
{
pos_T old_pos = curwin->w_cursor;
pos_T old_visual = VIsual;
/* In Visual mode the selected text is deleted. */
if (VIsual_mode == 'V' || curwin->w_cursor.lnum != VIsual.lnum)
{
shift_delete_registers();
cap->oap->regname = '1';
}
else
cap->oap->regname = '-';
cap->cmdchar = 'd';
cap->nchar = NUL;
nv_operator(cap);
do_pending_operator(cap, 0, FALSE);
cap->cmdchar = K_PS;
/* When the last char in the line was deleted then append. Detect this
* by checking if the cursor moved to before the Visual area. */
if (*ml_get_cursor() != NUL && lt(curwin->w_cursor, old_pos)
&& lt(curwin->w_cursor, old_visual))
inc_cursor();
/* Insert to replace the deleted text with the pasted text. */
invoke_edit(cap, FALSE, cap->cmdchar, FALSE);
}
else if (!checkclearopq(cap->oap))
{
switch (cap->cmdchar)
@@ -9079,8 +9107,9 @@ nv_edit(cmdarg_T *cap)
beginline(BL_WHITE|BL_FIX);
break;
case K_PS: /* Bracketed paste works like "a"ppend, unless the
cursor is in the first column, then it inserts. */
case K_PS:
/* Bracketed paste works like "a"ppend, unless the cursor is in
* the first column, then it inserts. */
if (curwin->w_cursor.col == 0)
break;
/*FALLTHROUGH*/

View File

@@ -1627,6 +1627,22 @@ adjust_clip_reg(int *rp)
}
#endif
/*
* Shift the delete registers: "9 is cleared, "8 becomes "9, etc.
*/
void
shift_delete_registers()
{
int n;
y_current = &y_regs[9];
free_yank_all(); /* free register nine */
for (n = 9; n > 1; --n)
y_regs[n] = y_regs[n - 1];
y_previous = y_current = &y_regs[1];
y_regs[1].y_array = NULL; /* set register one to empty */
}
/*
* Handle a delete operation.
*
@@ -1739,12 +1755,7 @@ op_delete(oparg_T *oap)
if (orig_regname != 0 || oap->motion_type == MLINE
|| oap->line_count > 1 || oap->use_reg_one)
{
y_current = &y_regs[9];
free_yank_all(); /* free register nine */
for (n = 9; n > 1; --n)
y_regs[n] = y_regs[n - 1];
y_previous = y_current = &y_regs[1];
y_regs[1].y_array = NULL; /* set register one to empty */
shift_delete_registers();
if (op_yank(oap, TRUE, FALSE) == OK)
did_yank = TRUE;
}

View File

@@ -4954,7 +4954,7 @@ do_set(
if (flags & P_FLAGLIST)
{
/* Remove flags that appear twice. */
for (s = newval; *s; ++s)
for (s = newval; *s;)
{
/* if options have P_FLAGLIST and
* P_ONECOMMA such as 'whichwrap' */
@@ -4966,7 +4966,7 @@ do_set(
/* Remove the duplicated value and
* the next comma. */
STRMOVE(s, s + 2);
s -= 2;
continue;
}
}
else
@@ -4975,9 +4975,10 @@ do_set(
&& vim_strchr(s + 1, *s) != NULL)
{
STRMOVE(s, s + 1);
--s;
continue;
}
}
++s;
}
}

View File

@@ -889,6 +889,8 @@ mch_early_init(void)
void
mch_exit(int r)
{
exiting = TRUE;
if (raw_in) /* put terminal in 'normal' mode */
{
settmode(TMODE_COOK);

View File

@@ -201,6 +201,8 @@ int _stricoll(char *a, char *b)
void
mch_exit(int r)
{
exiting = TRUE;
display_errors();
ml_close_all(TRUE); /* remove all memfiles */

View File

@@ -2538,8 +2538,9 @@ mch_init(void)
void
mch_exit(int r)
{
stoptermcap();
exiting = TRUE;
stoptermcap();
if (g_fWindInitCalled)
settmode(TMODE_COOK);

View File

@@ -23,6 +23,7 @@ int insert_reg(int regname, int literally);
int get_spec_reg(int regname, char_u **argp, int *allocated, int errmsg);
int cmdline_paste_reg(int regname, int literally, int remcr);
void adjust_clip_reg(int *rp);
void shift_delete_registers(void);
int op_delete(oparg_T *oap);
int op_replace(oparg_T *oap, int c);
void op_tilde(oparg_T *oap);

View File

@@ -15,11 +15,13 @@ func Test_let_termcap()
call assert_match('t_te.*^[[yes;', execute("set termcap"))
let &t_te = old_t_te
" Key code
let old_t_k1 = &t_k1
let &t_k1 = "that"
call assert_match('t_k1.*that', execute("set termcap"))
let &t_k1 = old_t_k1
if !has('gui_running')
" Key code
let old_t_k1 = &t_k1
let &t_k1 = "that"
call assert_match('t_k1.*that', execute("set termcap"))
let &t_k1 = old_t_k1
endif
call assert_fails('let x = &t_xx', 'E15')
let &t_xx = "yes"

View File

@@ -320,39 +320,73 @@ func! Test_mode()
normal! 3G
exe "normal i\<F2>\<Esc>"
call assert_equal('i-i', g:current_modes)
" i_CTRL-P: Multiple matches
exe "normal i\<C-G>uBa\<C-P>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-P: Single match
exe "normal iBro\<C-P>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-X
exe "normal iBa\<C-X>\<F2>\<Esc>u"
call assert_equal('i-ix', g:current_modes)
" i_CTRL-X CTRL-P: Multiple matches
exe "normal iBa\<C-X>\<C-P>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-X CTRL-P: Single match
exe "normal iBro\<C-X>\<C-P>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-X CTRL-P + CTRL-P: Single match
exe "normal iBro\<C-X>\<C-P>\<C-P>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-X CTRL-L: Multiple matches
exe "normal i\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-X CTRL-L: Single match
exe "normal iBlu\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-P: No match
exe "normal iCom\<C-P>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-X CTRL-P: No match
exe "normal iCom\<C-X>\<C-P>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-X CTRL-L: No match
exe "normal iabc\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" R_CTRL-P: Multiple matches
exe "normal RBa\<C-P>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-P: Single match
exe "normal RBro\<C-P>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-X
exe "normal RBa\<C-X>\<F2>\<Esc>u"
call assert_equal('R-Rx', g:current_modes)
" R_CTRL-X CTRL-P: Multiple matches
exe "normal RBa\<C-X>\<C-P>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-X CTRL-P: Single match
exe "normal RBro\<C-X>\<C-P>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-X CTRL-P + CTRL-P: Single match
exe "normal RBro\<C-X>\<C-P>\<C-P>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-X CTRL-L: Multiple matches
exe "normal R\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-X CTRL-L: Single match
exe "normal RBlu\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-P: No match
exe "normal RCom\<C-P>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-X CTRL-P: No match
exe "normal RCom\<C-X>\<C-P>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-X CTRL-L: No match
exe "normal Rabc\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
call assert_equal('n', mode(0))
call assert_equal('n', mode(1))

View File

@@ -13,6 +13,12 @@ function! Test_whichwrap()
set whichwrap+=h,l
call assert_equal('b,s,h,l', &whichwrap)
set whichwrap=h,h
call assert_equal('h', &whichwrap)
set whichwrap=h,h,h
call assert_equal('h', &whichwrap)
set whichwrap&
endfunction

View File

@@ -70,3 +70,30 @@ func Test_paste_cmdline()
call feedkeys(":a\<Esc>[200~foo\<CR>bar\<Esc>[201~b\<Home>\"\<CR>", 'xt')
call assert_equal("\"afoo\<CR>barb", getreg(':'))
endfunc
func Test_paste_visual_mode()
new
call setline(1, 'here are some words')
call feedkeys("0fsve\<Esc>[200~more\<Esc>[201~", 'xt')
call assert_equal('here are more words', getline(1))
call assert_equal('some', getreg('-'))
" include last char in the line
call feedkeys("0fwve\<Esc>[200~noises\<Esc>[201~", 'xt')
call assert_equal('here are more noises', getline(1))
call assert_equal('words', getreg('-'))
" exclude last char in the line
call setline(1, 'some words!')
call feedkeys("0fwve\<Esc>[200~noises\<Esc>[201~", 'xt')
call assert_equal('some noises!', getline(1))
call assert_equal('words', getreg('-'))
" multi-line selection
call setline(1, ['some words', 'and more'])
call feedkeys("0fwvj0fd\<Esc>[200~letters\<Esc>[201~", 'xt')
call assert_equal('some letters more', getline(1))
call assert_equal("words\nand", getreg('1'))
bwipe!
endfunc

View File

@@ -764,6 +764,16 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
307,
/**/
306,
/**/
305,
/**/
304,
/**/
303,
/**/
302,
/**/

View File

@@ -5708,7 +5708,10 @@ win_new_height(win_T *wp, int height)
wp->w_height = height;
wp->w_skipcol = 0;
scroll_to_fraction(wp, prev_height);
/* There is no point in adjusting the scroll position when exiting. Some
* values might be invalid. */
if (!exiting)
scroll_to_fraction(wp, prev_height);
}
void