Skip to content

Commit

Permalink
fix(picker): reject non-dir path option (#363)
Browse files Browse the repository at this point in the history
Doing `:Telescope file_browser path=/path/to/some/file.txt` now throws
an optional warning (based on "quiet" option) and just opens in
file_browser in the cwd.
  • Loading branch information
jamestrew authored Mar 6, 2024
1 parent 48ffb8d commit 8839e3f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lua/telescope/_extensions/file_browser/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ fb_utils.to_absolute_path = function(str)
if not path:exists() then
fb_utils.notify("to_absolute_path", { msg = string.format("Given path '%s' doesn't exist", path), level = "WARN" })
return nil
elseif not path:is_dir() then
fb_utils.notify(
"to_absolute_path",
{ msg = string.format("Given path '%s' is not a directory", path), level = "WARN" }
)
return nil
end
return path:absolute()
end
Expand Down

0 comments on commit 8839e3f

Please sign in to comment.