feat(picker): getters and setters for cwd

This commit is contained in:
Folke Lemaitre 2025-01-20 20:20:40 +01:00
parent 32be045f41
commit 2c2ff4caf8
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 15 additions and 0 deletions

View file

@ -43,6 +43,12 @@ function M.new(picker)
return self
end
---@param cwd string
function M:set_cwd(cwd)
self.cwd = cwd
self.cwd = vim.fs.normalize(self.cwd --[[@as string]], { _fast = true })
end
---@param opts? {trim?:boolean}
---@return snacks.picker.Filter
function M:clone(opts)

View file

@ -592,6 +592,15 @@ function M:hist_record(force)
})
end
function M:cwd()
return self.input.filter.cwd
end
function M:set_cwd(cwd)
self.input.filter:set_cwd(cwd)
self.opts.cwd = cwd
end
--- Move the history cursor
---@param forward? boolean
function M:hist(forward)