Compare commits

..

4 Commits

Author SHA1 Message Date
0b2eef24bc patch 8.0.0682: no test for synIDtrans()
Problem:    No test for synIDtrans().
Solution:   Add a test. (Dominique Pelle, closes #1796)
2017-06-27 15:43:49 +02:00
18d90b95c4 patch 8.0.0681: unnamed register only contains the last deleted text
Problem:    Unnamed register only contains the last deleted text when
            appending deleted text to a register. (Wolfgang Jeltsch)
Solution:   Only set y_previous when not using y_append. (Christian Brabandt)
2017-06-27 15:39:14 +02:00
07ecfa64a1 patch 8.0.0680: plugins in start packages are sourced twice
Problem:    Plugins in start packages are sourced twice. (mseplowitz)
Solution:   Use the unmodified runtime path when loading plugins (test by Ingo
            Karkat, closes #1801)
2017-06-27 14:43:55 +02:00
41cc038ff8 patch 8.0.0679: using freed memory
Problem:    Using freed memory.
Solution:   Get the parent frame pointer earlier.
2017-06-26 09:59:35 +02:00
9 changed files with 121 additions and 33 deletions

View File

@ -3285,19 +3285,6 @@ source_callback(char_u *fname, void *cookie UNUSED)
(void)do_source(fname, FALSE, DOSO_NONE);
}
/*
* Source the file "name" from all directories in 'runtimepath'.
* "name" can contain wildcards.
* When "flags" has DIP_ALL: source all files, otherwise only the first one.
*
* return FAIL when no file could be sourced, OK otherwise.
*/
int
source_runtime(char_u *name, int flags)
{
return do_in_runtimepath(name, flags, source_callback, NULL);
}
/*
* Find the file "name" in all directories in "path" and invoke
* "callback(fname, cookie)".
@ -3435,18 +3422,19 @@ do_in_path(
}
/*
* Find "name" in 'runtimepath'. When found, invoke the callback function for
* Find "name" in "path". When found, invoke the callback function for
* it: callback(fname, "cookie")
* When "flags" has DIP_ALL repeat for all matches, otherwise only the first
* one is used.
* Returns OK when at least one match found, FAIL otherwise.
*
* If "name" is NULL calls callback for each entry in runtimepath. Cookie is
* If "name" is NULL calls callback for each entry in "path". Cookie is
* passed by reference in this case, setting it to NULL indicates that callback
* has done its job.
*/
int
do_in_runtimepath(
static int
do_in_path_and_pp(
char_u *path,
char_u *name,
int flags,
void (*callback)(char_u *fname, void *ck),
@ -3459,7 +3447,7 @@ do_in_runtimepath(
char *opt_dir = "pack/*/opt/*/%s";
if ((flags & DIP_NORTP) == 0)
done = do_in_path(p_rtp, name, flags, callback, cookie);
done = do_in_path(path, name, flags, callback, cookie);
if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_START))
{
@ -3486,6 +3474,42 @@ do_in_runtimepath(
return done;
}
/*
* Just like do_in_path_and_pp(), using 'runtimepath' for "path".
*/
int
do_in_runtimepath(
char_u *name,
int flags,
void (*callback)(char_u *fname, void *ck),
void *cookie)
{
return do_in_path_and_pp(p_rtp, name, flags, callback, cookie);
}
/*
* Source the file "name" from all directories in 'runtimepath'.
* "name" can contain wildcards.
* When "flags" has DIP_ALL: source all files, otherwise only the first one.
*
* return FAIL when no file could be sourced, OK otherwise.
*/
int
source_runtime(char_u *name, int flags)
{
return source_in_path(p_rtp, name, flags);
}
/*
* Just like source_runtime(), but use "path" instead of 'runtimepath'.
*/
int
source_in_path(char_u *path, char_u *name, int flags)
{
return do_in_path_and_pp(path, name, flags, source_callback, NULL);
}
/*
* Expand wildcards in "pat" and invoke do_source() for each match.
*/

View File

@ -449,18 +449,28 @@ vim_main2(void)
*/
if (p_lpl)
{
char_u *rtp_copy = NULL;
/* First add all package directories to 'runtimepath', so that their
* autoload directories can be found. Only if not done already with a
* :packloadall command. */
* :packloadall command.
* Make a copy of 'runtimepath', so that source_runtime does not use
* the pack directories. */
if (!did_source_packages)
{
rtp_copy = vim_strsave(p_rtp);
add_pack_start_dirs();
}
source_in_path(rtp_copy == NULL ? p_rtp : rtp_copy,
# ifdef VMS /* Somehow VMS doesn't handle the "**". */
source_runtime((char_u *)"plugin/*.vim", DIP_ALL | DIP_NOAFTER);
(char_u *)"plugin/*.vim",
# else
source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL | DIP_NOAFTER);
(char_u *)"plugin/**/*.vim",
# endif
DIP_ALL | DIP_NOAFTER);
TIME_MSG("loading plugins");
vim_free(rtp_copy);
/* Only source "start" packages if not done already with a :packloadall
* command. */

View File

@ -1636,7 +1636,9 @@ shift_delete_registers()
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_current = &y_regs[1];
if (!y_append)
y_previous = y_current;
y_regs[1].y_array = NULL; /* set register one to empty */
}

View File

@ -69,9 +69,10 @@ void ex_argdelete(exarg_T *eap);
void ex_listdo(exarg_T *eap);
void ex_compiler(exarg_T *eap);
void ex_runtime(exarg_T *eap);
int source_runtime(char_u *name, int flags);
int do_in_path(char_u *path, char_u *name, int flags, void (*callback)(char_u *fname, void *ck), void *cookie);
int do_in_runtimepath(char_u *name, int flags, void (*callback)(char_u *fname, void *ck), void *cookie);
int source_runtime(char_u *name, int flags);
int source_in_path(char_u *path, char_u *name, int flags);
void add_pack_start_dirs(void);
void load_start_packages(void);
void ex_packloadall(exarg_T *eap);

View File

@ -34,3 +34,14 @@ func Test_put_char_block2()
bw!
call setreg('a', a[0], a[1])
endfunc
func Test_put_lines()
new
let a = [ getreg('a'), getregtype('a') ]
call setline(1, ['Line 1', 'Line2', 'Line 3', ''])
exe 'norm! gg"add"AddG""p'
call assert_equal(['Line 3', '', 'Line 1', 'Line2'], getline(1,'$'))
" clean up
bw!
call setreg('a', a[0], a[1])
endfunc

View File

@ -23,28 +23,34 @@ func Test_after_comes_later()
\ 'set guioptions+=M',
\ 'let $HOME = "/does/not/exist"',
\ 'set loadplugins',
\ 'set rtp=Xhere,Xafter',
\ 'set rtp=Xhere,Xafter,Xanother',
\ 'set packpath=Xhere,Xafter',
\ 'set nomore',
\ 'let g:sequence = ""',
\ ]
let after = [
\ 'redir! > Xtestout',
\ 'scriptnames',
\ 'redir END',
\ 'redir! > Xsequence',
\ 'echo g:sequence',
\ 'redir END',
\ 'quit',
\ ]
call mkdir('Xhere/plugin', 'p')
call writefile(['let done = 1'], 'Xhere/plugin/here.vim')
call writefile(['let g:sequence .= "here "'], 'Xhere/plugin/here.vim')
call mkdir('Xanother/plugin', 'p')
call writefile(['let g:sequence .= "another "'], 'Xanother/plugin/another.vim')
call mkdir('Xhere/pack/foo/start/foobar/plugin', 'p')
call writefile(['let done = 1'], 'Xhere/pack/foo/start/foobar/plugin/foo.vim')
call writefile(['let g:sequence .= "pack "'], 'Xhere/pack/foo/start/foobar/plugin/foo.vim')
call mkdir('Xafter/plugin', 'p')
call writefile(['let done = 1'], 'Xafter/plugin/later.vim')
call writefile(['let g:sequence .= "after "'], 'Xafter/plugin/later.vim')
if RunVim(before, after, '')
let lines = readfile('Xtestout')
let expected = ['Xbefore.vim', 'here.vim', 'foo.vim', 'later.vim', 'Xafter.vim']
let expected = ['Xbefore.vim', 'here.vim', 'another.vim', 'foo.vim', 'later.vim', 'Xafter.vim']
let found = []
for line in lines
for one in expected
@ -56,8 +62,12 @@ func Test_after_comes_later()
call assert_equal(expected, found)
endif
call assert_equal('here another pack after', substitute(join(readfile('Xsequence', 1), ''), '\s\+$', '', ''))
call delete('Xtestout')
call delete('Xsequence')
call delete('Xhere', 'rf')
call delete('Xanother', 'rf')
call delete('Xafter', 'rf')
endfunc

View File

@ -418,7 +418,7 @@ func Test_bg_detection()
hi Normal ctermbg=15
call assert_equal('light', &bg)
" manually-set &bg takes precendence over auto-detection
" manually-set &bg takes precedence over auto-detection
set bg=light
hi Normal ctermbg=4
call assert_equal('light', &bg)
@ -461,7 +461,6 @@ func Test_syntax_hangs()
bwipe!
endfunc
func Test_conceal()
if !has('conceal')
return
@ -497,3 +496,27 @@ func Test_conceal()
set conceallevel&
bw!
endfunc
fun Test_synstack_synIDtrans()
new
setfiletype c
syntax on
call setline(1, ' /* A comment with a TODO */')
call assert_equal([], synstack(1, 1))
norm f/
call assert_equal(['cComment', 'cCommentStart'], map(synstack(line("."), col(".")), 'synIDattr(v:val, "name")'))
call assert_equal(['Comment', 'Comment'], map(synstack(line("."), col(".")), 'synIDattr(synIDtrans(v:val), "name")'))
norm fA
call assert_equal(['cComment'], map(synstack(line("."), col(".")), 'synIDattr(v:val, "name")'))
call assert_equal(['Comment'], map(synstack(line("."), col(".")), 'synIDattr(synIDtrans(v:val), "name")'))
norm fT
call assert_equal(['cComment', 'cTodo'], map(synstack(line("."), col(".")), 'synIDattr(v:val, "name")'))
call assert_equal(['Comment', 'Todo'], map(synstack(line("."), col(".")), 'synIDattr(synIDtrans(v:val), "name")'))
syn clear
bw!
endfunc

View File

@ -764,6 +764,14 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
682,
/**/
681,
/**/
680,
/**/
679,
/**/
678,
/**/

View File

@ -2282,7 +2282,7 @@ win_close(win_T *win, int free_buf)
int dir;
int help_window = FALSE;
tabpage_T *prev_curtab = curtab;
frame_T *win_frame = win->w_frame;
frame_T *win_frame = win->w_frame->fr_parent;
if (last_window())
{
@ -2462,8 +2462,7 @@ win_close(win_T *win, int free_buf)
if (p_ea && (*p_ead == 'b' || *p_ead == dir))
/* If the frame of the closed window contains the new current window,
* only resize that frame. Otherwise resize all windows. */
win_equal(curwin,
curwin->w_frame->fr_parent == win_frame->fr_parent, dir);
win_equal(curwin, curwin->w_frame->fr_parent == win_frame, dir);
else
win_comp_pos();
if (close_curwin)