Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make workspace detection more robust #578

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Comment on lines +159 to +167
Copy link

@sadtab sadtab May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Piece of art, you just read plain English: 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