diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index f4f6ff8fdc..3c2e0adabb 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -187,6 +187,7 @@ DEFAULTS Unset 'exrc' to stop further search. • Mappings: • |grt| in Normal mode maps to |vim.lsp.buf.type_definition()| +• 'shada' default now excludes "/tmp/" and "/private/" paths to reduce clutter in |:oldfiles|. DIAGNOSTICS diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 554fdddc5b..bbe2a634db 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5356,9 +5356,7 @@ A jump table for the options with a short description can be found at |Q_op|. the session. *'shada'* *'sd'* *E526* *E527* *E528* -'shada' 'sd' string (default for - Win32: !,'100,<50,s10,h,rA:,rB: - others: !,'100,<50,s10,h) +'shada' 'sd' string (default "!,'100,<50,s10,h,r/tmp/,r/private/") global When non-empty, the shada file is read upon startup and written when exiting Vim (see |shada-file|). The string should be a comma- diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua index b73f7a0491..c1e35052a2 100644 --- a/runtime/lua/vim/_meta/options.lua +++ b/runtime/lua/vim/_meta/options.lua @@ -5756,7 +5756,7 @@ vim.go.ssop = vim.go.sessionoptions --- security reasons. --- --- @type string -vim.o.shada = "!,'100,<50,s10,h" +vim.o.shada = "!,'100,<50,s10,h,r/tmp/,r/private/" vim.o.sd = vim.o.shada vim.go.shada = vim.o.shada vim.go.sd = vim.go.shada diff --git a/src/nvim/options.lua b/src/nvim/options.lua index e4d0e12780..373ec1993a 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -7447,12 +7447,7 @@ local options = { abbreviation = 'sd', alias = { 'vi', 'viminfo' }, cb = 'did_set_shada', - defaults = { - if_true = "!,'100,<50,s10,h", - doc = [[for - Win32: !,'100,<50,s10,h,rA:,rB: - others: !,'100,<50,s10,h]], - }, + defaults = "!,'100,<50,s10,h,r/tmp/,r/private/", deny_duplicates = true, desc = [=[ When non-empty, the shada file is read upon startup and written diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua index 6f81878f2d..e9c5cc180b 100644 --- a/test/functional/ex_cmds/oldfiles_spec.lua +++ b/test/functional/ex_cmds/oldfiles_spec.lua @@ -18,7 +18,7 @@ local function _clear() '-i', shada_file, -- Need shada for these tests. '--cmd', - 'set noswapfile undodir=. directory=. viewdir=. backupdir=. belloff= noshowcmd noruler', + "set noswapfile undodir=. directory=. viewdir=. backupdir=. belloff= noshowcmd noruler shada=!,'100,<50,s10,h", }, args_rm = { '-i', '--cmd' }, } diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index 9ff076223b..e2bc64c210 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -195,7 +195,7 @@ describe('startup defaults', function() os.remove('Xtest-foo') end) - clear { args = {}, args_rm = { '-i' }, env = env } + clear { args = {}, args_rm = { '-i', '--cmd' }, env = env } -- Default 'shadafile' is empty. -- This means use the default location. :help shada-file-name eq('', api.nvim_get_option_value('shadafile', {})) @@ -203,16 +203,18 @@ describe('startup defaults', function() -- Handles viminfo/viminfofile as alias for shada/shadafile. eq('\n shadafile=', eval('execute("set shadafile?")')) eq('\n shadafile=', eval('execute("set viminfofile?")')) - eq("\n shada=!,'100,<50,s10,h", eval('execute("set shada?")')) - eq("\n shada=!,'100,<50,s10,h", eval('execute("set viminfo?")')) + eq("\n shada=!,'100,<50,s10,h,r/tmp/,r/private/", eval('execute("set shada?")')) + eq("\n shada=!,'100,<50,s10,h,r/tmp/,r/private/", eval('execute("set viminfo?")')) + -- Remove /tmp/ exclusion so test works when run in temp directories. + command("set shada=!,'100,<50,s10,h") -- Check that shada data (such as v:oldfiles) is saved/restored. command('edit Xtest-foo') command('write') local f = eval('fnamemodify(@%,":p")') assert(string.len(f) > 3) expect_exit(command, 'qall') - clear { args = {}, args_rm = { '-i' }, env = env } + clear { args = {}, args_rm = { '-i', '--cmd' }, env = env } eq({ f }, eval('v:oldfiles')) end) diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua index a52530d113..b4e176a9cf 100644 --- a/test/functional/shada/shada_spec.lua +++ b/test/functional/shada/shada_spec.lua @@ -241,8 +241,8 @@ describe('ShaDa support code', function() eq("'10", api.nvim_get_option_value('viminfo', {})) eq("'10", api.nvim_get_option_value('shada', {})) nvim_command('set all&') - eq("!,'100,<50,s10,h", api.nvim_get_option_value('viminfo', {})) - eq("!,'100,<50,s10,h", api.nvim_get_option_value('shada', {})) + eq("!,'100,<50,s10,h,r/tmp/,r/private/", api.nvim_get_option_value('viminfo', {})) + eq("!,'100,<50,s10,h,r/tmp/,r/private/", api.nvim_get_option_value('shada', {})) end) it('is able to set &shada after &viminfo using :set', function() diff --git a/test/functional/testnvim.lua b/test/functional/testnvim.lua index c9cbc472e3..5d9e9f69e7 100644 --- a/test/functional/testnvim.lua +++ b/test/functional/testnvim.lua @@ -26,7 +26,7 @@ M.nvim_prog = (os.getenv('NVIM_PRG') or t.paths.test_build_dir .. '/bin/nvim') M.nvim_set = ( 'set shortmess+=IS background=light noswapfile noautoindent startofline' .. ' laststatus=1 undodir=. directory=. viewdir=. backupdir=.' - .. ' belloff= wildoptions-=pum joinspaces noshowcmd noruler nomore redrawdebug=invalid' + .. " belloff= wildoptions-=pum joinspaces noshowcmd noruler nomore redrawdebug=invalid shada=!,'100,<50,s10,h" .. [[ statusline=%<%f\ %{%nvim_eval_statusline('%h%w%m%r',\ {'maxwidth':\ 30}).width\ >\ 0\ ?\ '%h%w%m%r\ '\ :\ ''%}%=%{%\ &showcmdloc\ ==\ 'statusline'\ ?\ '%-10.S\ '\ :\ ''\ %}%{%\ exists('b:keymap_name')\ ?\ '<'..b:keymap_name..'>\ '\ :\ ''\ %}%{%\ &ruler\ ?\ (\ &rulerformat\ ==\ ''\ ?\ '%-14.(%l,%c%V%)\ %P'\ :\ &rulerformat\ )\ :\ ''\ %}]] ) M.nvim_argv = {