Skip to content

Commit 3d6d0a5

Browse files
Übertreiberbroken-pen
andauthored
Fix tag parsing for search patterns. (#595)
Co-authored-by: Nico Madysa <[email protected]>
1 parent b5e12db commit 3d6d0a5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lua/orgmode/parser/search.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ end
339339
---@return TagMatch?, string
340340
function TagMatch:parse(input)
341341
local tag
342-
tag, input = parse_pattern(input, '%w+')
342+
tag, input = parse_pattern(input, '[%w_@#%%]+')
343343
if not tag then
344344
return nil, input
345345
end

tests/plenary/parser/search_spec.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,14 @@ describe('Search parser', function()
202202
todo = 'DONE',
203203
}))
204204
end)
205+
206+
it('should parse allowed punctuation in tags', function()
207+
local result = Search:new('lang_dev|@work|org#mode|a2%')
208+
assert.Is.True(result:check({ tags = { 'lang_dev' } }))
209+
assert.Is.True(result:check({ tags = { '@work' } }))
210+
assert.Is.True(result:check({ tags = { 'org#mode' } }))
211+
assert.Is.True(result:check({ tags = { 'a2%' } }))
212+
assert.Is.False(result:check({ tags = { 'lang', 'dev', 'work', 'org' } }))
213+
assert.Is.False(result:check({ tags = { 'mode', 'a2' } }))
214+
end)
205215
end)

0 commit comments

Comments
 (0)