Merge #15410 defaults: 'hidden', 'nojoinspaces'

ref #6289
This commit is contained in:
Justin M. Keyes
2021-08-19 06:13:08 -07:00
committed by GitHub
31 changed files with 57 additions and 35 deletions

View File

@@ -3078,7 +3078,7 @@ A jump table for the options with a short description can be found at |Q_op|.
See |help-translated|. See |help-translated|.
*'hidden'* *'hid'* *'nohidden'* *'nohid'* *'hidden'* *'hid'* *'nohidden'* *'nohid'*
'hidden' 'hid' boolean (default off) 'hidden' 'hid' boolean (default on)
global global
When off a buffer is unloaded when it is |abandon|ed. When on a When off a buffer is unloaded when it is |abandon|ed. When on a
buffer becomes hidden when it is |abandon|ed. If the buffer is still buffer becomes hidden when it is |abandon|ed. If the buffer is still
@@ -3498,7 +3498,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|jumplist-stack| |jumplist-stack|
*'joinspaces'* *'js'* *'nojoinspaces'* *'nojs'* *'joinspaces'* *'js'* *'nojoinspaces'* *'nojs'*
'joinspaces' 'js' boolean (default on) 'joinspaces' 'js' boolean (default off)
global global
Insert two spaces after a '.', '?' and '!' with a join command. Insert two spaces after a '.', '?' and '!' with a join command.
Otherwise only one space is inserted. Otherwise only one space is inserted.

View File

@@ -41,9 +41,11 @@ the differences.
- 'fillchars' defaults (in effect) to "vert:│,fold:·,sep:│" - 'fillchars' defaults (in effect) to "vert:│,fold:·,sep:│"
- 'formatoptions' defaults to "tcqj" - 'formatoptions' defaults to "tcqj"
- 'fsync' is disabled - 'fsync' is disabled
- 'hidden' is enabled
- 'history' defaults to 10000 (the maximum) - 'history' defaults to 10000 (the maximum)
- 'hlsearch' is enabled - 'hlsearch' is enabled
- 'incsearch' is enabled - 'incsearch' is enabled
- 'joinspaces' is disabled
- 'langnoremap' is enabled - 'langnoremap' is enabled
- 'langremap' is disabled - 'langremap' is disabled
- 'laststatus' defaults to 2 (statusline is always shown) - 'laststatus' defaults to 2 (statusline is always shown)

View File

