mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
feat(picker): picker:dir()
to get the dir of the item (when a directory) or it's parent (when a file)
This commit is contained in:
parent
6235f44b11
commit
969608ab79
1 changed files with 11 additions and 0 deletions
|
@ -553,6 +553,17 @@ function M:current(opts)
|
|||
return ret
|
||||
end
|
||||
|
||||
--- Returns the directory of the current item or the cwd.
|
||||
--- When the item is a directory, return item path,
|
||||
--- otherwise return the directory of the item.
|
||||
function M:dir()
|
||||
local item = self:current()
|
||||
if item then
|
||||
return Snacks.picker.util.dir(item)
|
||||
end
|
||||
return self:cwd()
|
||||
end
|
||||
|
||||
--- Get the selected items.
|
||||
--- If `fallback=true` and there is no selection, return the current item.
|
||||
---@param opts? {fallback?: boolean} default is `false`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue