Skip to content

Commit 3a94a7f

Browse files
committed
ref(feliniser): move search condition to component
1 parent 9a0bff0 commit 3a94a7f

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lua/arshamiser/feliniser/init.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,16 @@ table.insert(components.active[3], {
450450
-- Search results key {{{
451451
table.insert(components.active[3], {
452452
provider = "search_results",
453+
enabled = function()
454+
if not vim.v.hlsearch or vim.v.hlsearch ~= 1 then
455+
return false
456+
end
457+
local lines = vim.api.nvim_buf_line_count(0)
458+
if lines > 50000 then
459+
return false
460+
end
461+
return true
462+
end,
453463
truncate_hide = true,
454464
hl = right_ribbon_hl,
455465
right_sep = {

lua/arshamiser/feliniser/util.lua

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,6 @@ function M.filename(_, opts) --{{{
306306
end --}}}
307307

308308
function M.search_results() --{{{
309-
local lines = vim.api.nvim_buf_line_count(0)
310-
if lines > 50000 then
311-
return ""
312-
end
313309
local search_term = vim.fn.getreg("/")
314310
if search_term == "" then
315311
return ""
@@ -319,11 +315,7 @@ function M.search_results() --{{{
319315
end
320316

321317
local search_count = vim.fn.searchcount({ recompute = 1, maxcount = -1 })
322-
local active = false
323-
if vim.v.hlsearch and vim.v.hlsearch == 1 and search_count.total > 0 then
324-
active = true
325-
end
326-
if not active then
318+
if search_count.total == 0 then
327319
return ""
328320
end
329321

0 commit comments

Comments
 (0)