We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fafb8f1 commit 1d8c9b9Copy full SHA for 1d8c9b9
lua/orgmode/org/indent.lua
@@ -246,6 +246,13 @@ local function indentexpr(linenr, bufnr)
246
query = query or vim.treesitter.query.get('org', 'org_indent')
247
248
bufnr = bufnr or vim.api.nvim_get_current_buf()
249
+
250
+ -- The buffer might be invalid, which can happen, if the function is implicitly called through
251
+ -- refile operations. In this case we fallback to autoindent.
252
+ if bufnr == -1 or not vim.api.nvim_buf_is_valid(bufnr) then
253
+ return -1
254
+ end
255
256
local indentexpr_cache = buf_indentexpr_cache[bufnr] or { prev_linenr = -1 }
257
if indentexpr_cache.prev_linenr ~= linenr - 1 or not mode:lower():find('n') then
258
indentexpr_cache.matches = get_matches(bufnr)
0 commit comments