@@ -1081,7 +1081,7 @@ return {
short_desc=N_("don't unload buffer when it is |abandon|ed"), short_desc=N_("don't unload buffer when it is |abandon|ed"),
type='bool', scope={'global'}, type='bool', scope={'global'},
varname='p_hid', varname='p_hid',
defaults={if_true=false} defaults={if_true=true}
}, },
{ {
full_name='highlight', abbreviation='hl', full_name='highlight', abbreviation='hl',
@@ -1288,7 +1288,7 @@ return {
short_desc=N_("two spaces after a period with a join command"), short_desc=N_("two spaces after a period with a join command"),
type='bool', scope={'global'}, type='bool', scope={'global'},
varname='p_js', varname='p_js',
defaults={if_true=true} defaults={if_true=false}
}, },
{ {
full_name='jumpoptions', abbreviation='jop', full_name='jumpoptions', abbreviation='jop',

View File

@@ -12,6 +12,7 @@ set directory^=.
set fillchars=vert:\|,fold:- set fillchars=vert:\|,fold:-
set laststatus=1 set laststatus=1
set listchars=eol:$ set listchars=eol:$
set joinspaces
set nohidden smarttab noautoindent noautoread complete-=i noruler noshowcmd set nohidden smarttab noautoindent noautoread complete-=i noruler noshowcmd
set nrformats+=octal set nrformats+=octal
set shortmess-=F set shortmess-=F

Binary file not shown.

View File

@@ -998,6 +998,7 @@ func Test_bufunload_all()
endfunc endfunc
au BufUnload * call UnloadAllBufs() au BufUnload * call UnloadAllBufs()
au VimLeave * call writefile(['Test Finished'], 'Xout') au VimLeave * call writefile(['Test Finished'], 'Xout')
set nohidden
edit Xxx1 edit Xxx1
split Xxx2 split Xxx2
q q

View File

@@ -33,7 +33,7 @@ func Test_command_count_0()
delcommand RangeBuffers delcommand RangeBuffers
delcommand RangeBuffersAll delcommand RangeBuffersAll
set hidden& set nohidden
set swapfile& set swapfile&
endfunc endfunc

View File

@@ -540,7 +540,7 @@ func Test_diffopt_hiddenoff()
bwipe! bwipe!
bwipe! bwipe!
set hidden& diffopt& set nohidden diffopt&
endfunc endfunc
func Test_diffoff_hidden() func Test_diffoff_hidden()
@@ -577,7 +577,7 @@ func Test_diffoff_hidden()
bwipe! bwipe!
bwipe! bwipe!
set hidden& diffopt& set nohidden diffopt&
endfunc endfunc
func Test_setting_cursor() func Test_setting_cursor()

View File

@@ -145,7 +145,7 @@ func Test_gf_visual()
bwipe! bwipe!
call delete('Xtest_gf_visual') call delete('Xtest_gf_visual')
set hidden& set nohidden
endfunc endfunc
func Test_gf_error() func Test_gf_error()

View File

@@ -95,7 +95,7 @@ func Test_ins_complete()
call delete('Xtest11.one') call delete('Xtest11.one')
call delete('Xtest11.two') call delete('Xtest11.two')
call delete('Xtestdata') call delete('Xtestdata')
set cpt& cot& def& tags& tagbsearch& hidden& set cpt& cot& def& tags& tagbsearch& nohidden
cd .. cd ..
call delete('Xdir', 'rf') call delete('Xdir', 'rf')
endfunc endfunc

View File

@@ -51,7 +51,7 @@ func Test_join_marks()
/^This line/;'}-join /^This line/;'}-join
call assert_equal([0, 4, 11, 0], getpos("'[")) call assert_equal([0, 4, 11, 0], getpos("'["))
call assert_equal([0, 4, 67, 0], getpos("']")) call assert_equal([0, 4, 66, 0], getpos("']"))
enew! enew!
endfunc endfunc

View File

@@ -307,7 +307,7 @@ func Test_mksession_buffer_count()
call delete('Xbaz') call delete('Xbaz')
call delete('Xtest_mks.out') call delete('Xtest_mks.out')
%bwipe! %bwipe!
set hidden& set nohidden
endfunc endfunc
if has('extra_search') if has('extra_search')

View File

@@ -539,7 +539,7 @@ func Test_copy_winopt()
call assert_equal(4,&numberwidth) call assert_equal(4,&numberwidth)
bw! bw!
set hidden& set nohidden
endfunc endfunc
func Test_shortmess_F() func Test_shortmess_F()

View File

@@ -170,7 +170,7 @@ func Test_tag_symbolic()
call assert_equal('Xtest.c', expand('%:t')) call assert_equal('Xtest.c', expand('%:t'))
call assert_equal(2, col('.')) call assert_equal(2, col('.'))
set hidden& set nohidden
set tags& set tags&
enew! enew!
call delete('Xtags') call delete('Xtags')

View File

@@ -608,7 +608,7 @@ func Test_window_prevwin()
" reset " reset
q q
call delete('tmp.txt') call delete('tmp.txt')
set hidden&vim autoread&vim set nohidden autoread&vim
delfunc Fun_RenewFile delfunc Fun_RenewFile
endfunc endfunc

View File

@@ -159,9 +159,8 @@ describe('API: buffer events:', function()
tick = tick + 1 tick = tick + 1
expectn('nvim_buf_lines_event', {b, tick, 29, 29, firstfour, false}) expectn('nvim_buf_lines_event', {b, tick, 29, 29, firstfour, false})
-- create a new empty buffer and wipe out the old one ... this will -- delete the current buffer to turn off buffer events
-- turn off buffer events command('bdelete!')
command('enew!')
expectn('nvim_buf_detach_event', {b}) expectn('nvim_buf_detach_event', {b})
-- add a line at the start of an empty file -- add a line at the start of an empty file
@@ -269,7 +268,7 @@ describe('API: buffer events:', function()
'original foo'}, false}) 'original foo'}, false})
-- type text into the first line of a blank file, one character at a time -- type text into the first line of a blank file, one character at a time
command('enew!') command('bdelete!')
tick = 2 tick = 2
expectn('nvim_buf_detach_event', {b}) expectn('nvim_buf_detach_event', {b})
local bnew = nvim('get_current_buf') local bnew = nvim('get_current_buf')
@@ -666,7 +665,8 @@ describe('API: buffer events:', function()
tick = tick + 1 tick = tick + 1
expectn('nvim_buf_changedtick_event', {b, tick}) expectn('nvim_buf_changedtick_event', {b, tick})
-- close our buffer by creating a new one -- close our buffer and create a new one
command('bdelete')
command('enew') command('enew')
expectn('nvim_buf_detach_event', {b}) expectn('nvim_buf_detach_event', {b})

View File

@@ -311,7 +311,8 @@ describe('API/win', function()
eq({newwin}, meths.list_wins()) eq({newwin}, meths.list_wins())
end) end)
it('handles changed buffer', function() it("handles changed buffer when 'hidden' is unset", function()
command('set nohidden')
local oldwin = meths.get_current_win() local oldwin = meths.get_current_win()
insert('text') insert('text')
command('new') command('new')

View File

@@ -221,9 +221,9 @@ describe('getbufvar() function', function()
eq(0, funcs.getbufvar(1, '&l:autoindent')) eq(0, funcs.getbufvar(1, '&l:autoindent'))
eq(0, funcs.getbufvar(1, '&g:autoindent')) eq(0, funcs.getbufvar(1, '&g:autoindent'))
-- Also works with global-only options -- Also works with global-only options
eq(0, funcs.getbufvar(1, '&hidden')) eq(1, funcs.getbufvar(1, '&hidden'))
eq(0, funcs.getbufvar(1, '&l:hidden')) eq(1, funcs.getbufvar(1, '&l:hidden'))
eq(0, funcs.getbufvar(1, '&g:hidden')) eq(1, funcs.getbufvar(1, '&g:hidden'))
-- Also works with window-local options -- Also works with window-local options
eq(0, funcs.getbufvar(1, '&number')) eq(0, funcs.getbufvar(1, '&number'))
eq(0, funcs.getbufvar(1, '&l:number')) eq(0, funcs.getbufvar(1, '&l:number'))
@@ -279,9 +279,9 @@ describe('setbufvar() function', function()
eq(false, winmeths.get_option(windows[3], 'number')) eq(false, winmeths.get_option(windows[3], 'number'))
eq(false, winmeths.get_option(meths.get_current_win(), 'number')) eq(false, winmeths.get_option(meths.get_current_win(), 'number'))
eq(false, meths.get_option('hidden'))
funcs.setbufvar(1, '&hidden', true)
eq(true, meths.get_option('hidden')) eq(true, meths.get_option('hidden'))
funcs.setbufvar(1, '&hidden', 0)
eq(false, meths.get_option('hidden'))
eq(false, bufmeths.get_option(buf1, 'autoindent')) eq(false, bufmeths.get_option(buf1, 'autoindent'))
funcs.setbufvar(1, '&autoindent', true) funcs.setbufvar(1, '&autoindent', true)

View File

@@ -55,6 +55,7 @@ describe(":drop", function()
end) end)
it("splits off a new window when a buffer can't be abandoned", function() it("splits off a new window when a buffer can't be abandoned", function()
command("set nohidden")
feed_command("edit tmp1") feed_command("edit tmp1")
feed_command("vsplit") feed_command("vsplit")
feed_command("edit tmp2") feed_command("edit tmp2")

View File

@@ -47,6 +47,7 @@ for _, c in ipairs({'l', 'c'}) do
eq(('%s-2.res'):format(file), funcs.bufname(list[2].bufnr)) eq(('%s-2.res'):format(file), funcs.bufname(list[2].bufnr))
-- Run cfile/lfile from a modified buffer -- Run cfile/lfile from a modified buffer
command('set nohidden')
command('enew!') command('enew!')
curbufmeths.set_lines(1, 1, true, {'Quickfix'}) curbufmeths.set_lines(1, 1, true, {'Quickfix'})
eq(('Vim(%s):E37: No write since last change (add ! to override)'):format( eq(('Vim(%s):E37: No write since last change (add ! to override)'):format(

View File

@@ -38,7 +38,7 @@ module.nvim_prog = (
module.nvim_set = ( module.nvim_set = (
'set shortmess+=IS background=light noswapfile noautoindent startofline' 'set shortmess+=IS background=light noswapfile noautoindent startofline'
..' laststatus=1 undodir=. directory=. viewdir=. backupdir=.' ..' laststatus=1 undodir=. directory=. viewdir=. backupdir=.'
..' belloff= wildoptions-=pum noshowcmd noruler nomore redrawdebug=invalid') ..' belloff= wildoptions-=pum joinspaces noshowcmd noruler nomore redrawdebug=invalid')
module.nvim_argv = { module.nvim_argv = {
module.nvim_prog, '-u', 'NONE', '-i', 'NONE', module.nvim_prog, '-u', 'NONE', '-i', 'NONE',
'--cmd', module.nvim_set, '--cmd', module.nvim_set,

View File

@@ -8,6 +8,9 @@ describe(':ball', function()
setup(clear) setup(clear)
it('is working', function() it('is working', function()
-- Must disable 'hidden' so that the BufReadPost autocmd is triggered
-- when Xxx2 is reloaded
feed_command('set nohidden')
insert([[ insert([[
start of test file Xxx start of test file Xxx
this is a test this is a test
@@ -18,7 +21,7 @@ describe(':ball', function()
feed('gg') feed('gg')
-- Write test file Xxx1 -- Write test file Xxx1
feed('A1:.,/end of/w! Xxx1<cr>') feed('A1<esc>:.,/end of/w! Xxx1<cr>')
feed_command('sp Xxx1') feed_command('sp Xxx1')
feed_command('close') feed_command('close')

View File

@@ -71,6 +71,9 @@ describe('autocommands that delete and unload buffers:', function()
au BufUnload * call CloseAll() au BufUnload * call CloseAll()
au VimLeave * call WriteToOut() au VimLeave * call WriteToOut()
]]) ]])
-- Must disable 'hidden' so that the BufUnload autocmd is triggered between
-- each :edit
command('set nohidden')
command('silent! edit Xxx2') command('silent! edit Xxx2')
command('silent! edit Xxx1') command('silent! edit Xxx1')
command('silent! edit Makefile') -- an existing file command('silent! edit Makefile') -- an existing file

View File

@@ -129,13 +129,11 @@ describe('file reading, writing and bufnew and filter autocommands', function()
-- Will load Xtest.c. -- Will load Xtest.c.
feed_command('e! foo.c') feed_command('e! foo.c')
feed_command("au FileAppendPre *.out '[,']s/new/NEW/") feed_command("au FileAppendPre *.out '[,']s/new/NEW/")
feed_command('au FileAppendPost *.out !cat Xtest.c >>test.out') feed_command('au FileAppendPost *.out !cat Xtest.c >test.out')
-- Append it to the output file. -- Append it to the output file.
feed_command('w>>test.out') feed_command('w>>test.out')
-- Discard all prompts and messages. -- Discard all prompts and messages.
feed('<C-L>') feed('<C-L>')
-- Expect the decompressed file in the buffer.
feed_command('e test.out')
expect([[ expect([[
/* /*

View File

@@ -80,6 +80,7 @@ describe("'directory' option", function()
eq({ "Xtest1.swp", "Xtest3" }, ls_dir_sorted("Xtest2")) eq({ "Xtest1.swp", "Xtest3" }, ls_dir_sorted("Xtest2"))
meths.set_option('directory', 'Xtest.je') meths.set_option('directory', 'Xtest.je')
command('bdelete')
command('edit Xtest2/Xtest3') command('edit Xtest2/Xtest3')
eq(true, curbufmeths.get_option('swapfile')) eq(true, curbufmeths.get_option('swapfile'))
poke_eventloop() poke_eventloop()

View File

@@ -156,10 +156,12 @@ describe('argument list commands', function()
eq({'a', 'b', 'a', 'c'}, eval('argv()')) eq({'a', 'b', 'a', 'c'}, eval('argv()'))
command('0argedit x') command('0argedit x')
eq({'x', 'a', 'b', 'a', 'c'}, eval('argv()')) eq({'x', 'a', 'b', 'a', 'c'}, eval('argv()'))
command('set nohidden')
command('enew! | set modified') command('enew! | set modified')
assert_fails('argedit y', 'E37:') assert_fails('argedit y', 'E37:')
command('argedit! y') command('argedit! y')
eq({'x', 'y', 'y', 'a', 'b', 'a', 'c'}, eval('argv()')) eq({'x', 'y', 'y', 'a', 'b', 'a', 'c'}, eval('argv()'))
command('set hidden')
command('%argd') command('%argd')
command('argedit a b') command('argedit a b')
eq({'a', 'b'}, eval('argv()')) eq({'a', 'b'}, eval('argv()'))

View File

@@ -91,7 +91,8 @@ describe('cdo', function()
exe "silent! 4,5" . XdoCmd exe "silent! 4,5" . XdoCmd
call assert_equal([], l) call assert_equal([], l)
" Run commands from an unsaved buffer " Run commands from an unsaved buffer when 'hidden' is unset
set nohidden
let v:errmsg='' let v:errmsg=''
let l = [] let l = []
enew enew
@@ -108,6 +109,7 @@ describe('cdo', function()
if subst_count != 1 || getline('.') != 'xLine1' if subst_count != 1 || getline('.') != 'xLine1'
call add(v:errors, 'Abort command on error test failed') call add(v:errors, 'Abort command on error test failed')
endif endif
set hidden
let l = [] let l = []
exe "2,2" . Xdo . "! call add(l, GetRuler())" exe "2,2" . Xdo . "! call add(l, GetRuler())"

View File

@@ -23,8 +23,6 @@ describe('fixeol', function()
it('is working', function() it('is working', function()
-- First write two test files with and without trailing EOL. -- First write two test files with and without trailing EOL.
-- Use Unix fileformat for consistency.
feed_command('set ff=unix')
feed_command('enew!') feed_command('enew!')
feed('awith eol<esc>:w! XXEol<cr>') feed('awith eol<esc>:w! XXEol<cr>')
feed_command('enew!') feed_command('enew!')
@@ -40,7 +38,7 @@ describe('fixeol', function()
feed_command('e! XXNoEol') feed_command('e! XXNoEol')
feed('ostays without<esc>:set nofixeol<cr>') feed('ostays without<esc>:set nofixeol<cr>')
feed_command('w! XXTestNoEol') feed_command('w! XXTestNoEol')
feed_command('bwipe XXEol XXNoEol XXTestEol XXTestNoEol') feed_command('bwipe! XXEol XXNoEol XXTestEol XXTestNoEol')
feed_command('set fixeol') feed_command('set fixeol')
-- Append "END" to each file so that we can see what the last written char was. -- Append "END" to each file so that we can see what the last written char was.

View File

@@ -2161,6 +2161,12 @@ describe('plugin/shada.vim', function()
reset() reset()
wshada('\004\000\009\147\000\196\002ab\196\001a') wshada('\004\000\009\147\000\196\002ab\196\001a')
wshada_tmp('\004\000\009\147\000\196\002ab\196\001b') wshada_tmp('\004\000\009\147\000\196\002ab\196\001b')
-- Need to set nohidden so that the buffer containing 'fname' is not unloaded
-- after loading 'fname_tmp', otherwise the '++opt not supported' test below
-- won't work since the BufReadCmd autocmd won't be triggered.
nvim_command('set nohidden')
nvim_command('edit ' .. fname) nvim_command('edit ' .. fname)
eq({ eq({
'History entry with timestamp ' .. epoch .. ':', 'History entry with timestamp ' .. epoch .. ':',

View File

@@ -74,7 +74,8 @@ describe('float window', function()
funcs.win_execute(win, 'bwipe!') funcs.win_execute(win, 'bwipe!')
end) end)
it('win_execute() call commands that not allowed' , function() it("win_execute() call commands that are not allowed when 'hidden' is not set" , function()
command('set nohidden')
local buf = meths.create_buf(false, false) local buf = meths.create_buf(false, false)
meths.buf_set_lines(buf, 0, -1, true, {'the floatwin'}) meths.buf_set_lines(buf, 0, -1, true, {'the floatwin'})
local win = meths.open_win(buf, true, {relative='win', width=16, height=1, row=0, col=10}) local win = meths.open_win(buf, true, {relative='win', width=16, height=1, row=0, col=10})

View File

@@ -69,6 +69,7 @@ describe('ui/ext_tabline', function()
command("bnext") command("bnext")
local expected_buffers = { local expected_buffers = {
{buffer = { id = 1 }, name = '[No Name]'},
{buffer = { id = 2 }, name = 'another-buffer'}, {buffer = { id = 2 }, name = 'another-buffer'},
} }
screen:expect{grid=[[ screen:expect{grid=[[