Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
## [Unreleased]

- Fix: Correctly center floating terminal when no borders are used.
- Fix: Skip showing terminal if buffer is no longer valid or it doesn't exist.
- Set terminal window as `nolist`.
- Add `fixed_height` & `fixed_width` options to control whether terminal size should be preserved on new splits.
- Do not ignore wildcard patterns when expanding `dir`.
Expand Down
2 changes: 1 addition & 1 deletion lua/ergoterm/instance/open.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ end
---@param term Terminal
---@param layout layout?
function M.show(term, layout)
if not M.is_open(term) then
if not M.is_open(term) and term._state.bufnr and vim.api.nvim_buf_is_valid(term._state.bufnr) then
layout = layout or term._state.layout
local window = nil
if vim.tbl_contains(NEW_WINDOW_LAYOUTS, layout) then
Expand Down
12 changes: 12 additions & 0 deletions spec/ergoterm/instance/open_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ describe(".open", function()
assert.equal("right", win_config.split)
end)

it("does nothing if buffer is missing", function()
local term = Terminal:new():start()
term:cleanup()

local ok = pcall(function()
open.show(term)
end)

assert.is_true(ok)
assert.is_nil(term:get_state("window"))
end)

it("errors if layout is invalid", function()
local term = Terminal:new()

Expand Down