Skip to content

Commit 60fe867

Browse files
Do not ignore wildcards when expanding directory paths
Closes #25
1 parent 0c7dc9b commit 60fe867

5 files changed

Lines changed: 14 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
66

77
- Fix: Correctly center floating terminal when no borders are used.
88
- Set terminal window as `nolist`.
9+
- Do not ignore wildcard patterns when expanding `dir`.
910

1011
## 1.0.0 - 2025-11-21
1112

lua/ergoterm/instance.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ function Terminal:_compute_dir()
499499
elseif self.dir == nil then
500500
dir = vim.loop.cwd()
501501
else
502-
dir = vim.fn.expand(self.dir)
502+
dir = vim.fn.expand(self.dir, true)
503503
if vim.fn.isdirectory(dir) == 0 then
504504
utils.notify(
505505
string.format("%s is not a directory", dir),

spec/ergoterm/commands_spec.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ describe("M.new", function()
2121
local original_expand = vim.fn.expand
2222
local original_isdirectory = vim.fn.isdirectory
2323
--- @diagnostic disable: duplicate-set-field
24-
vim.fn.expand = function(path) return path end
24+
--- @diagnostic disable-next-line: unused-vararg
25+
vim.fn.expand = function(path, ...) return path end
2526
vim.fn.isdirectory = function(_) return 1 end
2627
--- @diagnostic enable: duplicate-set-field
2728

spec/ergoterm/instance_spec.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,14 @@ describe(":new", function()
272272
assert.equal("/tmp", term:get_state("dir"))
273273
end)
274274

275+
it("initializes directory even when it matches wildignore pattern", function()
276+
test_helpers.with_option("wildignore", "**/tmp", function()
277+
local term = Terminal:new({ dir = "/tmp" })
278+
279+
assert.equal("/tmp", term:get_state("dir"))
280+
end)
281+
end)
282+
275283
it("errors if dir is not a valid directory", function()
276284
local result = test_helpers.mocking_notify(function()
277285
Terminal:new({ dir = "/invalid" })

spec/ergoterm/utils_spec.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ describe(".get_dir", function()
127127
---@diagnostic disable: duplicate-set-field
128128
utils.git_dir = function() return "/git/dir" end
129129
vim.loop.cwd = function() return "/current/dir" end
130-
vim.fn.expand = function(arg) return "/expanded/" .. arg end
130+
--- @diagnostic disable-next-line: unused-vararg
131+
vim.fn.expand = function(arg, ...) return "/expanded/" .. arg end
131132
vim.fn.isdirectory = function(_) return 1 end
132133
end)
133134

0 commit comments

Comments
 (0)