@@ -189,6 +189,47 @@ local function filter_file_ignore_patters(items, opts)
189
189
end , items )
190
190
end
191
191
192
+ --- @param items vim.quickfix.entry[]
193
+ --- @param opts table
194
+ --- @return vim.quickfix.entry[]
195
+ local function remove_duplicates (items )
196
+ local seen = {}
197
+ local result = {}
198
+ for _ , value in ipairs (items ) do
199
+ key = string.format (" %s:%d:%d:%s" , value .filename , value .lnum , value .col , value .text )
200
+ if not seen [key ] then
201
+ table.insert (result , value )
202
+ seen [key ] = true
203
+ end
204
+ end
205
+ return result
206
+ end
207
+
208
+ --- @param items vim.quickfix.entry[]
209
+ --- @return vim.quickfix.entry[]
210
+ local function apply_post_process_handler (items , opts )
211
+ local post_process = vim .F .if_nil (opts .post_process , conf .post_process )
212
+ if type (post_process ) == " function" then
213
+ items = post_process (items )
214
+ if items == nil then
215
+ utils .notify (" buildin.post_process" , {
216
+ msg = " 'post_process' value is nil" ,
217
+ level = " ERROR" ,
218
+ })
219
+ items = {}
220
+ end
221
+ elseif post_process == " deduplicate" then
222
+ return remove_duplicates (items )
223
+ elseif post_process == nil then
224
+ else
225
+ utils .notify (" buildin.post_process" , {
226
+ msg = " Unexpected 'post_process' value: " .. post_process ,
227
+ level = " WARN" ,
228
+ })
229
+ end
230
+ return items
231
+ end
232
+
192
233
--- @param action telescope.lsp.list_or_jump_action
193
234
--- @param title string prompt title
194
235
--- @param funname string : name of the calling function
@@ -234,6 +275,7 @@ local function list_or_jump(action, title, funname, params, opts)
234
275
235
276
items = apply_action_handler (action , items , opts )
236
277
items = filter_file_ignore_patters (items , opts )
278
+ items = apply_post_process_handler (items , opts )
237
279
238
280
if vim .tbl_isempty (items ) then
239
281
utils .notify (funname , {
0 commit comments