diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c71fbeb..e1ffbba 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,7 +8,7 @@ on: jobs: lint: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index a6e8266..a4e50bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. - Fix: Correctly center floating terminal when no borders are used. - 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`. ## 1.0.0 - 2025-11-21 diff --git a/lua/ergoterm/instance.lua b/lua/ergoterm/instance.lua index 337b767..69ff933 100644 --- a/lua/ergoterm/instance.lua +++ b/lua/ergoterm/instance.lua @@ -503,7 +503,7 @@ function Terminal:_compute_dir() elseif self.dir == nil then dir = vim.loop.cwd() else - dir = vim.fn.expand(self.dir) + dir = vim.fn.expand(self.dir, true) if vim.fn.isdirectory(dir) == 0 then utils.notify( string.format("%s is not a directory", dir), diff --git a/spec/ergoterm/commands_spec.lua b/spec/ergoterm/commands_spec.lua index 43489c8..74c6482 100644 --- a/spec/ergoterm/commands_spec.lua +++ b/spec/ergoterm/commands_spec.lua @@ -21,7 +21,8 @@ describe("M.new", function() local original_expand = vim.fn.expand local original_isdirectory = vim.fn.isdirectory --- @diagnostic disable: duplicate-set-field - vim.fn.expand = function(path) return path end + --- @diagnostic disable-next-line: unused-vararg + vim.fn.expand = function(path, ...) return path end vim.fn.isdirectory = function(_) return 1 end --- @diagnostic enable: duplicate-set-field diff --git a/spec/ergoterm/instance_spec.lua b/spec/ergoterm/instance_spec.lua index 2dabbfe..0e230a6 100644 --- a/spec/ergoterm/instance_spec.lua +++ b/spec/ergoterm/instance_spec.lua @@ -284,6 +284,14 @@ describe(":new", function() assert.equal("/tmp", term:get_state("dir")) end) + it("initializes directory even when it matches wildignore pattern", function() + test_helpers.with_option("wildignore", "**/tmp", function() + local term = Terminal:new({ dir = "/tmp" }) + + assert.equal("/tmp", term:get_state("dir")) + end) + end) + it("errors if dir is not a valid directory", function() local result = test_helpers.mocking_notify(function() Terminal:new({ dir = "/invalid" }) diff --git a/spec/ergoterm/utils_spec.lua b/spec/ergoterm/utils_spec.lua index 3abc875..dff1538 100644 --- a/spec/ergoterm/utils_spec.lua +++ b/spec/ergoterm/utils_spec.lua @@ -127,7 +127,8 @@ describe(".get_dir", function() ---@diagnostic disable: duplicate-set-field utils.git_dir = function() return "/git/dir" end vim.loop.cwd = function() return "/current/dir" end - vim.fn.expand = function(arg) return "/expanded/" .. arg end + --- @diagnostic disable-next-line: unused-vararg + vim.fn.expand = function(arg, ...) return "/expanded/" .. arg end vim.fn.isdirectory = function(_) return 1 end end)