diff options
-rw-r--r-- | runtime/autoload/netrw.vim | 37 | ||||
-rw-r--r-- | runtime/doc/change.txt | 14 | ||||
-rw-r--r-- | scripts/lintcommit.lua | 7 | ||||
-rw-r--r-- | test/old/testdir/test_listdict.vim | 49 |
4 files changed, 88 insertions, 19 deletions
diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 7da97c9690..c7306289e5 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -15,6 +15,7 @@ " 2024 May 13 by Vim Project: prefer scp over pscp " 2024 Jun 04 by Vim Project: set bufhidden if buffer changed, nohidden is set and buffer shall be switched (#14915) " 2024 Jun 13 by Vim Project: glob() on Windows fails when a directory name contains [] (#14952) +" 2024 Jun 23 by Vim Project: save ad restore registers when liststyle = WIDELIST (#15077) " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 2016 Charles E. Campbell {{{1 @@ -5526,13 +5527,12 @@ endfun " --------------------------------------------------------------------- " netrw#BrowseXVis: used by gx in visual mode to select a file for browsing {{{2 fun! netrw#BrowseXVis() -" call Dfunc("netrw#BrowseXVis()") - let akeep = @a + let dict={} + let dict.a=[getreg('a'), getregtype('a')] norm! gv"ay let gxfile= @a - let @a = akeep + call s:RestoreRegister(dict) call netrw#BrowseX(gxfile,netrw#CheckIfRemote(gxfile)) -" call Dret("netrw#BrowseXVis") endfun " --------------------------------------------------------------------- @@ -9679,7 +9679,13 @@ fun! s:NetrwWideListing() " fpl: filenames per line " fpc: filenames per column setl ma noro - let keepa= @a + let dict={} + " save the unnamed register and register 0-9 and a + let dict.a=[getreg('a'), getregtype('a')] + for i in range(0, 9) + let dict[i] = [getreg(i), getregtype(i)] + endfor + let dict.unnamed = [getreg(''), getregtype('')] " call Decho("setl ma noro",'~'.expand("<slnum>")) let b:netrw_cpf= 0 if line("$") >= w:netrw_bannercnt @@ -9687,7 +9693,8 @@ fun! s:NetrwWideListing() exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif' NetrwKeepj call histdel("/",-1) else - let @a= keepa + " restore stored registers + call s:RestoreRegister(dict) " call Dret("NetrwWideListing") return endif @@ -9729,7 +9736,7 @@ fun! s:NetrwWideListing() exe 'nno <buffer> <silent> b :call search(''^.\\|\s\s\zs\S'',''bW'')'."\<cr>" " call Decho("NetrwWideListing) setl noma nomod ro",'~'.expand("<slnum>")) exe "setl ".g:netrw_bufsettings - let @a= keepa + call s:RestoreRegister(dict) " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) " call Dret("NetrwWideListing") return @@ -9741,7 +9748,6 @@ fun! s:NetrwWideListing() sil! nunmap <buffer> b endif endif - endfun " --------------------------------------------------------------------- @@ -10062,7 +10068,8 @@ fun! s:SetupNetrwStatusLine(statline) endif " set up User9 highlighting as needed - let keepa= @a + let dict={} + let dict.a=[getreg('a'), getregtype('a')] redir @a try hi User9 @@ -10074,7 +10081,7 @@ fun! s:SetupNetrwStatusLine(statline) endif endtry redir END - let @a= keepa + call s:RestoreRegister(dict) endif " set up status line (may use User9 highlighting) @@ -11884,6 +11891,16 @@ fun! s:RestoreCursorline() " call Dret("s:RestoreCursorline : restored cul=".&l:cursorline." cuc=".&l:cursorcolumn) endfun +" s:RestoreRegister: restores all registers given in the dict {{{2 +fun! s:RestoreRegister(dict) + for [key, val] in items(a:dict) + if key == 'unnamed' + let key = '' + endif + call setreg(key, val[0], val[1]) + endfor +endfun + " --------------------------------------------------------------------- " s:NetrwDelete: Deletes a file. {{{2 " Uses Steve Hall's idea to insure that Windows paths stay diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index 9ff16165d7..928b834600 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -1227,13 +1227,13 @@ Vim fills these registers with text from yank and delete commands. Numbered register 0 contains the text from the most recent yank command, unless the command specified another register with ["x]. Numbered register 1 contains the text deleted by the most recent delete or -change command, unless the command specified another register or the text is -less than one line (the small delete register is used then). An exception is -made for the delete operator with these movement commands: |%|, |(|, |)|, |`|, -|/|, |?|, |n|, |N|, |{| and |}|. Register "1 is always used then (this is Vi -compatible). The "- register is used as well if the delete is within a line. -Note that these characters may be mapped. E.g. |%| is mapped by the matchit -plugin. +change command (even when the command specified another register), unless the +text is less than one line (the small delete register is used then). An +exception is made for the delete operator with these movement commands: |%|, +|(|, |)|, |`|, |/|, |?|, |n|, |N|, |{| and |}|. +Register "1 is always used then (this is Vi compatible). The "- register is +used as well if the delete is within a line. Note that these characters may be +mapped. E.g. |%| is mapped by the matchit plugin. With each successive deletion or change, Vim shifts the previous contents of register 1 into register 2, 2 into 3, and so forth, losing the previous contents of register 9. diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua index f0e2feaab3..7cb57de901 100644 --- a/scripts/lintcommit.lua +++ b/scripts/lintcommit.lua @@ -68,11 +68,12 @@ local function validate_commit(commit_message) if after_idx > vim.tbl_count(commit_split) then return [[Commit message does not include colons.]] end - local after_colon = '' + local after_colon_split = {} while after_idx <= vim.tbl_count(commit_split) do - after_colon = after_colon .. commit_split[after_idx] + table.insert(after_colon_split, commit_split[after_idx]) after_idx = after_idx + 1 end + local after_colon = table.concat(after_colon_split, ':') -- Check if commit introduces a breaking change. if vim.endswith(before_colon, '!') then @@ -247,8 +248,10 @@ function M._test() ['unknown: using unknown type'] = false, ['feat: foo:bar'] = true, ['feat: :foo:bar'] = true, + ['feat: :Foo:Bar'] = true, ['feat(something): foo:bar'] = true, ['feat(something): :foo:bar'] = true, + ['feat(something): :Foo:Bar'] = true, ['feat(:grep): read from pipe'] = true, ['feat(:grep/:make): read from pipe'] = true, ['feat(:grep): foo:bar'] = true, diff --git a/test/old/testdir/test_listdict.vim b/test/old/testdir/test_listdict.vim index 0adc3286f9..6c22dc0784 100644 --- a/test/old/testdir/test_listdict.vim +++ b/test/old/testdir/test_listdict.vim @@ -1447,4 +1447,53 @@ func Test_extendnew_leak() for i in range(100) | silent! call extendnew({}, {}, {}) | endfor endfunc +" Test for comparing deeply nested List/Dict values +func Test_deep_nested_listdict_compare() + let lines =<< trim END + func GetNestedList(sz) + let l = [] + let x = l + for i in range(a:sz) + let y = [1] + call add(x, y) + let x = y + endfor + return l + endfunc + + VAR l1 = GetNestedList(1000) + VAR l2 = GetNestedList(999) + call assert_false(l1 == l2) + + #" after 1000 nested items, the lists are considered to be equal + VAR l3 = GetNestedList(1001) + VAR l4 = GetNestedList(1002) + call assert_true(l3 == l4) + END + call CheckLegacyAndVim9Success(lines) + + let lines =<< trim END + func GetNestedDict(sz) + let d = {} + let x = d + for i in range(a:sz) + let y = {} + let x['a'] = y + let x = y + endfor + return d + endfunc + + VAR d1 = GetNestedDict(1000) + VAR d2 = GetNestedDict(999) + call assert_false(d1 == d2) + + #" after 1000 nested items, the Dicts are considered to be equal + VAR d3 = GetNestedDict(1001) + VAR d4 = GetNestedDict(1002) + call assert_true(d3 == d4) + END + call CheckLegacyAndVim9Success(lines) +endfunc + " vim: shiftwidth=2 sts=2 expandtab |