diff --git a/CHANGELOG.md b/CHANGELOG.md index f02c11b0b..1bac6e168 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lua/obsidian/workspace.lua b/lua/obsidian/workspace.lua index 3eaee0fca..3d898b68b 100644 --- a/lua/obsidian/workspace.lua +++ b/lua/obsidian/workspace.lua @@ -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