Skip to content

Commit

Permalink
Don't open picker for tags when there aren't any results
Browse files Browse the repository at this point in the history
See #493.
  • Loading branch information
epwalsh committed Mar 15, 2024
1 parent 0f4ea50 commit 450c3da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
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

- Don't open picker for tags when there aren't any matches.

## [v3.7.3](https://github.com/epwalsh/obsidian.nvim/releases/tag/v3.7.3) - 2024-03-13

### Changed
Expand Down
14 changes: 9 additions & 5 deletions lua/obsidian/commands/tags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ local search = require "obsidian.search"
---@param tags string[]
local function gather_tag_picker_list(client, picker, tags)
client:find_tags_async(tags, function(tag_locations)
if vim.tbl_isempty(tag_locations) then
log.warn "Tags not found"
return
end

-- Format results into picker entries, filtering out results that aren't exact matches or sub-tags.
---@type obsidian.PickerEntry[]
local entries = {}
Expand All @@ -32,6 +27,15 @@ local function gather_tag_picker_list(client, picker, tags)
end
end

if vim.tbl_isempty(entries) then
if #tags == 1 then
log.warn "Tag not found"
else
log.warn "Tags not found"
end
return
end

vim.schedule(function()
picker:pick(entries, {
prompt_title = "#" .. table.concat(tags, ", #"),
Expand Down

0 comments on commit 450c3da

Please sign in to comment.