mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
fix(treesitter): don't memoize modified headings (#33186)
Problem: repeated gO in markdown etc. adds extra toc indentation
Solution: don't memoize heading table which gets modified
(cherry picked from commit 28eaec5e15
)
This commit is contained in:
committed by
github-actions[bot]
parent
7e884b78bf
commit
70f3e15298
@ -40,10 +40,6 @@ local heading_queries = {
|
||||
]],
|
||||
}
|
||||
|
||||
local function hash_tick(bufnr)
|
||||
return tostring(vim.b[bufnr].changedtick)
|
||||
end
|
||||
|
||||
---@class TS.Heading
|
||||
---@field bufnr integer
|
||||
---@field lnum integer
|
||||
@ -53,7 +49,7 @@ end
|
||||
--- Extract headings from buffer
|
||||
--- @param bufnr integer buffer to extract headings from
|
||||
--- @return TS.Heading[]
|
||||
local get_headings = vim.func._memoize(hash_tick, function(bufnr)
|
||||
local get_headings = function(bufnr)
|
||||
local lang = ts.language.get_lang(vim.bo[bufnr].filetype)
|
||||
if not lang then
|
||||
return {}
|
||||
@ -85,7 +81,7 @@ local get_headings = vim.func._memoize(hash_tick, function(bufnr)
|
||||
end
|
||||
end
|
||||
return headings
|
||||
end)
|
||||
end
|
||||
|
||||
--- Shows an Outline (table of contents) of the current buffer, in the loclist.
|
||||
function M.show_toc()
|
||||
|
Reference in New Issue
Block a user