Skip to content

Commit

Permalink
fix(filter): fix range filter to include col
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 30, 2024
1 parent 3cda187 commit 6cae8af
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lua/trouble/filter.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
local M = {}

local function overlaps(pos, item)
return (pos[1] > item.pos[1] or (pos[1] == item.pos[1] and pos[2] >= item.pos[2]))
and (pos[1] < item.end_pos[1] or (pos[1] == item.end_pos[1] and pos[2] <= item.end_pos[2]))
end

---@alias trouble.Filter.ctx {opts:trouble.Config, main?:trouble.Main}
---@alias trouble.FilterFn fun(item:trouble.Item, value: any, ctx:trouble.Filter.ctx): boolean
---@class trouble.Filters: {[string]: trouble.FilterFn}
Expand All @@ -23,9 +28,9 @@ M.filters = {
end
local range = item.range --[[@as trouble.Item]]
if range then
return main.cursor[1] >= range.pos[1] and main.cursor[1] <= range.end_pos[1]
return overlaps(main.cursor, range)
else
return main.cursor[1] >= item.pos[1] and main.cursor[1] <= item.end_pos[1]
return overlaps(main.cursor, item)
end
end,
["not"] = function(item, filter, ctx)
Expand Down

0 comments on commit 6cae8af

Please sign in to comment.