mirror of
https://github.com/NotAShelf/syntax-gaslighting.nvim.git
synced 2026-04-17 08:19:51 +00:00
Merge pull request #1 from Jappie3/main
avoid gaslighting on identical lines
This commit is contained in:
commit
4cee4c0550
1 changed files with 17 additions and 9 deletions
|
|
@ -169,11 +169,18 @@ function M.update_decorations()
|
||||||
api.nvim_buf_clear_namespace(bufnr, ns, 0, -1) -- Clear previous decorations
|
api.nvim_buf_clear_namespace(bufnr, ns, 0, -1) -- Clear previous decorations
|
||||||
local lines = api.nvim_buf_get_lines(bufnr, 0, -1, false)
|
local lines = api.nvim_buf_get_lines(bufnr, 0, -1, false)
|
||||||
|
|
||||||
|
-- Track processed lines to avoid duplicates
|
||||||
|
local processed_hashes = {}
|
||||||
|
|
||||||
for i, line in ipairs(lines) do
|
for i, line in ipairs(lines) do
|
||||||
local trimmed = vim.trim(line)
|
local trimmed = vim.trim(line)
|
||||||
|
|
||||||
-- Skip comment lines entirely
|
-- Skip comment lines entirely
|
||||||
if #trimmed >= config.min_line_length and not isComment(trimmed) then
|
if #trimmed >= config.min_line_length and not isComment(trimmed) then
|
||||||
|
local hash = createHash(trimmed)
|
||||||
|
|
||||||
|
if not processed_hashes[hash] then
|
||||||
|
processed_hashes[hash] = true
|
||||||
local message = getGaslightingMessageForLineContent(trimmed)
|
local message = getGaslightingMessageForLineContent(trimmed)
|
||||||
if message then
|
if message then
|
||||||
local first_non_whitespace = line:find("%S")
|
local first_non_whitespace = line:find("%S")
|
||||||
|
|
@ -188,6 +195,7 @@ function M.update_decorations()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Debounced update function
|
--- Debounced update function
|
||||||
function M.schedule_update()
|
function M.schedule_update()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue