mirror of
https://github.com/akinsho/toggleterm.nvim
synced 2024-09-16 21:34:03 +02:00
fix: autochdir for custom terminals (#553)
* fix: autochdir for custom terminals * refactor: use ternary expression can do it like this when the variable is now assigned outside of this block
This commit is contained in:
parent
fef08f32b9
commit
dca1c80fb8
1 changed files with 3 additions and 5 deletions
|
@ -485,7 +485,8 @@ end
|
|||
---@param size number?
|
||||
---@param direction string?
|
||||
function Terminal:open(size, direction)
|
||||
self.dir = _get_dir(self.dir)
|
||||
local cwd = fn.getcwd()
|
||||
self.dir = _get_dir(config.autochdir and cwd or self.dir)
|
||||
ui.set_origin_window()
|
||||
if direction then self:change_direction(direction) end
|
||||
if not self.bufnr or not api.nvim_buf_is_valid(self.bufnr) then
|
||||
|
@ -496,10 +497,7 @@ function Terminal:open(size, direction)
|
|||
local ok, err = pcall(opener, size, self)
|
||||
if not ok and err then return utils.notify(err, "error") end
|
||||
ui.switch_buf(self.bufnr)
|
||||
if config.autochdir then
|
||||
local cwd = fn.getcwd()
|
||||
if self.dir ~= cwd then self:change_dir(cwd) end
|
||||
end
|
||||
if config.autochdir and self.dir ~= cwd then self:change_dir(cwd) end
|
||||
end
|
||||
ui.hl_term(self)
|
||||
-- NOTE: it is important that this function is called at this point. i.e. the buffer has been correctly assigned
|
||||
|
|
Loading…
Reference in a new issue