diff options
author | Scott Prager <splinterofchaos@gmail.com> | 2014-09-13 14:32:32 -0400 |
---|---|---|
committer | Scott Prager <splinterofchaos@gmail.com> | 2014-09-13 18:28:32 -0400 |
commit | def28adfdd7a9ee643224e36f3f601f9f7222f46 (patch) | |
tree | 11123540c97d3eb7c4eca9bf62d1b4cd21cec3d1 /src | |
parent | 1761a4af711410076e6fdb5f727a83ee54ff5988 (diff) | |
download | rneovim-def28adfdd7a9ee643224e36f3f601f9f7222f46.tar.gz rneovim-def28adfdd7a9ee643224e36f3f601f9f7222f46.tar.bz2 rneovim-def28adfdd7a9ee643224e36f3f601f9f7222f46.zip |
vim-patch:7.4.312
Problem: Cannot figure out what argument list is being used for a window.
Solution: Add the arglistid() function. (Marcin Szamotulski)
https://code.google.com/p/vim/source/detail?r=v7-4-312
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/buffer_defs.h | 1 | ||||
-rw-r--r-- | src/nvim/eval.c | 27 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 1 | ||||
-rw-r--r-- | src/nvim/globals.h | 1 | ||||
-rw-r--r-- | src/nvim/main.c | 1 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
6 files changed, 32 insertions, 1 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index de1b0985bb..84d55fb730 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -255,6 +255,7 @@ struct wininfo_S { typedef struct arglist { garray_T al_ga; /* growarray with the array of file names */ int al_refcount; /* number of windows using this arglist */ + int id; ///< id of this arglist } alist_T; /* diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d8c2e73150..11e620c639 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6311,6 +6311,7 @@ static struct fst { {"append", 2, 2, f_append}, {"argc", 0, 0, f_argc}, {"argidx", 0, 0, f_argidx}, + {"arglistid", 0, 2, f_arglistid}, {"argv", 0, 1, f_argv}, {"asin", 1, 1, f_asin}, /* WJMc */ {"atan", 1, 1, f_atan}, @@ -7203,6 +7204,32 @@ static void f_argidx(typval_T *argvars, typval_T *rettv) rettv->vval.v_number = curwin->w_arg_idx; } +/// "arglistid" function +static void f_arglistid(typval_T *argvars, typval_T *rettv) +{ + rettv->vval.v_number = -1; + if (argvars[0].v_type != VAR_UNKNOWN) { + tabpage_T *tp = NULL; + if (argvars[1].v_type != VAR_UNKNOWN) { + long n = get_tv_number(&argvars[1]); + if (n >= 0) { + tp = find_tabpage(n); + } + } else { + tp = curtab; + } + + if (tp != NULL) { + win_T *wp = find_win_by_nr(&argvars[0], tp); + if (wp != NULL) { + rettv->vval.v_number = wp->w_alist->id; + } + } + } else { + rettv->vval.v_number = curwin->w_alist->id; + } +} + /* * "argv(nr)" function */ diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index dacd0f9e31..1117b6fbcf 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5504,6 +5504,7 @@ void alist_new(void) { curwin->w_alist = xmalloc(sizeof(*curwin->w_alist)); curwin->w_alist->al_refcount = 1; + curwin->w_alist->id = ++max_alist_id; alist_init(curwin->w_alist); } diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 49a4a2f604..674786ff08 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -568,6 +568,7 @@ EXTERN int mf_dont_release INIT(= FALSE); /* don't release blocks */ * to this when the window is using the global argument list. */ EXTERN alist_T global_alist; /* global argument list */ +EXTERN int max_alist_id INIT(= 0); ///< the previous argument list id EXTERN int arg_had_last INIT(= FALSE); /* accessed last file in global_alist */ diff --git a/src/nvim/main.c b/src/nvim/main.c index fc1826975a..7dc299e73b 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -192,6 +192,7 @@ int main(int argc, char **argv) init_yank(); /* init yank buffers */ alist_init(&global_alist); /* Init the argument list to empty. */ + global_alist.id = 0; /* * Set the default values for the options. diff --git a/src/nvim/version.c b/src/nvim/version.c index fc0b85fde9..2ca9208469 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -283,7 +283,7 @@ static int included_patches[] = { 315, 314, //313, - //312, + 312, //311, //310, 309, |