diff options
Diffstat (limited to 'src')
47 files changed, 272 insertions, 216 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index b515c4e1e4..46687f344c 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -937,8 +937,9 @@ struct matchitem { */ struct window_S { uint64_t handle; - buf_T *w_buffer; /* buffer we are a window into (used - often, keep it the first item!) */ + int w_id; ///< unique window ID + buf_T *w_buffer; ///< buffer we are a window into (used + ///< often, keep it the first item!) synblock_T *w_s; /* for :ownsyntax */ diff --git a/src/nvim/eval.c b/src/nvim/eval.c index a5333d74be..7839a7f645 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6987,6 +6987,10 @@ static struct fst { { "virtcol", 1, 1, f_virtcol }, { "visualmode", 0, 1, f_visualmode }, { "wildmenumode", 0, 0, f_wildmenumode }, + { "win_getid", 0, 2, f_win_getid }, + { "win_gotoid", 1, 1, f_win_gotoid }, + { "win_id2tabwin", 1, 1, f_win_id2tabwin }, + { "win_id2win", 1, 1, f_win_id2win }, { "winbufnr", 1, 1, f_winbufnr }, { "wincol", 0, 0, f_wincol }, { "winheight", 1, 1, f_winheight }, @@ -17150,6 +17154,32 @@ static void f_wildmenumode(typval_T *argvars, typval_T *rettv) rettv->vval.v_number = 1; } +/// "win_getid()" function +static void f_win_getid(typval_T *argvars, typval_T *rettv) +{ + rettv->vval.v_number = win_getid(argvars); +} + +/// "win_gotoid()" function +static void f_win_gotoid(typval_T *argvars, typval_T *rettv) +{ + rettv->vval.v_number = win_gotoid(argvars); +} + +/// "win_id2tabwin()" function +static void f_win_id2tabwin(typval_T *argvars, typval_T *rettv) +{ + if (rettv_list_alloc(rettv) != FAIL) { + win_id2tabwin(argvars, rettv->vval.v_list); + } +} + +/// "win_id2win()" function +static void f_win_id2win(typval_T *argvars, typval_T *rettv) +{ + rettv->vval.v_number = win_id2win(argvars); +} + /* * "winbufnr(nr)" function */ @@ -18437,7 +18467,7 @@ static void init_tv(typval_T *varp) * caller of incompatible types: it sets *denote to TRUE if "denote" * is not NULL or returns -1 otherwise. */ -static long get_tv_number(typval_T *varp) +long get_tv_number(typval_T *varp) { int error = FALSE; diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 154558b332..3b598bd64b 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -493,22 +493,14 @@ readfile ( curbuf->b_flags &= ~(BF_NEW | BF_NEW_W); } - /* - * Check readonly by trying to open the file for writing. - * If this fails, we know that the file is readonly. - */ - file_readonly = FALSE; + // Check readonly. + file_readonly = false; if (!read_buffer && !read_stdin) { - if (!newfile || readonlymode) { - file_readonly = TRUE; - } else if ((fd = os_open((char *)fname, O_RDWR, 0)) < 0) { - // opening in readwrite mode failed => file is readonly - file_readonly = TRUE; - } - if (file_readonly == TRUE) { - // try to open readonly - fd = os_open((char *)fname, O_RDONLY, 0); + if (!newfile || readonlymode || !(perm & 0222) + || !os_file_is_writable((char *)fname)) { + file_readonly = true; } + fd = os_open((char *)fname, O_RDONLY, 0); } if (fd < 0) { /* cannot open at all */ diff --git a/src/nvim/message.c b/src/nvim/message.c index 3c310ed309..725c6b080a 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -702,16 +702,9 @@ int delete_first_msg(void) void ex_messages(exarg_T *eap) { struct msg_hist *p; - const char *s; msg_hist_off = TRUE; - s = os_getenv("LANG"); - if (s) - msg_attr((char_u *) - _("Messages maintainer: Bram Moolenaar <Bram@vim.org>"), - hl_attr(HLF_T)); - for (p = first_msg_hist; p != NULL && !got_int; p = p->next) if (p->msg != NULL) msg_attr(p->msg, p->attr); diff --git a/src/nvim/option.c b/src/nvim/option.c index de53b0b1f4..6baf8c65ce 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -236,6 +236,7 @@ typedef struct vimoption { #define P_NO_ML 0x2000000U ///< not allowed in modeline #define P_CURSWANT 0x4000000U ///< update curswant required; not needed ///< when there is a redraw flag +#define P_NO_DEF_EXP 0x8000000U ///< Do not expand default value. #define HIGHLIGHT_INIT \ "8:SpecialKey,~:EndOfBuffer,z:TermCursor,Z:TermCursorNC,@:NonText," \ @@ -676,15 +677,18 @@ void set_init_1(void) #endif false); - char *backupdir = stdpaths_user_data_subpath("backup", 0); + char *backupdir = stdpaths_user_data_subpath("backup", 0, true); const size_t backupdir_len = strlen(backupdir); backupdir = xrealloc(backupdir, backupdir_len + 3); memmove(backupdir + 2, backupdir, backupdir_len + 1); memmove(backupdir, ".,", 2); - set_string_default("viewdir", stdpaths_user_data_subpath("view", 0), true); + set_string_default("viewdir", stdpaths_user_data_subpath("view", 0, true), + true); set_string_default("backupdir", backupdir, true); - set_string_default("directory", stdpaths_user_data_subpath("swap", 2), true); - set_string_default("undodir", stdpaths_user_data_subpath("undo", 0), true); + set_string_default("directory", stdpaths_user_data_subpath("swap", 2, true), + true); + set_string_default("undodir", stdpaths_user_data_subpath("undo", 0, true), + true); // Set default for &runtimepath. All necessary expansions are performed in // this function. set_runtimepath_default(); @@ -726,6 +730,9 @@ void set_init_1(void) * default. */ for (opt_idx = 0; options[opt_idx].fullname; opt_idx++) { + if (options[opt_idx].flags & P_NO_DEF_EXP) { + continue; + } char *p; if ((options[opt_idx].flags & P_GETTEXT) && options[opt_idx].var != NULL) { @@ -1473,16 +1480,19 @@ do_set ( * default value was already expanded, only * required when an environment variable was set * later */ - if (newval == NULL) + new_value_alloced = true; + if (newval == NULL) { newval = empty_option; - else { + } else if (!(options[opt_idx].flags | P_NO_DEF_EXP)) { s = option_expand(opt_idx, newval); - if (s == NULL) + if (s == NULL) { s = newval; + } newval = vim_strsave(s); + } else { + newval = (char_u *)xstrdup((char *)newval); } - new_value_alloced = TRUE; - } else if (nextchar == '<') { /* set to global val */ + } else if (nextchar == '<') { // set to global val newval = vim_strsave(*(char_u **)get_varp_scope( &(options[opt_idx]), OPT_GLOBAL)); new_value_alloced = TRUE; @@ -2020,13 +2030,15 @@ static char_u *option_expand(int opt_idx, char_u *val) if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) return NULL; - /* If val is longer than MAXPATHL no meaningful expansion can be done, - * expand_env() would truncate the string. */ - if (val != NULL && STRLEN(val) > MAXPATHL) - return NULL; - - if (val == NULL) + if (val == NULL) { val = *(char_u **)options[opt_idx].var; + } + + // If val is longer than MAXPATHL no meaningful expansion can be done, + // expand_env() would truncate the string. + if (val == NULL || STRLEN(val) > MAXPATHL) { + return NULL; + } /* * Expanding this with NameBuff, expand_env() must not be passed IObuff. diff --git a/src/nvim/option.h b/src/nvim/option.h index 5c2b2662b5..3a43b859a8 100644 --- a/src/nvim/option.h +++ b/src/nvim/option.h @@ -6,17 +6,18 @@ #define BCO_ALWAYS 2 /* always copy the options */ #define BCO_NOHELP 4 /* don't touch the help related options */ -/* - * "flags" values for option-setting functions. - * When OPT_GLOBAL and OPT_LOCAL are both missing, set both local and global - * values, get local value. - */ -#define OPT_FREE 1 /* free old value if it was allocated */ -#define OPT_GLOBAL 2 /* use global value */ -#define OPT_LOCAL 4 /* use local value */ -#define OPT_MODELINE 8 /* option in modeline */ -#define OPT_WINONLY 16 /* only set window-local options */ -#define OPT_NOWIN 32 /* don't set window-local options */ +/// Flags for option-setting functions +/// +/// When OPT_GLOBAL and OPT_LOCAL are both missing, set both local and global +/// values, get local value. +typedef enum { + OPT_FREE = 1, ///< Free old value if it was allocated. + OPT_GLOBAL = 2, ///< Use global value. + OPT_LOCAL = 4, ///< Use local value. + OPT_MODELINE = 8, ///< Option in modeline. + OPT_WINONLY = 16, ///< Only set window-local options. + OPT_NOWIN = 32, ///< Don’t set window-local options. +} OptionFlags; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "option.h.generated.h" diff --git a/src/nvim/options.lua b/src/nvim/options.lua index d19af4f73f..060ec8c1e1 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -165,7 +165,7 @@ return { deny_duplicates=true, secure=true, vi_def=true, - expand=true, + expand='nodefault', varname='p_bdir', defaults={if_true={vi=''}} }, @@ -616,7 +616,7 @@ return { deny_duplicates=true, secure=true, vi_def=true, - expand=true, + expand='nodefault', varname='p_dir', defaults={if_true={vi=''}} }, @@ -1891,7 +1891,7 @@ return { deny_duplicates=true, secure=true, vi_def=true, - expand=true, + expand='nodefault', varname='p_rtp', defaults={if_true={vi=''}} }, @@ -2507,7 +2507,7 @@ return { deny_duplicates=true, secure=true, vi_def=true, - expand=true, + expand='nodefault', varname='p_udir', defaults={if_true={vi=''}} }, @@ -2568,7 +2568,7 @@ return { type='string', scope={'global'}, secure=true, vi_def=true, - expand=true, + expand='nodefault', varname='p_vdir', defaults={if_true={vi=''}} }, diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index 81ceb919c4..10b3f4c091 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -100,18 +100,30 @@ char *stdpaths_user_conf_subpath(const char *fname) /// /// @param[in] fname New component of the path. /// @param[in] trailing_pathseps Amount of trailing path separators to add. +/// @param[in] escape_commas If true, all commas will be escaped. /// -/// @return [allocated] `$XDG_DATA_HOME/nvim/{fname}` +/// @return [allocated] `$XDG_DATA_HOME/nvim/{fname}`. char *stdpaths_user_data_subpath(const char *fname, - const size_t trailing_pathseps) + const size_t trailing_pathseps, + const bool escape_commas) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET { char *ret = concat_fnames_realloc(get_xdg_home(kXDGDataHome), fname, true); - if (trailing_pathseps) { - const size_t len = strlen(ret); - ret = xrealloc(ret, len + trailing_pathseps + 1); - memset(ret + len, PATHSEP, trailing_pathseps); - ret[len + trailing_pathseps] = NUL; + const size_t len = strlen(ret); + const size_t numcommas = (escape_commas ? memcnt(ret, ',', len) : 0); + if (numcommas || trailing_pathseps) { + ret = xrealloc(ret, len + trailing_pathseps + numcommas + 1); + for (size_t i = 0 ; i < len + numcommas ; i++) { + if (ret[i] == ',') { + memmove(ret + i + 1, ret + i, len - i + numcommas); + ret[i] = '\\'; + i++; + } + } + if (trailing_pathseps) { + memset(ret + len + numcommas, PATHSEP, trailing_pathseps); + } + ret[len + trailing_pathseps + numcommas] = NUL; } return ret; } diff --git a/src/nvim/po/af.po b/src/nvim/po/af.po index 6bb93b9e02..8f06ed178c 100644 --- a/src/nvim/po/af.po +++ b/src/nvim/po/af.po @@ -4305,10 +4305,6 @@ msgstr "rel %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: Ongeldige registernaam: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Boodskappe onderhouers: Danie Roux en Jean Jordaan <droux@tuks.co.za>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Onderbreek: " diff --git a/src/nvim/po/ca.po b/src/nvim/po/ca.po index 79434cfdcd..2b0d7611d0 100644 --- a/src/nvim/po/ca.po +++ b/src/nvim/po/ca.po @@ -4293,10 +4293,6 @@ msgstr "lnia %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: El nom de registre no s vlid: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Traducci dels missatges: Ernest Adrogu <eadrogue@gmx.net>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Interrupci: " diff --git a/src/nvim/po/cs.cp1250.po b/src/nvim/po/cs.cp1250.po index 1e62034317..339dfe6ae5 100644 --- a/src/nvim/po/cs.cp1250.po +++ b/src/nvim/po/cs.cp1250.po @@ -4378,10 +4378,6 @@ msgstr "dek %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: '%s' nen ppustn jmno registru" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Sprvce zprv: Bram Moolenaar <Bram@vim.org>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Peruen: " diff --git a/src/nvim/po/cs.po b/src/nvim/po/cs.po index dd7016fedb..5c19eecf32 100644 --- a/src/nvim/po/cs.po +++ b/src/nvim/po/cs.po @@ -4378,10 +4378,6 @@ msgstr "dek %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: '%s' nen ppustn jmno registru" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Sprvce zprv: Bram Moolenaar <Bram@vim.org>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Peruen: " diff --git a/src/nvim/po/en_GB.po b/src/nvim/po/en_GB.po index b4b38e11e3..41e4cd895d 100644 --- a/src/nvim/po/en_GB.po +++ b/src/nvim/po/en_GB.po @@ -4128,10 +4128,6 @@ msgstr "" msgid "E354: Invalid register name: '%s'" msgstr "" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Messages maintainer: Mike Williams <mrw@eandem.co.uk>" - #: ../message.c:986 msgid "Interrupt: " msgstr "" diff --git a/src/nvim/po/eo.po b/src/nvim/po/eo.po index 6bc76506ae..153eacc7b8 100644 --- a/src/nvim/po/eo.po +++ b/src/nvim/po/eo.po @@ -4295,10 +4295,6 @@ msgstr "linio %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: Nevalida nomo de reĝistro: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Flegado de mesaĝoj: Dominique PELLÉ <dominique.pelle@gmail.com>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Interrompo: " diff --git a/src/nvim/po/es.po b/src/nvim/po/es.po index 8a9c86e88d..9a3bfa6894 100644 --- a/src/nvim/po/es.po +++ b/src/nvim/po/es.po @@ -4377,12 +4377,6 @@ msgstr "línea %4ld" msgid "E354: Invalid register name: '%s'" msgstr "E354: Nombre de registro no válido: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "" -"Traducción: Proyecto vim-doc-es <http://www.assembla.com/wiki/show/vim-doc-" -"es>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Interrupción: " diff --git a/src/nvim/po/fi.po b/src/nvim/po/fi.po index d4082135aa..6dfaa78a77 100644 --- a/src/nvim/po/fi.po +++ b/src/nvim/po/fi.po @@ -4275,10 +4275,6 @@ msgstr "rivi %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: Virheellinen rekisterin nimi: %s" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Knnksen yllpitj: Flammie Pirinen <flammie@iki.fi>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Keskeytys: " diff --git a/src/nvim/po/fr.po b/src/nvim/po/fr.po index 41efd5c5e3..a16a939117 100644 --- a/src/nvim/po/fr.po +++ b/src/nvim/po/fr.po @@ -4479,10 +4479,6 @@ msgid "E354: Invalid register name: '%s'" msgstr "E354: Nom de registre invalide : '%s'" # DB - todo : mettre jour ? -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Maintenance des messages : Dominique Pell <dominique.pelle@gmail.com>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Interruption : " diff --git a/src/nvim/po/ga.po b/src/nvim/po/ga.po index f7117c6e86..d94b788449 100644 --- a/src/nvim/po/ga.po +++ b/src/nvim/po/ga.po @@ -4286,11 +4286,6 @@ msgstr "lne %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: Ainm neamhbhail tabhaill: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "" -"Cothaitheoir na dteachtaireachta: Kevin P. Scannell <scannell@slu.edu>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Idirbhriseadh: " diff --git a/src/nvim/po/it.po b/src/nvim/po/it.po index 084102da60..119a8f02ff 100644 --- a/src/nvim/po/it.po +++ b/src/nvim/po/it.po @@ -4294,10 +4294,6 @@ msgstr "riga %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: Nome registro non valido: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Manutentore messaggi: Vlad Sandrini <marco@sandrini.biz>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Interruzione: " diff --git a/src/nvim/po/ja.euc-jp.po b/src/nvim/po/ja.euc-jp.po index 85042e3506..e8d60d4438 100644 --- a/src/nvim/po/ja.euc-jp.po +++ b/src/nvim/po/ja.euc-jp.po @@ -4258,10 +4258,6 @@ msgstr " %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: ̵ʥ쥸̾: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "ܸå/ƽ: ¼ Ϻ <koron.kaoriya@gmail.com>" - #: ../message.c:986 msgid "Interrupt: " msgstr ": " diff --git a/src/nvim/po/ja.po b/src/nvim/po/ja.po index 0326f33bb5..fd3690f9bf 100644 --- a/src/nvim/po/ja.po +++ b/src/nvim/po/ja.po @@ -4257,10 +4257,6 @@ msgstr "行 %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: 無効なレジスタ名: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "日本語メッセージ翻訳/監修: 村岡 太郎 <koron.kaoriya@gmail.com>" - #: ../message.c:986 msgid "Interrupt: " msgstr "割込み: " diff --git a/src/nvim/po/ja.sjis.po b/src/nvim/po/ja.sjis.po index 16a5d2ce36..c9fd35292c 100644 --- a/src/nvim/po/ja.sjis.po +++ b/src/nvim/po/ja.sjis.po @@ -4261,10 +4261,6 @@ msgstr "s %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: ȃWX^: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "{ꃁbZ[W|/ďC: Y <koron.kaoriya@gmail.com>" - #: ../message.c:986 msgid "Interrupt: " msgstr ": " diff --git a/src/nvim/po/ko.UTF-8.po b/src/nvim/po/ko.UTF-8.po index 149286eda8..3ed659208b 100644 --- a/src/nvim/po/ko.UTF-8.po +++ b/src/nvim/po/ko.UTF-8.po @@ -4224,10 +4224,6 @@ msgstr "%4ld 줄:" msgid "E354: Invalid register name: '%s'" msgstr "E354: 잘못된 레지스터 이름: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "메시지 관리자: Bram Moolenaar <Bram@vim.org>" - #: ../message.c:986 msgid "Interrupt: " msgstr "중단: " diff --git a/src/nvim/po/ko.po b/src/nvim/po/ko.po index b6aaf37bbb..e97e90642c 100644 --- a/src/nvim/po/ko.po +++ b/src/nvim/po/ko.po @@ -4224,10 +4224,6 @@ msgstr "%4ld :" msgid "E354: Invalid register name: '%s'" msgstr "E354: ߸ ̸: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr " : Bram Moolenaar <Bram@vim.org>" - #: ../message.c:986 msgid "Interrupt: " msgstr "ߴ: " diff --git a/src/nvim/po/nb.po b/src/nvim/po/nb.po index ce635e098c..76e42ddcd6 100644 --- a/src/nvim/po/nb.po +++ b/src/nvim/po/nb.po @@ -4275,11 +4275,6 @@ msgstr "linje %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: Ugyldig registernavn: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "" -"Vedlikeholder for norsk oversettelse: yvind A. Holm <sunny@sunbase.org>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Avbryt: " diff --git a/src/nvim/po/nl.po b/src/nvim/po/nl.po index ea609c0f69..6013b847cb 100644 --- a/src/nvim/po/nl.po +++ b/src/nvim/po/nl.po @@ -4282,10 +4282,6 @@ msgstr "regel %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Vertaald door: Erwin Poeze <erwin.poeze@gmail.com>" - #: ../message.c:986 msgid "Interrupt: " msgstr "" diff --git a/src/nvim/po/no.po b/src/nvim/po/no.po index ce635e098c..76e42ddcd6 100644 --- a/src/nvim/po/no.po +++ b/src/nvim/po/no.po @@ -4275,11 +4275,6 @@ msgstr "linje %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: Ugyldig registernavn: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "" -"Vedlikeholder for norsk oversettelse: yvind A. Holm <sunny@sunbase.org>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Avbryt: " diff --git a/src/nvim/po/pl.UTF-8.po b/src/nvim/po/pl.UTF-8.po index 68cb9e72d5..2536efb422 100644 --- a/src/nvim/po/pl.UTF-8.po +++ b/src/nvim/po/pl.UTF-8.po @@ -4243,10 +4243,6 @@ msgstr "wiersz %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: Niewłaściwa nazwa rejestru: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Opiekun komunikatów: Mikołaj Machowski <mikmach@wp.pl>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Przerwanie: " diff --git a/src/nvim/po/pl.cp1250.po b/src/nvim/po/pl.cp1250.po index 3fcdbfb87d..30835637d0 100644 --- a/src/nvim/po/pl.cp1250.po +++ b/src/nvim/po/pl.cp1250.po @@ -4243,10 +4243,6 @@ msgstr "wiersz %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: Niewaciwa nazwa rejestru: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Opiekun komunikatw: Mikoaj Machowski <mikmach@wp.pl>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Przerwanie: " diff --git a/src/nvim/po/pl.po b/src/nvim/po/pl.po index 2a2d12daac..c5734f0c49 100644 --- a/src/nvim/po/pl.po +++ b/src/nvim/po/pl.po @@ -4243,10 +4243,6 @@ msgstr "wiersz %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: Niewaciwa nazwa rejestru: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Opiekun komunikatw: Mikoaj Machowski <mikmach@wp.pl>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Przerwanie: " diff --git a/src/nvim/po/ru.cp1251.po b/src/nvim/po/ru.cp1251.po index 29e8c83ee6..b1005bd0e6 100644 --- a/src/nvim/po/ru.cp1251.po +++ b/src/nvim/po/ru.cp1251.po @@ -4283,12 +4283,6 @@ msgstr " %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: : '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "" -" : <vrr@users.sourceforge." -"net>, <alyoshin.s@gmail.com>" - #: ../message.c:986 msgid "Interrupt: " msgstr ": " diff --git a/src/nvim/po/ru.po b/src/nvim/po/ru.po index c8146e8c47..2511ef2c46 100644 --- a/src/nvim/po/ru.po +++ b/src/nvim/po/ru.po @@ -4281,12 +4281,6 @@ msgstr "строка %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: Недопустимое имя регистра: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "" -"Перевод сообщений на русский язык: Василий Рагозин <vrr@users.sourceforge." -"net>, Сергей Алёшин <alyoshin.s@gmail.com>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Прерывание: " diff --git a/src/nvim/po/sk.cp1250.po b/src/nvim/po/sk.cp1250.po index e3b7508cdc..b1b0bb6ade 100644 --- a/src/nvim/po/sk.cp1250.po +++ b/src/nvim/po/sk.cp1250.po @@ -4273,10 +4273,6 @@ msgstr "riadok %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: '%s' nie je prstupn meno registru" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Sprvca prekladu: Lubomir Host <rajo@platon.sk>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Preruenie: " diff --git a/src/nvim/po/sk.po b/src/nvim/po/sk.po index 53f8a7b911..206e3e3ef6 100644 --- a/src/nvim/po/sk.po +++ b/src/nvim/po/sk.po @@ -4273,10 +4273,6 @@ msgstr "riadok %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: '%s' nie je prstupn meno registru" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Sprvca prekladu: Lubomir Host <rajo@platon.sk>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Preruenie: " diff --git a/src/nvim/po/uk.cp1251.po b/src/nvim/po/uk.cp1251.po index 2c6f3423ae..0b5668cfc5 100644 --- a/src/nvim/po/uk.cp1251.po +++ b/src/nvim/po/uk.cp1251.po @@ -4362,10 +4362,6 @@ msgstr " %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: : '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr ": <sakhnik@gmail.com>" - #: ../message.c:986 msgid "Interrupt: " msgstr ": " diff --git a/src/nvim/po/uk.po b/src/nvim/po/uk.po index eaa3a5bfa9..73d43b14c5 100644 --- a/src/nvim/po/uk.po +++ b/src/nvim/po/uk.po @@ -4362,10 +4362,6 @@ msgstr "рядок %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: Неправильна назва регістру: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Українізація: Анатолій Сахнік <sakhnik@gmail.com>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Перервано: " diff --git a/src/nvim/po/vi.po b/src/nvim/po/vi.po index a720510426..49c6765843 100644 --- a/src/nvim/po/vi.po +++ b/src/nvim/po/vi.po @@ -4311,11 +4311,6 @@ msgstr "dòng %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: Tên sổ đăng ký không cho phép: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "" -"Bản dịch các thông báo sang tiếng Việt: Phan Vĩnh Thịnh <teppi@vnlinux.org>" - #: ../message.c:986 msgid "Interrupt: " msgstr "Gián đoạn: " diff --git a/src/nvim/po/zh_CN.UTF-8.po b/src/nvim/po/zh_CN.UTF-8.po index 82b895d9d6..e88efed8e3 100644 --- a/src/nvim/po/zh_CN.UTF-8.po +++ b/src/nvim/po/zh_CN.UTF-8.po @@ -4264,10 +4264,6 @@ msgstr "第 %4ld 行:" msgid "E354: Invalid register name: '%s'" msgstr "E354: 无效的寄存器名: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "简体中文消息维护者: Yuheng Xie <elephant@linux.net.cn>" - #: ../message.c:986 msgid "Interrupt: " msgstr "已中断: " diff --git a/src/nvim/po/zh_CN.cp936.po b/src/nvim/po/zh_CN.cp936.po index cf66010c71..e5351cc22a 100644 --- a/src/nvim/po/zh_CN.cp936.po +++ b/src/nvim/po/zh_CN.cp936.po @@ -4265,10 +4265,6 @@ msgstr " %4ld :" msgid "E354: Invalid register name: '%s'" msgstr "E354: ЧļĴ: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Ϣά: Yuheng Xie <elephant@linux.net.cn>" - #: ../message.c:986 msgid "Interrupt: " msgstr "ж: " diff --git a/src/nvim/po/zh_CN.po b/src/nvim/po/zh_CN.po index 254ebbce6b..6cc4dd42ac 100644 --- a/src/nvim/po/zh_CN.po +++ b/src/nvim/po/zh_CN.po @@ -4265,10 +4265,6 @@ msgstr " %4ld :" msgid "E354: Invalid register name: '%s'" msgstr "E354: ЧļĴ: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "Ϣά: Yuheng Xie <elephant@linux.net.cn>" - #: ../message.c:986 msgid "Interrupt: " msgstr "ж: " diff --git a/src/nvim/po/zh_TW.UTF-8.po b/src/nvim/po/zh_TW.UTF-8.po index 79e09c83d1..da86d80c27 100644 --- a/src/nvim/po/zh_TW.UTF-8.po +++ b/src/nvim/po/zh_TW.UTF-8.po @@ -4304,12 +4304,6 @@ msgstr "行 %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: 暫存器名稱錯誤: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "" -"正體中文訊息維護者: Francis S.Lin <piaip@csie.ntu.edu." -"tw>, Cecil Sheng <b7506022@csie.ntu.edu.tw>" - #: ../message.c:986 msgid "Interrupt: " msgstr "已中斷: " diff --git a/src/nvim/po/zh_TW.po b/src/nvim/po/zh_TW.po index 07d510c0c6..977f18086e 100644 --- a/src/nvim/po/zh_TW.po +++ b/src/nvim/po/zh_TW.po @@ -4296,12 +4296,6 @@ msgstr " %4ld:" msgid "E354: Invalid register name: '%s'" msgstr "E354: ȦsWٿ~: '%s'" -#: ../message.c:745 -msgid "Messages maintainer: Bram Moolenaar <Bram@vim.org>" -msgstr "" -"餤T@: Francis S.Lin <piaip@csie.ntu.edu." -"tw>, Cecil Sheng <b7506022@csie.ntu.edu.tw>" - #: ../message.c:986 msgid "Interrupt: " msgstr "w_: " diff --git a/src/nvim/shada.c b/src/nvim/shada.c index b5921eb810..fe62f06e59 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -1524,7 +1524,7 @@ static const char *shada_get_default_file(void) FUNC_ATTR_WARN_UNUSED_RESULT { if (default_shada_file == NULL) { - char *shada_dir = stdpaths_user_data_subpath("shada", 0); + char *shada_dir = stdpaths_user_data_subpath("shada", 0, false); default_shada_file = concat_fnames_realloc(shada_dir, "main.shada", true); } return default_shada_file; diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 9a0bba83fe..4979aae57a 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -39,6 +39,7 @@ NEW_TESTS = \ test_timers.res \ test_viml.res \ test_visual.res \ + test_window_id.res \ test_alot.res SCRIPTS_GUI := test16.out diff --git a/src/nvim/testdir/test_window_id.vim b/src/nvim/testdir/test_window_id.vim new file mode 100644 index 0000000000..b9e9f45c49 --- /dev/null +++ b/src/nvim/testdir/test_window_id.vim @@ -0,0 +1,71 @@ +" Test using the window ID. + +func Test_win_getid() + edit one + let id1 = win_getid() + split two + let id2 = win_getid() + split three + let id3 = win_getid() + tabnew + edit four + let id4 = win_getid() + split five + let id5 = win_getid() + tabnext + + wincmd w + call assert_equal("two", expand("%")) + call assert_equal(id2, win_getid()) + let nr2 = winnr() + wincmd w + call assert_equal("one", expand("%")) + call assert_equal(id1, win_getid()) + let nr1 = winnr() + wincmd w + call assert_equal("three", expand("%")) + call assert_equal(id3, win_getid()) + let nr3 = winnr() + tabnext + call assert_equal("five", expand("%")) + call assert_equal(id5, win_getid()) + let nr5 = winnr() + wincmd w + call assert_equal("four", expand("%")) + call assert_equal(id4, win_getid()) + let nr4 = winnr() + tabnext + + exe nr1 . "wincmd w" + call assert_equal(id1, win_getid()) + exe nr2 . "wincmd w" + call assert_equal(id2, win_getid()) + exe nr3 . "wincmd w" + call assert_equal(id3, win_getid()) + tabnext + exe nr4 . "wincmd w" + call assert_equal(id4, win_getid()) + exe nr5 . "wincmd w" + call assert_equal(id5, win_getid()) + + call win_gotoid(id2) + call assert_equal("two", expand("%")) + call win_gotoid(id4) + call assert_equal("four", expand("%")) + call win_gotoid(id1) + call assert_equal("one", expand("%")) + call win_gotoid(id5) + call assert_equal("five", expand("%")) + + call assert_equal(0, win_id2win(9999)) + call assert_equal(nr5, win_id2win(id5)) + call assert_equal(0, win_id2win(id1)) + tabnext + call assert_equal(nr1, win_id2win(id1)) + + call assert_equal([0, 0], win_id2tabwin(9999)) + call assert_equal([1, nr2], win_id2tabwin(id2)) + call assert_equal([2, nr4], win_id2tabwin(id4)) + + only! +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index d6b051a511..aa337f9fae 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -604,7 +604,7 @@ static int included_patches[] = { 1676, 1675, // 1674 NA - // 1673, + 1673, // 1672 NA // 1671, // 1670, @@ -674,7 +674,7 @@ static int included_patches[] = { // 1606, // 1605, // 1604, - // 1603, + 1603, // 1602 NA // 1601 NA // 1600 NA @@ -720,7 +720,7 @@ static int included_patches[] = { // 1560 NA // 1559, // 1558, - // 1557, + 1557, // 1556 NA // 1555 NA 1554, diff --git a/src/nvim/window.c b/src/nvim/window.c index e267d493bf..350b54d595 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -3683,6 +3683,8 @@ win_T *buf_jump_open_tab(buf_T *buf) return NULL; } +static int last_win_id = 0; + /* * Allocate a window structure and link it in the window list when "hidden" is * FALSE. @@ -3695,6 +3697,7 @@ static win_T *win_alloc(win_T *after, int hidden) win_T *new_wp = xcalloc(1, sizeof(win_T)); handle_register_window(new_wp); win_alloc_lines(new_wp); + new_wp->w_id = ++last_win_id; /* init w: variables */ new_wp->w_vars = dict_alloc(); @@ -5674,3 +5677,93 @@ static bool frame_check_width(frame_T *topfrp, int width) } return true; } + +int win_getid(typval_T *argvars) +{ + if (argvars[0].v_type == VAR_UNKNOWN) { + return curwin->w_id; + } + int winnr = get_tv_number(&argvars[0]); + win_T *wp; + if (winnr > 0) { + if (argvars[1].v_type == VAR_UNKNOWN) { + wp = firstwin; + } else { + tabpage_T *tp; + int tabnr = get_tv_number(&argvars[1]); + for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) { + if (--tabnr == 0) { + break; + } + } + if (tp == NULL) { + return -1; + } + wp = tp->tp_firstwin; + } + for ( ; wp != NULL; wp = wp->w_next) { + if (--winnr == 0) { + return wp->w_id; + } + } + } + return 0; +} + +int win_gotoid(typval_T *argvars) +{ + win_T *wp; + tabpage_T *tp; + int id = get_tv_number(&argvars[0]); + + for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) { + for (wp = tp == curtab ? firstwin : tp->tp_firstwin; + wp != NULL; wp = wp->w_next) { + if (wp->w_id == id) { + goto_tabpage_win(tp, wp); + return 1; + } + } + } + return 0; +} + +void win_id2tabwin(typval_T *argvars, list_T *list) +{ + win_T *wp; + tabpage_T *tp; + int winnr = 1; + int tabnr = 1; + int id = get_tv_number(&argvars[0]); + + for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) { + for (wp = tp == curtab ? firstwin : tp->tp_firstwin; + wp != NULL; wp = wp->w_next) { + if (wp->w_id == id) { + list_append_number(list, tabnr); + list_append_number(list, winnr); + return; + } + winnr++; + } + tabnr++; + winnr = 1; + } + list_append_number(list, 0); + list_append_number(list, 0); +} + +int win_id2win(typval_T *argvars) +{ + win_T *wp; + int nr = 1; + int id = get_tv_number(&argvars[0]); + + for (wp = firstwin; wp != NULL; wp = wp->w_next) { + if (wp->w_id == id) { + return nr; + } + nr++; + } + return 0; +} |