diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_cmds2.c | 26 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 19 | ||||
-rw-r--r-- | src/nvim/getchar.c | 4 | ||||
-rw-r--r-- | src/nvim/lua/treesitter.c | 4 | ||||
-rw-r--r-- | src/nvim/normal.c | 5 | ||||
-rw-r--r-- | src/nvim/popupmnu.c | 18 | ||||
-rw-r--r-- | src/nvim/syntax.c | 39 | ||||
-rw-r--r-- | src/nvim/testdir/test_filetype.vim | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_mapping.vim | 36 | ||||
-rw-r--r-- | src/nvim/testdir/test_syntax.vim | 3 |
10 files changed, 129 insertions, 26 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 713d18b44d..42454b7c9a 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2551,6 +2551,17 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, done = do_in_path(p_pp, s, flags, callback, cookie); xfree(s); + + if (done == FAIL|| (flags & DIP_ALL)) { + start_dir = "start/*/%s"; // NOLINT + len = STRLEN(start_dir) + STRLEN(name); + s = xmallocz(len); + + vim_snprintf((char *)s, len, start_dir, name); + done = do_in_path(p_pp, s, flags, callback, cookie); + + xfree(s); + } } if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_OPT)) { @@ -2562,6 +2573,17 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, done = do_in_path(p_pp, s, flags, callback, cookie); xfree(s); + + if (done == FAIL || (flags & DIP_ALL)) { + opt_dir = "opt/*/%s"; // NOLINT + len = STRLEN(opt_dir) + STRLEN(name); + s = xmallocz(len); + + vim_snprintf((char *)s, len, opt_dir, name); + done = do_in_path(p_pp, s, flags, callback, cookie); + + xfree(s); + } } return done; @@ -2822,6 +2844,8 @@ void add_pack_start_dirs(void) { do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT add_pack_plugin, &APP_ADD_DIR); + do_in_path(p_pp, (char_u *)"start/*", DIP_ALL + DIP_DIR, // NOLINT + add_pack_plugin, &APP_ADD_DIR); } /// Load plugins from all packages in the "start" directory. @@ -2830,6 +2854,8 @@ void load_start_packages(void) did_source_packages = true; do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT add_pack_plugin, &APP_LOAD); + do_in_path(p_pp, (char_u *)"start/*", DIP_ALL + DIP_DIR, // NOLINT + add_pack_plugin, &APP_LOAD); } // ":packloadall" diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 9edb826ea6..0100be15bc 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -5533,6 +5533,7 @@ static int ExpandRTDir(char_u *pat, int flags, int *num_file, char_u ***file, garray_T ga; ga_init(&ga, (int)sizeof(char *), 10); + // TODO(bfredl): this is bullshit, exandpath should not reinvent path logic. for (int i = 0; dirnames[i] != NULL; i++) { size_t size = STRLEN(dirnames[i]) + pat_len + 7; char_u *s = xmalloc(size); @@ -5549,6 +5550,14 @@ static int ExpandRTDir(char_u *pat, int flags, int *num_file, char_u ***file, globpath(p_pp, s, &ga, 0); xfree(s); } + + for (int i = 0; dirnames[i] != NULL; i++) { + size_t size = STRLEN(dirnames[i]) + pat_len + 22; + char_u *s = xmalloc(size); + snprintf((char *)s, size, "start/*/%s/%s*.vim", dirnames[i], pat); // NOLINT + globpath(p_pp, s, &ga, 0); + xfree(s); + } } if (flags & DIP_OPT) { @@ -5559,6 +5568,14 @@ static int ExpandRTDir(char_u *pat, int flags, int *num_file, char_u ***file, globpath(p_pp, s, &ga, 0); xfree(s); } + + for (int i = 0; dirnames[i] != NULL; i++) { + size_t size = STRLEN(dirnames[i]) + pat_len + 20; + char_u *s = xmalloc(size); + snprintf((char *)s, size, "opt/*/%s/%s*.vim", dirnames[i], pat); // NOLINT + globpath(p_pp, s, &ga, 0); + xfree(s); + } } for (int i = 0; i < ga.ga_len; i++) { @@ -5606,6 +5623,8 @@ static int ExpandPackAddDir(char_u *pat, int *num_file, char_u ***file) char_u *s = xmalloc(buflen); snprintf((char *)s, buflen, "pack/*/opt/%s*", pat); // NOLINT globpath(p_pp, s, &ga, 0); + snprintf((char *)s, buflen, "opt/%s*", pat); // NOLINT + globpath(p_pp, s, &ga, 0); xfree(s); for (int i = 0; i < ga.ga_len; i++) { diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index a5c81b2795..2e2993ed26 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -4476,9 +4476,7 @@ char_u * getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat) aborted = true; } else if (IS_SPECIAL(c1)) { if (c1 == K_SNR) { - ga_append(&line_ga, (char)K_SPECIAL); - ga_append(&line_ga, (char)KS_EXTRA); - ga_append(&line_ga, (char)KE_SNR); + ga_concat(&line_ga, (char_u *)"<SNR>"); } else { EMSG2(e_cmdmap_key, get_special_key_name(c1, cmod)); aborted = true; diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c index 0515bbfe53..a9a57d386b 100644 --- a/src/nvim/lua/treesitter.c +++ b/src/nvim/lua/treesitter.c @@ -743,7 +743,9 @@ static int node_field(lua_State *L) if (ts_tree_cursor_goto_first_child(&cursor)) { do { - if (!STRCMP(field_name, ts_tree_cursor_current_field_name(&cursor))) { + const char *current_field = ts_tree_cursor_current_field_name(&cursor); + + if (current_field != NULL && !STRCMP(field_name, current_field)) { push_node(L, ts_tree_cursor_current_node(&cursor), 1); // [table, node] lua_rawseti(L, -2, ++curr_index); } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 2805a7d74e..4b26ae259e 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1485,7 +1485,8 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) if ((redo_yank || oap->op_type != OP_YANK) && ((!VIsual_active || oap->motion_force) // Also redo Operator-pending Visual mode mappings. - || (cap->cmdchar == ':' && oap->op_type != OP_COLON)) + || ((cap->cmdchar == ':' || cap->cmdchar == K_COMMAND) + && oap->op_type != OP_COLON)) && cap->cmdchar != 'D' && oap->op_type != OP_FOLD && oap->op_type != OP_FOLDOPEN @@ -1678,7 +1679,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) prep_redo(oap->regname, cap->count0, get_op_char(oap->op_type), get_extra_op_char(oap->op_type), oap->motion_force, cap->cmdchar, cap->nchar); - } else if (cap->cmdchar != ':') { + } else if (cap->cmdchar != ':' && cap->cmdchar != K_COMMAND) { int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL; // reverse what nv_replace() did diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index ac0c1f6eb1..f242b7d71a 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -376,6 +376,8 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, // the positioning. Limit this to two times, when there is not much // room the window size will keep changing. } while (pum_set_selected(selected, redo_count) && (++redo_count <= 2)); + + pum_redraw(); } /// Redraw the popup menu, using "pum_first" and "pum_selected". @@ -534,7 +536,17 @@ void pum_redraw(void) xfree(st); col -= width; } else { - grid_puts_len(&pum_grid, st, (int)STRLEN(st), row, col, attr); + int size = (int)STRLEN(st); + int cells = (int)mb_string2cells(st); + + // only draw the text that fits + while (size > 0 && col + cells > pum_width + pum_col) { + size--; + size -= utf_head_off(st, st + size); + cells -= utf_ptr2cells(st + size); + } + + grid_puts_len(&pum_grid, st, size, row, col, attr); xfree(st); col += width; } @@ -824,10 +836,6 @@ static int pum_set_selected(int n, int repeat) } } - if (!resized) { - pum_redraw(); - } - return resized; } diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 2e593e39de..5e54354ea8 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -3505,12 +3505,16 @@ syn_cmd_list( syn_match_msg(); return; } else if (!(curwin->w_s->b_syn_sync_flags & SF_MATCH)) { - if (curwin->w_s->b_syn_sync_minlines == 0) + if (curwin->w_s->b_syn_sync_minlines == 0) { MSG_PUTS(_("no syncing")); - else { - MSG_PUTS(_("syncing starts ")); - msg_outnum(curwin->w_s->b_syn_sync_minlines); - MSG_PUTS(_(" lines before top line")); + } else { + if (curwin->w_s->b_syn_sync_minlines == MAXLNUM) { + MSG_PUTS(_("syncing starts at the first line")); + } else { + MSG_PUTS(_("syncing starts ")); + msg_outnum(curwin->w_s->b_syn_sync_minlines); + MSG_PUTS(_(" lines before top line")); + } syn_match_msg(); } return; @@ -3566,17 +3570,22 @@ static void syn_lines_msg(void) if (curwin->w_s->b_syn_sync_maxlines > 0 || curwin->w_s->b_syn_sync_minlines > 0) { MSG_PUTS("; "); - if (curwin->w_s->b_syn_sync_minlines > 0) { - MSG_PUTS(_("minimal ")); - msg_outnum(curwin->w_s->b_syn_sync_minlines); - if (curwin->w_s->b_syn_sync_maxlines) - MSG_PUTS(", "); - } - if (curwin->w_s->b_syn_sync_maxlines > 0) { - MSG_PUTS(_("maximal ")); - msg_outnum(curwin->w_s->b_syn_sync_maxlines); + if (curwin->w_s->b_syn_sync_minlines == MAXLNUM) { + MSG_PUTS(_("from the first line")); + } else { + if (curwin->w_s->b_syn_sync_minlines > 0) { + MSG_PUTS(_("minimal ")); + msg_outnum(curwin->w_s->b_syn_sync_minlines); + if (curwin->w_s->b_syn_sync_maxlines) { + MSG_PUTS(", "); + } + } + if (curwin->w_s->b_syn_sync_maxlines > 0) { + MSG_PUTS(_("maximal ")); + msg_outnum(curwin->w_s->b_syn_sync_maxlines); + } + MSG_PUTS(_(" lines before top line")); } - MSG_PUTS(_(" lines before top line")); } } diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 9f7e153955..af8482bdbe 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -329,6 +329,7 @@ let s:filename_checks = { \ 'papp': ['file.papp', 'file.pxml', 'file.pxsl'], \ 'pascal': ['file.pas', 'file.pp', 'file.dpr', 'file.lpr'], \ 'passwd': ['any/etc/passwd', 'any/etc/passwd-', 'any/etc/passwd.edit', 'any/etc/shadow', 'any/etc/shadow-', 'any/etc/shadow.edit', 'any/var/backups/passwd.bak', 'any/var/backups/shadow.bak'], + \ 'pbtxt': ['file.pbtxt'], \ 'pccts': ['file.g'], \ 'pdf': ['file.pdf'], \ 'perl': ['file.plx', 'file.al', 'file.psgi', 'gitolite.rc', '.gitolite.rc', 'example.gitolite.rc'], diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index 152afb4b9d..c4807797ff 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -499,4 +499,40 @@ func Test_mapcomplete() call assert_match("abbr! \x01", @:) endfunc +func Test_map_cmdkey_redo() + func SelectDash() + call search('^---\n\zs', 'bcW') + norm! V + call search('\n\ze---$', 'W') + endfunc + + let text =<< trim END + --- + aaa + --- + bbb + bbb + --- + ccc + ccc + ccc + --- + END + new Xcmdtext + call setline(1, text) + + onoremap <silent> i- <Cmd>call SelectDash()<CR> + call feedkeys('2Gdi-', 'xt') + call assert_equal(['---', '---'], getline(1, 2)) + call feedkeys('j.', 'xt') + call assert_equal(['---', '---', '---'], getline(1, 3)) + call feedkeys('j.', 'xt') + call assert_equal(['---', '---', '---', '---'], getline(1, 4)) + + bwipe! + call delete('Xcmdtext') + delfunc SelectDash + ounmap i- +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index 2617aa3945..4cf0e983b0 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -308,6 +308,8 @@ func Test_syntax_arg_skipped() syn sync ccomment endif call assert_notmatch('on C-style comments', execute('syntax sync')) + syn sync fromstart + call assert_match('syncing starts at the first line', execute('syntax sync')) syn clear endfunc @@ -669,6 +671,7 @@ func Test_syntax_foldlevel() redir END call assert_equal("\nsyntax foldlevel start", @c) syn sync fromstart + call assert_match('from the first line$', execute('syn sync')) let a = map(range(3,9), 'foldclosed(v:val)') call assert_equal([3,3,3,3,3,3,3], a) " attached cascade folds together let a = map(range(10,15), 'foldclosed(v:val)') |