Skip to content

Commit

Permalink
Make workspace detection more robust (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
epwalsh authored May 8, 2024
1 parent db41b1f commit 2e1f034
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed

- Made workspace detection more robust.

## [v3.7.12](https://github.com/epwalsh/obsidian.nvim/releases/tag/v3.7.12) - 2024-05-02

### Changed
Expand Down
10 changes: 9 additions & 1 deletion lua/obsidian/workspace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,15 @@ end
---
---@return obsidian.Workspace|?
Workspace.get_workspace_for_dir = function(cur_dir, workspaces)
cur_dir = Path.new(cur_dir):resolve { strict = true }
local ok
ok, cur_dir = pcall(function()
return Path.new(cur_dir):resolve { strict = true }
end)

if not ok then
return
end

for _, spec in ipairs(workspaces) do
local w = Workspace.new_from_spec(spec)
if w.path == cur_dir or w.path:is_parent_of(cur_dir) then
Expand Down

0 comments on commit 2e1f034

Please sign in to comment.