Skip to content

Commit 4e89bd0

Browse files
Makes the property searching case insensitive (#457)
1 parent 5351b85 commit 4e89bd0

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

lua/orgmode/parser/search.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function Search:_matches(val, item)
6363
end
6464
return val == item.tags
6565
end
66-
prop_name = vim.trim(prop_name)
66+
prop_name = string.lower(vim.trim(prop_name))
6767
prop_val = vim.trim(prop_val)
6868
if not item.props or not item.props[prop_name] then
6969
return false

tests/plenary/parser/search_spec.lua

+19-19
Original file line numberDiff line numberDiff line change
@@ -68,109 +68,109 @@ describe('Search parser', function()
6868
it('should parse search term and match string properties and value', function()
6969
local result = Search:new('CATEGORY="test"&MYPROP=myval+WORK')
7070
assert.Is.True(result:check({
71-
props = { CATEGORY = 'test', MYPROP = 'myval', AGE = 10 },
71+
props = { category = 'test', myprop = 'myval', age = 10 },
7272
tags = { 'WORK', 'OFFICE' },
7373
}))
7474

7575
assert.Is.False(result:check({
76-
props = { CATEGORY = 'invalid', MYPROP = 'myval', AGE = 10 },
76+
props = { category = 'invalid', myprop = 'myval', age = 10 },
7777
tags = { 'WORK', 'OFFICE' },
7878
}))
7979

8080
assert.Is.False(result:check({
81-
props = { CATEGORY = 'test', MYPROP = 'myval', AGE = 10 },
81+
props = { category = 'test', myprop = 'myval', age = 10 },
8282
tags = { 'OFFICE' },
8383
}))
8484
end)
8585

8686
it('should parse search term and match number properties and value', function()
8787
local result = Search:new('PAGES>=1000&ITEMS<500&COUNT=10&CALCULATION<>5&BOOKS>3+WORK')
8888
assert.Is.True(result:check({
89-
props = { PAGES = 1010, ITEMS = 100, COUNT = 10, CALCULATION = 8, BOOKS = 5 },
89+
props = { pages = 1010, items = 100, count = 10, calculation = 8, books = 5 },
9090
tags = { 'WORK', 'OFFICE' },
9191
}))
9292

9393
assert.Is.True(result:check({
94-
props = { PAGES = 1000, ITEMS = 499, COUNT = 10, CALCULATION = 10, BOOKS = 4 },
94+
props = { pages = 1000, items = 499, count = 10, calculation = 10, books = 4 },
9595
tags = { 'WORK' },
9696
}))
9797

9898
assert.Is.False(result:check({
99-
props = { PAGES = 999, ITEMS = 499, COUNT = 10, CALCULATION = 10, BOOKS = 4 },
99+
props = { pages = 999, items = 499, count = 10, calculation = 10, books = 4 },
100100
tags = { 'WORK' },
101101
}))
102102

103103
assert.Is.False(result:check({
104-
props = { PAGES = 1001, ITEMS = 500, COUNT = 10, CALCULATION = 10, BOOKS = 4 },
104+
props = { pages = 1001, items = 500, count = 10, calculation = 10, books = 4 },
105105
tags = { 'WORK' },
106106
}))
107107

108108
assert.Is.False(result:check({
109-
props = { PAGES = 1001, ITEMS = 500, COUNT = 11, CALCULATION = 10, BOOKS = 4 },
109+
props = { pages = 1001, items = 500, count = 11, calculation = 10, books = 4 },
110110
tags = { 'WORK' },
111111
}))
112112

113113
assert.Is.False(result:check({
114-
props = { PAGES = 1001, ITEMS = 500, COUNT = 11, CALCULATION = 5, BOOKS = 4 },
114+
props = { pages = 1001, items = 500, count = 11, calculation = 5, books = 4 },
115115
tags = { 'WORK' },
116116
}))
117117

118118
assert.Is.False(result:check({
119-
props = { PAGES = 1001, ITEMS = 500, COUNT = 11, CALCULATION = 5, BOOKS = 3 },
119+
props = { pages = 1001, items = 500, count = 11, calculation = 5, books = 3 },
120120
tags = { 'WORK' },
121121
}))
122122

123123
assert.Is.False(result:check({
124-
props = { PAGES = 1010, ITEMS = 100, COUNT = 10, CALCULATION = 8, BOOKS = 5 },
124+
props = { pages = 1010, items = 100, count = 10, calculation = 8, books = 5 },
125125
tags = { 'OFFICE' },
126126
}))
127127
end)
128128

129129
it('should search props, tags and todo keywords', function()
130130
local result = Search:new('CATEGORY="test"&MYPROP=myval+WORK/TODO|NEXT')
131131
assert.Is.True(result:check({
132-
props = { CATEGORY = 'test', MYPROP = 'myval', AGE = 10 },
132+
props = { category = 'test', myprop = 'myval', age = 10 },
133133
tags = { 'WORK', 'OFFICE' },
134134
todo = { 'TODO' },
135135
}))
136136
assert.Is.True(result:check({
137-
props = { CATEGORY = 'test', MYPROP = 'myval', AGE = 10 },
137+
props = { category = 'test', myprop = 'myval', age = 10 },
138138
tags = { 'WORK', 'OFFICE' },
139139
todo = 'NEXT',
140140
}))
141141
assert.Is.False(result:check({
142-
props = { CATEGORY = 'test', MYPROP = 'myval', AGE = 10 },
142+
props = { category = 'test', myprop = 'myval', age = 10 },
143143
tags = { 'WORK', 'OFFICE' },
144144
todo = { 'DONE' },
145145
}))
146146

147147
result = Search:new('CATEGORY="test"+WORK/-WAITING')
148148
assert.Is.True(result:check({
149-
props = { CATEGORY = 'test' },
149+
props = { category = 'test' },
150150
tags = { 'WORK' },
151151
todo = { 'TODO' },
152152
}))
153153

154154
assert.Is.True(result:check({
155-
props = { CATEGORY = 'test' },
155+
props = { category = 'test' },
156156
tags = { 'WORK' },
157157
todo = { 'DONE' },
158158
}))
159159

160160
assert.Is.False(result:check({
161-
props = { CATEGORY = 'test' },
161+
props = { category = 'test' },
162162
tags = { 'WORK' },
163163
todo = { 'WAITING' },
164164
}))
165165

166166
assert.Is.False(result:check({
167-
props = { CATEGORY = 'test_bad' },
167+
props = { category = 'test_bad' },
168168
tags = { 'WORK' },
169169
todo = { 'DONE' },
170170
}))
171171

172172
assert.Is.False(result:check({
173-
props = { CATEGORY = 'test' },
173+
props = { category = 'test' },
174174
tags = { 'OFFICE' },
175175
todo = { 'DONE' },
176176
}))

0 commit comments

Comments
 (0)