Compare commits

...

7 Commits

Author SHA1 Message Date
Bram Moolenaar
5459129af2 patch 8.0.1489: there is no easy way to get the global directory
Problem:    There is no easy way to get the global directory, esp. if some
            windows have a local directory.
Solution:   Make getcwd(-1) return the global directory. (Andy Massimino,
            closes #2606)
2018-02-09 20:53:59 +01:00
Bram Moolenaar
0d20737732 patch 8.0.1488: emacs tags no longer work
Problem:    Emacs tags no longer work. (zdohnal)
Solution:   Do not skip over end of line.
2018-02-09 19:25:29 +01:00
Bram Moolenaar
8846ac5aed patch 8.0.1487: test 14 fails
Problem:    Test 14 fails.
Solution:   Fix of-by-one error.
2018-02-09 19:24:01 +01:00
Bram Moolenaar
82846a00ac patch 8.0.1486: accessing invalid memory with "it"
Problem:    Accessing invalid memory with "it". (Dominique Pelle)
Solution:   Avoid going over the end of the line. (Christian Brabandt,
            closes #2532)
2018-02-09 18:09:54 +01:00
Bram Moolenaar
9e33efd152 patch 8.0.1485: weird autocmd may cause arglist to be changed recursively
Problem:    Weird autocmd may cause arglist to be changed recursively.
Solution:   Prevent recursively changing the argument list. (Christian
            Brabandt, closes #2472)
2018-02-09 17:50:28 +01:00
Bram Moolenaar
a15ef4588c patch 8.0.1484: reduntant conditions
Problem:    Reduntant conditions.
Solution:   Remove them. (Dominique Pelle)
2018-02-09 16:46:00 +01:00
Bram Moolenaar
9d32276b52 patch 8.0.1483: searchpair() might return an invalid value on timeout
Problem:    Searchpair() might return an invalid value on timeout.
Solution:   When the second search times out, do not accept a match from the
            first search. (Daniel Hahler, closes #2552)
2018-02-09 16:04:25 +01:00
11 changed files with 110 additions and 18 deletions

View File

@@ -4484,10 +4484,13 @@ getcwd([{winnr} [, {tabnr}]])
Without arguments, for the current window.
With {winnr} return the local current directory of this window
in the current tab page.
in the current tab page. {winnr} can be the window number or
the |window-ID|.
If {winnr} is -1 return the name of the global working
directory. See also |haslocaldir()|.
With {winnr} and {tabnr} return the local current directory of
the window in the specified tab page.
{winnr} can be the window number or the |window-ID|.
Return an empty string if the arguments are invalid.
getfsize({fname}) *getfsize()*

View File

@@ -4613,16 +4613,21 @@ f_getcwd(typval_T *argvars, typval_T *rettv)
{
win_T *wp = NULL;
char_u *cwd;
int global = FALSE;
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
wp = find_tabwin(&argvars[0], &argvars[1]);
if (wp != NULL)
if (argvars[0].v_type == VAR_NUMBER && argvars[0].vval.v_number == -1)
global = TRUE;
else
wp = find_tabwin(&argvars[0], &argvars[1]);
if (wp != NULL && wp->w_localdir != NULL)
rettv->vval.v_string = vim_strsave(wp->w_localdir);
else if (wp != NULL || global)
{
if (wp->w_localdir != NULL)
rettv->vval.v_string = vim_strsave(wp->w_localdir);
else if (globaldir != NULL)
if (globaldir != NULL)
rettv->vval.v_string = vim_strsave(globaldir);
else
{

View File

@@ -8058,6 +8058,16 @@ alist_set(
int fnum_len)
{
int i;
static int recursive = 0;
if (recursive)
{
#ifdef FEAT_AUTOCMD
EMSG(_(e_au_recursive));
#endif
return;
}
++recursive;
alist_clear(al);
if (ga_grow(&al->al_ga, count) == OK)
@@ -8087,6 +8097,8 @@ alist_set(
FreeWild(count, files);
if (al == &global_alist)
arg_had_last = FALSE;
--recursive;
}
/*

View File

@@ -1594,6 +1594,9 @@ EXTERN char_u e_notset[] INIT(= N_("E764: Option '%s' is not set"));
EXTERN char_u e_invalidreg[] INIT(= N_("E850: Invalid register name"));
#endif
EXTERN char_u e_dirnotf[] INIT(= N_("E919: Directory not found in '%s': \"%s\""));
#ifdef FEAT_AUTOCMD
EXTERN char_u e_au_recursive[] INIT(= N_("E952: Autocommand caused recursive behavior"));
#endif
#ifdef FEAT_GUI_MAC
EXTERN short disallow_gui INIT(= FALSE);

View File

@@ -684,11 +684,11 @@ searchit(
&& pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count
&& pos->col < MAXCOL - 2)
{
ptr = ml_get_buf(buf, pos->lnum, FALSE) + pos->col;
if (*ptr == NUL)
ptr = ml_get_buf(buf, pos->lnum, FALSE);
if ((int)STRLEN(ptr) <= pos->col)
start_char_len = 1;
else
start_char_len = (*mb_ptr2len)(ptr);
start_char_len = (*mb_ptr2len)(ptr + pos->col);
}
#endif
else
@@ -973,7 +973,16 @@ searchit(
NULL, NULL
#endif
)) == 0)
{
#ifdef FEAT_RELTIME
/* If the search timed out, we did find a match
* but it might be the wrong one, so that's not
* OK. */
if (timed_out != NULL && *timed_out)
match_ok = FALSE;
#endif
break;
}
/* Need to get the line pointer again, a
* multi-line search may have made it invalid. */

View File

@@ -2958,12 +2958,9 @@ matching_line_len(char_u *lbuf)
char_u *p = lbuf + 1;
/* does the same thing as parse_match() */
p += STRLEN(p) + 2;
p += STRLEN(p) + 1;
#ifdef FEAT_EMACS_TAGS
if (*p)
p += STRLEN(p);
else
++p;
p += STRLEN(p) + 1;
#endif
return (p - lbuf) + STRLEN(p);
}

View File

@@ -523,7 +523,7 @@ ex_terminal(exarg_T *eap)
init_job_options(&opt);
cmd = eap->arg;
while (*cmd && *cmd == '+' && *(cmd + 1) == '+')
while (*cmd == '+' && *(cmd + 1) == '+')
{
char_u *p, *ep;
@@ -3259,8 +3259,7 @@ f_term_wait(typval_T *argvars, typval_T *rettv UNUSED)
return;
/* Get the job status, this will detect a job that finished. */
if ((buf->b_term->tl_job->jv_channel == NULL
|| !buf->b_term->tl_job->jv_channel->ch_keep_open)
if (!buf->b_term->tl_job->jv_channel->ch_keep_open
&& STRCMP(job_status(buf->b_term->tl_job), "dead") == 0)
{
/* The job is dead, keep reading channel I/O until the channel is

View File

@@ -37,6 +37,7 @@ function SetUp()
new
call mkdir('Xtopdir')
cd Xtopdir
let g:topdir = getcwd()
call mkdir('Xdir1')
call mkdir('Xdir2')
call mkdir('Xdir3')
@@ -56,36 +57,44 @@ function Test_GetCwd()
3wincmd w
lcd Xdir1
call assert_equal("a Xdir1 1", GetCwdInfo(0, 0))
call assert_equal(g:topdir, getcwd(-1))
wincmd W
call assert_equal("b Xtopdir 0", GetCwdInfo(0, 0))
call assert_equal(g:topdir, getcwd(-1))
wincmd W
lcd Xdir3
call assert_equal("c Xdir3 1", GetCwdInfo(0, 0))
call assert_equal("a Xdir1 1", GetCwdInfo(bufwinnr("a"), 0))
call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), 0))
call assert_equal("c Xdir3 1", GetCwdInfo(bufwinnr("c"), 0))
call assert_equal(g:topdir, getcwd(-1))
wincmd W
call assert_equal("a Xdir1 1", GetCwdInfo(bufwinnr("a"), tabpagenr()))
call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), tabpagenr()))
call assert_equal("c Xdir3 1", GetCwdInfo(bufwinnr("c"), tabpagenr()))
call assert_equal(g:topdir, getcwd(-1))
tabnew x
new y
new z
3wincmd w
call assert_equal("x Xtopdir 0", GetCwdInfo(0, 0))
call assert_equal(g:topdir, getcwd(-1))
wincmd W
lcd Xdir2
call assert_equal("y Xdir2 1", GetCwdInfo(0, 0))
call assert_equal(g:topdir, getcwd(-1))
wincmd W
lcd Xdir3
call assert_equal("z Xdir3 1", GetCwdInfo(0, 0))
call assert_equal("x Xtopdir 0", GetCwdInfo(bufwinnr("x"), 0))
call assert_equal("y Xdir2 1", GetCwdInfo(bufwinnr("y"), 0))
call assert_equal("z Xdir3 1", GetCwdInfo(bufwinnr("z"), 0))
call assert_equal(g:topdir, getcwd(-1))
let tp_nr = tabpagenr()
tabrewind
call assert_equal("x Xtopdir 0", GetCwdInfo(3, tp_nr))
call assert_equal("y Xdir2 1", GetCwdInfo(2, tp_nr))
call assert_equal("z Xdir3 1", GetCwdInfo(1, tp_nr))
call assert_equal(g:topdir, getcwd(-1))
endfunc

View File

@@ -229,4 +229,32 @@ func Test_tag_file_encoding()
call delete('Xtags1')
endfunc
func Test_tagjump_etags()
if !has('emacs_tags')
return
endif
call writefile([
\ "void foo() {}",
\ "int main(int argc, char **argv)",
\ "{",
\ "\tfoo();",
\ "\treturn 0;",
\ "}",
\ ], 'Xmain.c')
call writefile([
\ "\x0c",
\ "Xmain.c,64",
\ "void foo() {}\x7ffoo\x011,0",
\ "int main(int argc, char **argv)\x7fmain\x012,14",
\ ], 'Xtags')
set tags=Xtags
ta foo
call assert_equal('void foo() {}', getline('.'))
call delete('Xtags')
call delete('Xmain.c')
bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -152,3 +152,16 @@ func Test_match()
call assert_equal(3 , match('abc', '\zs', 3, 1))
call assert_equal(-1, match('abc', '\zs', 4, 1))
endfunc
" This was causing an illegal memory access
func Test_inner_tag()
new
norm ixxx
call feedkeys("v", 'xt')
insert
x
x
.
norm it
q!
endfunc

View File

@@ -771,6 +771,20 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1489,
/**/
1488,
/**/
1487,
/**/
1486,
/**/
1485,
/**/
1484,
/**/
1483,
/**/
1482,
/**/