Skip to content

Commit

Permalink
feat(api): allow a match to disable getting a label
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 26, 2023
1 parent 3b839b5 commit ea56cea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ interface FlashMatch {
win: number;
pos: [number, number]; // (1,0)-indexed
end_pos: [number, number]; // (1,0)-indexed
label?: string;
label?: string | false; // set to false to never show a label for this match
}

// Check the code for the full definition
Expand Down
6 changes: 4 additions & 2 deletions lua/flash/labeler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ function M:reset()
end
end
for _, m in ipairs(self.state.results) do
m.label = nil
if m.label ~= false then
m.label = nil
end
end
end

Expand All @@ -71,7 +73,7 @@ end
---@param m Flash.Match
---@param used boolean?
function M:label(m, used)
if m.label then
if m.label ~= nil then
return true
end
local pos = m.pos:id(m.win)
Expand Down
2 changes: 1 addition & 1 deletion lua/flash/search/matcher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local Pos = require("flash.search.pos")
---@field win window
---@field pos Pos -- (1,0) indexed
---@field end_pos Pos -- (1,0) indexed
---@field label? string
---@field label? string|false

---@alias Flash.Match.Find {forward?:boolean, wrap?:boolean, count?:number, pos?: Pos, match?:Flash.Match}

Expand Down

0 comments on commit ea56cea

Please sign in to comment.