vim-patch:8.2.3920: restoring directory after using another window is inefficient

Problem:    Restoring directory after using another window is inefficient.
Solution:   Only restore the directory for win_execute().  Apply 'autochdir'
            only when needed.
90c317f224
This commit is contained in:
zeertzjq
2022-03-06 08:11:52 +08:00
parent 1a5409db0d
commit da9bc96152
4 changed files with 51 additions and 3 deletions

View File

@@ -61,6 +61,20 @@ describe('autochdir behavior', function()
expected_empty()
end)
it('win_execute() does not change directory', function()
local subdir = 'Xfile'
command('cd '..dir)
command('set autochdir')
call('mkdir', subdir)
local winid = eval('win_getid()')
command('new '..subdir..'/file')
matches('.*'..dir..'[/\\]'..subdir, eval('getcwd()'))
command('cd ..')
matches('.*'..dir, eval('getcwd()'))
call('win_execute', winid, 'echo')
matches('.*'..dir, eval('getcwd()'))
end)
it(':verbose pwd shows whether autochdir is used', function()
local subdir = 'Xautodir'
command('cd '..dir)