Skip to content

Commit d67f0d3

Browse files
Do not ignore wildcards when expanding directory paths
Closes #25
1 parent dfb5fb8 commit d67f0d3

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
@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
77
- Fix: Correctly center floating terminal when no borders are used.
88
- Set terminal window as `nolist`.
99
- Add `fixed_height` & `fixed_width` options to control whether terminal size should be preserved on new splits.
10+
- Do not ignore wildcard patterns when expanding `dir`.
1011

1112
## 1.0.0 - 2025-11-21
1213

lua/ergoterm/instance.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ function Terminal:_compute_dir()
503503
elseif self.dir == nil then
504504
dir = vim.loop.cwd()
505505
else
506-
dir = vim.fn.expand(self.dir)
506+
dir = vim.fn.expand(self.dir, true)
507507
if vim.fn.isdirectory(dir) == 0 then
508508
utils.notify(
509509
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
@@ -284,6 +284,14 @@ describe(":new", function()
284284
assert.equal("/tmp", term:get_state("dir"))
285285
end)
286286

287+
it("initializes directory even when it matches wildignore pattern", function()
288+
test_helpers.with_option("wildignore", "**/tmp", function()
289+
local term = Terminal:new({ dir = "/tmp" })
290+
291+
assert.equal("/tmp", term:get_state("dir"))
292+
end)
293+
end)
294+
287295
it("errors if dir is not a valid directory", function()
288296
local result = test_helpers.mocking_notify(function()
289297
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)