aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua
diff options
context:
space:
mode:
authorTan, Long <tanloong@foxmail.com>2025-03-31 17:22:57 +0800
committerGitHub <noreply@github.com>2025-03-31 11:22:57 +0200
commit28eaec5e1526b2a004eadeadf6246df75cfa08e8 (patch)
tree39e32ac9baa808f4fb8046f1c6c4b42b5fa4caa6 /runtime/lua
parentee143aaf65a0e662c42c636aa4a959682858b3e7 (diff)
downloadrneovim-28eaec5e1526b2a004eadeadf6246df75cfa08e8.tar.gz
rneovim-28eaec5e1526b2a004eadeadf6246df75cfa08e8.tar.bz2
rneovim-28eaec5e1526b2a004eadeadf6246df75cfa08e8.zip
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
Diffstat (limited to 'runtime/lua')
-rw-r--r--runtime/lua/vim/treesitter/_headings.lua8
1 files changed, 2 insertions, 6 deletions
diff --git a/runtime/lua/vim/treesitter/_headings.lua b/runtime/lua/vim/treesitter/_headings.lua
index 885d014a89..bfa468ad88 100644
--- a/runtime/lua/vim/treesitter/_headings.lua
+++ b/runtime/lua/vim/treesitter/_headings.lua
@@ -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()