diff options
-rw-r--r-- | runtime/syntax/haskell.vim | 7 | ||||
-rw-r--r-- | runtime/syntax/vim.vim | 3 | ||||
-rw-r--r-- | src/nvim/edit.c | 15 | ||||
-rw-r--r-- | src/nvim/indent.c | 4 | ||||
-rw-r--r-- | src/nvim/os/users.c | 2 | ||||
-rw-r--r-- | src/nvim/plines.c | 2 | ||||
-rw-r--r-- | src/nvim/regexp.c | 4 | ||||
-rw-r--r-- | src/nvim/tag.c | 18 | ||||
-rw-r--r-- | test/old/testdir/test_buffer.vim | 2 | ||||
-rw-r--r-- | test/old/testdir/test_edit.vim | 37 | ||||
-rw-r--r-- | test/old/testdir/test_history.vim | 2 | ||||
-rw-r--r-- | test/old/testdir/test_ins_complete.vim | 2 | ||||
-rw-r--r-- | test/old/testdir/test_mksession.vim | 4 | ||||
-rw-r--r-- | test/old/testdir/test_recover.vim | 2 | ||||
-rw-r--r-- | test/old/testdir/test_regexp_latin.vim | 14 | ||||
-rw-r--r-- | test/old/testdir/test_visual.vim | 2 | ||||
-rw-r--r-- | test/old/testdir/test_winfixbuf.vim | 18 |
17 files changed, 95 insertions, 43 deletions
diff --git a/runtime/syntax/haskell.vim b/runtime/syntax/haskell.vim index b48b278084..509aa25122 100644 --- a/runtime/syntax/haskell.vim +++ b/runtime/syntax/haskell.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: Haskell " Maintainer: Haskell Cafe mailinglist <haskell-cafe@haskell.org> -" Last Change: 2020 Oct 4 by Marcin Szamotulski <profunctor@pm.me> +" Last Change: 2024 Mar 28 by Enrico Maria De Angelis <enricomaria.dean6elis@gmail.com> " Original Author: John Williams <jrw@pobox.com> " " Thanks to Ryan Crumley for suggestions and John Meacham for @@ -104,8 +104,8 @@ endif " Comments -syn match hsLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" contains=@Spell -syn region hsBlockComment start="{-" end="-}" contains=hsBlockComment,@Spell +syn match hsLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" contains=hsTodo,@Spell +syn region hsBlockComment start="{-" end="-}" contains=hsBlockComment,hsTodo,@Spell syn region hsPragma start="{-#" end="#-}" syn keyword hsTodo contained FIXME TODO XXX NOTE @@ -164,6 +164,7 @@ hi def link hsLiterateComment hsComment hi def link hsBlockComment hsComment hi def link hsLineComment hsComment hi def link hsComment Comment +hi def link hsTodo Todo hi def link hsPragma SpecialComment hi def link hsBoolean Boolean hi def link hsType Type diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 640102562b..e665ec8e14 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -150,6 +150,7 @@ syn match vimNumber '\<\d\+\%(\.\d\+\%(e[+-]\=\d\+\)\=\)\=' skipwhite nextgroup= syn match vimNumber '\<0b[01]\+' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,vimComment,vim9Comment syn match vimNumber '\<0o\=\o\+' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,vimComment,vim9Comment syn match vimNumber '\<0x\x\+' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,vimComment,vim9Comment +syn match vimNumber '\<0z\>' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,vimComment,vim9Comment syn match vimNumber '\<0z\%(\x\x\)\+\%(\.\%(\x\x\)\+\)*' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,vimComment,vim9Comment syn match vimNumber '\%(^\|\A\)\zs#\x\{6}' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,vimComment,vim9Comment syn case match @@ -465,6 +466,8 @@ syn keyword vimFor for skipwhite nextgroup=vimVar,vimVarList " ============= " GEN_SYN_VIM: vimCommand abbrev, START_STR='syn keyword vimAbb', END_STR='skipwhite nextgroup=vimMapMod,vimMapLhs' syn keyword vimAbb ab[breviate] ca[bbrev] cnorea[bbrev] cuna[bbrev] ia[bbrev] inorea[bbrev] iuna[bbrev] norea[bbrev] una[bbreviate] skipwhite nextgroup=vimMapMod,vimMapLhs +" GEN_SYN_VIM: vimCommand abclear, START_STR='syn keyword vimAbb', END_STR='skipwhite nextgroup=vimMapMod' +syn keyword vimAbb abc[lear] cabc[lear] iabc[lear] skipwhite nextgroup=vimMapMod " Autocmd: {{{2 " ======= diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 11c5ba2628..8b8345657c 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -3838,7 +3838,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p) bool const use_ts = !curwin->w_p_list || curwin->w_p_lcs_chars.tab1; char *const line = get_cursor_line_ptr(); - char *const end_ptr = line + curwin->w_cursor.col; + char *const cursor_ptr = line + curwin->w_cursor.col; colnr_T vcol = 0; colnr_T space_vcol = 0; @@ -3846,9 +3846,10 @@ static bool ins_bs(int c, int mode, int *inserted_space_p) StrCharInfo space_sci = sci; bool prev_space = false; - // Find the last whitespace that is preceded by non-whitespace. + // Compute virtual column of cursor position, and find the last + // whitespace before cursor that is preceded by non-whitespace. // Use charsize_nowrap() so that virtual text and wrapping are ignored. - while (sci.ptr < end_ptr) { + while (sci.ptr < cursor_ptr) { bool cur_space = ascii_iswhite(sci.chr.value); if (!prev_space && cur_space) { space_sci = sci; @@ -3860,11 +3861,9 @@ static bool ins_bs(int c, int mode, int *inserted_space_p) } // Compute the virtual column where we want to be. - colnr_T want_vcol = vcol - 1; - if (want_vcol <= 0) { - want_vcol = 0; - } else if (p_sta && in_indent) { - want_vcol = want_vcol - want_vcol % get_sw_value(curbuf); + colnr_T want_vcol = vcol > 0 ? vcol - 1 : 0; + if (p_sta && in_indent) { + want_vcol -= want_vcol % get_sw_value(curbuf); } else { want_vcol = tabstop_start(want_vcol, get_sts_value(), curbuf->b_p_vsts_array); } diff --git a/src/nvim/indent.c b/src/nvim/indent.c index d477b466d7..d635c7d7bf 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -177,7 +177,7 @@ colnr_T tabstop_start(colnr_T col, int ts, colnr_T *vts) colnr_T tabcol = 0; if (vts == NULL || vts[0] == 0) { - return ((col / ts) * ts); + return col - col % ts; } const int tabcount = vts[0]; @@ -189,7 +189,7 @@ colnr_T tabstop_start(colnr_T col, int ts, colnr_T *vts) } const int excess = (tabcol % vts[tabcount]); - return (excess + ((col - excess) / vts[tabcount]) * vts[tabcount]); + return col - (col - excess) % vts[tabcount]; } /// Find the number of tabs and spaces necessary to get from one column diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c index 8886d6068d..d5a8355470 100644 --- a/src/nvim/os/users.c +++ b/src/nvim/os/users.c @@ -203,7 +203,7 @@ static void init_users(void) os_get_usernames(&ga_users); } -/// Given to ExpandGeneric() to obtain an user names. +/// Given to ExpandGeneric() to obtain user names. char *get_users(expand_T *xp, int idx) { init_users(); diff --git a/src/nvim/plines.c b/src/nvim/plines.c index dae9de48c6..d90ee9c1ba 100644 --- a/src/nvim/plines.c +++ b/src/nvim/plines.c @@ -249,7 +249,7 @@ CharSize charsize_regular(CharsizeArg *csarg, char *const cur, colnr_T const vco } csarg->indent_width = head_mid; } - if (head_mid > 0 && wcol + size > wp->w_width_inner) { + if (head_mid > 0) { // Calculate effective window width. int prev_rem = wp->w_width_inner - wcol; int width = width2 - head_mid; diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 86082adbb6..08c804bca5 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -4494,7 +4494,7 @@ static uint8_t *regatom(int *flagp) n = n * 10 + (uint32_t)(c - '0'); c = getchr(); } - if (c == '\'' && n == 0) { + if (no_Magic(c) == '\'' && n == 0) { // "\%'m", "\%<'m" and "\%>'m": Mark c = getchr(); ret = regnode(RE_MARK); @@ -10218,7 +10218,7 @@ static int nfa_regatom(void) } EMIT((int)n); break; - } else if (c == '\'' && n == 0) { + } else if (no_Magic(c) == '\'' && n == 0) { // \%'m \%<'m \%>'m EMIT(cmp == '<' ? NFA_MARK_LT : cmp == '>' ? NFA_MARK_GT : NFA_MARK); diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 0265d2d822..7e94a8b124 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -290,10 +290,6 @@ void set_buflocal_tfu_callback(buf_T *buf) /// @param verbose print "tag not found" message void do_tag(char *tag, int type, int count, int forceit, bool verbose) { - if (postponed_split == 0 && !check_can_set_curbuf_forceit(forceit)) { - return; - } - taggy_T *tagstack = curwin->w_tagstack; int tagstackidx = curwin->w_tagstackidx; int tagstacklen = curwin->w_tagstacklen; @@ -320,11 +316,6 @@ void do_tag(char *tag, int type, int count, int forceit, bool verbose) static char **matches = NULL; static int flags; - if (tfu_in_use) { - emsg(_(e_cannot_modify_tag_stack_within_tagfunc)); - return; - } - #ifdef EXITFREE if (type == DT_FREE) { // remove the list of matches @@ -334,6 +325,15 @@ void do_tag(char *tag, int type, int count, int forceit, bool verbose) } #endif + if (tfu_in_use) { + emsg(_(e_cannot_modify_tag_stack_within_tagfunc)); + return; + } + + if (postponed_split == 0 && !check_can_set_curbuf_forceit(forceit)) { + return; + } + if (type == DT_HELP) { type = DT_TAG; no_regexp = true; diff --git a/test/old/testdir/test_buffer.vim b/test/old/testdir/test_buffer.vim index b0b9f4f24b..bb8394997d 100644 --- a/test/old/testdir/test_buffer.vim +++ b/test/old/testdir/test_buffer.vim @@ -133,7 +133,7 @@ func Test_bdelete_cmd() call assert_fails('1,1bdelete 1 2', 'E488:') call assert_fails('bdelete \)', 'E55:') - " Deleting a unlisted and unloaded buffer + " Deleting an unlisted and unloaded buffer edit Xbdelfile1 let bnr = bufnr() set nobuflisted diff --git a/test/old/testdir/test_edit.vim b/test/old/testdir/test_edit.vim index ba084442d1..1bfe46c4a9 100644 --- a/test/old/testdir/test_edit.vim +++ b/test/old/testdir/test_edit.vim @@ -2065,7 +2065,10 @@ func Test_edit_revins() call setline(1, 'one two three') exe "normal! wi\nfour" call assert_equal(['one two three', 'ruof'], getline(1, '$')) - set revins& + set backspace=indent,eol,start + exe "normal! ggA\<BS>:" + call assert_equal(['one two three:ruof'], getline(1, '$')) + set revins& backspace& bw! endfunc @@ -2156,7 +2159,7 @@ func s:check_backspace(expected) inoremap <buffer> <F2> <Cmd>let g:actual += [getline('.')]<CR> set backspace=indent,eol,start - exe "normal $i" .. repeat("\<BS>\<F2>", len(a:expected)) + exe "normal i" .. repeat("\<BS>\<F2>", len(a:expected)) call assert_equal(a:expected, g:actual) set backspace& @@ -2166,9 +2169,12 @@ endfunc " Test that backspace works with 'smarttab' and mixed Tabs and spaces. func Test_edit_backspace_smarttab_mixed() + set smarttab call NewWindow(1, 30) - setlocal smarttab tabstop=4 shiftwidth=4 + setlocal tabstop=4 shiftwidth=4 + call setline(1, "\t \t \t a") + normal! $ call s:check_backspace([ \ "\t \t \ta", \ "\t \t a", @@ -2180,15 +2186,19 @@ func Test_edit_backspace_smarttab_mixed() \ ]) call CloseWindow() + set smarttab& endfunc " Test that backspace works with 'smarttab' and 'varsofttabstop'. func Test_edit_backspace_smarttab_varsofttabstop() CheckFeature vartabs + set smarttab call NewWindow(1, 30) - setlocal smarttab tabstop=8 varsofttabstop=6,2,5,3 + setlocal tabstop=8 varsofttabstop=6,2,5,3 + call setline(1, "a\t \t a") + normal! $ call s:check_backspace([ \ "a\t \ta", \ "a\t a", @@ -2199,13 +2209,17 @@ func Test_edit_backspace_smarttab_varsofttabstop() \ ]) call CloseWindow() + set smarttab& endfunc " Test that backspace works with 'smarttab' when a Tab is shown as "^I". func Test_edit_backspace_smarttab_list() + set smarttab call NewWindow(1, 30) - setlocal smarttab tabstop=4 shiftwidth=4 list listchars= + setlocal tabstop=4 shiftwidth=4 list listchars= + call setline(1, "\t \t \t a") + normal! $ call s:check_backspace([ \ "\t \t a", \ "\t \t a", @@ -2215,15 +2229,19 @@ func Test_edit_backspace_smarttab_list() \ ]) call CloseWindow() + set smarttab& endfunc " Test that backspace works with 'smarttab' and 'breakindent'. func Test_edit_backspace_smarttab_breakindent() CheckFeature linebreak + set smarttab call NewWindow(3, 17) - setlocal smarttab tabstop=4 shiftwidth=4 breakindent breakindentopt=min:5 + setlocal tabstop=4 shiftwidth=4 breakindent breakindentopt=min:5 + call setline(1, "\t \t \t a") + normal! $ call s:check_backspace([ \ "\t \t \ta", \ "\t \t a", @@ -2235,17 +2253,21 @@ func Test_edit_backspace_smarttab_breakindent() \ ]) call CloseWindow() + set smarttab& endfunc " Test that backspace works with 'smarttab' and virtual text. func Test_edit_backspace_smarttab_virtual_text() CheckFeature textprop + set smarttab call NewWindow(1, 50) - setlocal smarttab tabstop=4 shiftwidth=4 + setlocal tabstop=4 shiftwidth=4 + call setline(1, "\t \t \t a") call prop_type_add('theprop', {}) call prop_add(1, 3, {'type': 'theprop', 'text': 'text'}) + normal! $ call s:check_backspace([ \ "\t \t \ta", \ "\t \t a", @@ -2258,6 +2280,7 @@ func Test_edit_backspace_smarttab_virtual_text() call CloseWindow() call prop_type_delete('theprop') + set smarttab& endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_history.vim b/test/old/testdir/test_history.vim index 482328ab4a..19490f2528 100644 --- a/test/old/testdir/test_history.vim +++ b/test/old/testdir/test_history.vim @@ -254,7 +254,7 @@ func Test_history_crypt_key() set key& bs& ts& endfunc -" The following used to overflow and causing an use-after-free +" The following used to overflow and causing a use-after-free func Test_history_max_val() set history=10 diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim index cfae6ef11e..ac04187a7b 100644 --- a/test/old/testdir/test_ins_complete.vim +++ b/test/old/testdir/test_ins_complete.vim @@ -1208,7 +1208,7 @@ func Test_complete_wholeline_unlistedbuf() edit Xfile1 enew set complete=U - " completing from a unloaded buffer should fail + " completing from an unloaded buffer should fail exe "normal! ia\<C-X>\<C-L>\<C-P>" call assert_equal('a', getline(1)) %d diff --git a/test/old/testdir/test_mksession.vim b/test/old/testdir/test_mksession.vim index d63d10b44c..7e9cd6c8e8 100644 --- a/test/old/testdir/test_mksession.vim +++ b/test/old/testdir/test_mksession.vim @@ -631,11 +631,11 @@ endfunc func Test_mkview_no_file_name() new - " :mkview or :mkview {nr} should fail in a unnamed buffer. + " :mkview or :mkview {nr} should fail in an unnamed buffer. call assert_fails('mkview', 'E32:') call assert_fails('mkview 1', 'E32:') - " :mkview {file} should succeed in a unnamed buffer. + " :mkview {file} should succeed in an unnamed buffer. mkview Xview help source Xview diff --git a/test/old/testdir/test_recover.vim b/test/old/testdir/test_recover.vim index fa8cc1abaf..ca1ee11b44 100644 --- a/test/old/testdir/test_recover.vim +++ b/test/old/testdir/test_recover.vim @@ -385,7 +385,7 @@ func Test_recover_encrypted_swap_file() call delete('Xfile1') endfunc -" Test for :recover using a unreadable swap file +" Test for :recover using an unreadable swap file func Test_recover_unreadable_swap_file() CheckUnix CheckNotRoot diff --git a/test/old/testdir/test_regexp_latin.vim b/test/old/testdir/test_regexp_latin.vim index ece6ae518e..2cfa81e078 100644 --- a/test/old/testdir/test_regexp_latin.vim +++ b/test/old/testdir/test_regexp_latin.vim @@ -842,12 +842,26 @@ func Regex_Mark() %d endfunc +" Same test as above, but use verymagic +func Regex_Mark_Verymagic() + call append(0, ['', '', '', 'Marks:', 'asdfSasdfsadfEasdf', 'asdfSas', + \ 'dfsadfEasdf', '', '', '', '', '']) + call cursor(4, 1) + exe "normal jfSmsfEme:.-4,.+6s/\\v.%>'s.*%<'e../here/\<CR>" + exe "normal jfSmsj0fEme:.-4,.+6s/\\v.%>'s\\_.*%<'e../again/\<CR>" + call assert_equal(['', '', '', 'Marks:', 'asdfhereasdf', 'asdfagainasdf', + \ '', '', '', '', '', ''], getline(1, '$')) + %d +endfunc + func Test_matching_marks() new set regexpengine=1 call Regex_Mark() + call Regex_Mark_Verymagic() set regexpengine=2 call Regex_Mark() + call Regex_Mark_Verymagic() bwipe! endfunc diff --git a/test/old/testdir/test_visual.vim b/test/old/testdir/test_visual.vim index d952400367..864ccd428d 100644 --- a/test/old/testdir/test_visual.vim +++ b/test/old/testdir/test_visual.vim @@ -1151,7 +1151,7 @@ func Test_visual_inner_block() " try to select non-existing inner block call cursor(5, 1) call assert_beeps('normal ViBiBiB') - " try to select a unclosed inner block + " try to select an unclosed inner block 8,9d call cursor(5, 1) call assert_beeps('normal ViBiB') diff --git a/test/old/testdir/test_winfixbuf.vim b/test/old/testdir/test_winfixbuf.vim index 3fcc5fa5eb..c6c483e5a0 100644 --- a/test/old/testdir/test_winfixbuf.vim +++ b/test/old/testdir/test_winfixbuf.vim @@ -1,6 +1,7 @@ " Test 'winfixbuf' source check.vim +source shared.vim " Find the number of open windows in the current tab func s:get_windows_count() @@ -1251,11 +1252,12 @@ endfunc " Allow :e selecting the current buffer as a full path func Test_edit_same_buffer_on_disk_absolute_path() - " This fails on CI (Windows builds), why? - " CheckNotMSWindows call s:reset_all_buffers() let file = tempname() + " file must exist for expansion of 8.3 paths to succeed + call writefile([], file, 'D') + let file = fnamemodify(file, ':p') let current = bufnr() execute "edit " . file write! @@ -1265,7 +1267,6 @@ func Test_edit_same_buffer_on_disk_absolute_path() execute "edit " file call assert_equal(current, bufnr()) - call delete(file) set nowinfixbuf endfunc @@ -3427,4 +3428,15 @@ func Test_bufdo_cnext_splitwin_fails() set winminheight&vim winheight&vim endfunc +" Test that exiting with 'winfixbuf' and EXITFREE doesn't cause an error. +func Test_exitfree_no_error() + let lines =<< trim END + set winfixbuf + qall! + END + call writefile(lines, 'Xwfb_exitfree', 'D') + call assert_notmatch('E1513:', + \ system(GetVimCommandClean() .. ' -X -S Xwfb_exitfree')) +endfunc + " vim: shiftwidth=2 sts=2 expandtab |