neovim/test/functional/options/autochdir_spec.lua

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.5 KiB
Lua
Raw Normal View History

local luv = require('luv')
2016-07-01 11:27:56 -07:00
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
2022-03-05 20:01:49 -07:00
local funcs = helpers.funcs
local command = helpers.command
local mkdir = helpers.mkdir
2016-07-01 11:27:56 -07:00
describe("'autochdir'", function()
it('given on the shell gets processed properly', function()
local targetdir = 'test/functional/fixtures'
-- By default 'autochdir' is off, thus getcwd() returns the repo root.
clear(targetdir..'/tty-test.c')
2022-03-05 20:01:49 -07:00
local rootdir = funcs.getcwd()
local expected = rootdir .. '/' .. targetdir
2016-07-01 11:27:56 -07:00
-- With 'autochdir' on, we should get the directory of tty-test.c.
clear('--cmd', 'set autochdir', targetdir..'/tty-test.c')
eq(helpers.is_os('win') and expected:gsub('/', '\\') or expected, funcs.getcwd())
2022-03-05 20:01:49 -07:00
end)
it('is not overwritten by getwinvar() call #17609',function()
local curdir = string.gsub(luv.cwd(), '\\', '/')
2022-03-05 20:01:49 -07:00
local dir_a = curdir..'/Xtest-functional-options-autochdir.dir_a'
local dir_b = curdir..'/Xtest-functional-options-autochdir.dir_b'
mkdir(dir_a)
mkdir(dir_b)
2022-03-05 20:01:49 -07:00
clear()
command('set shellslash')
command('set autochdir')
command('edit '..dir_a..'/file1')
eq(dir_a, funcs.getcwd())
command('lcd '..dir_b)
eq(dir_b, funcs.getcwd())
command('botright vnew ../file2')
eq(curdir, funcs.getcwd())
command('wincmd w')
eq(dir_a, funcs.getcwd())
funcs.getwinvar(2, 'foo')
eq(dir_a, funcs.getcwd())
helpers.rmdir(dir_a)
helpers.rmdir(dir_b)
2016-07-01 11:27:56 -07:00
end)
end)