Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lua/orgmode/org/indent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,13 @@ local function indentexpr(linenr, bufnr)
query = query or vim.treesitter.query.get('org', 'org_indent')

bufnr = bufnr or vim.api.nvim_get_current_buf()

-- The buffer might be invalid, which can happen, if the function is implicitly called through
-- refile operations. In this case we fallback to autoindent.
if bufnr == -1 or not vim.api.nvim_buf_is_valid(bufnr) then
return -1
end

local indentexpr_cache = buf_indentexpr_cache[bufnr] or { prev_linenr = -1 }
if indentexpr_cache.prev_linenr ~= linenr - 1 or not mode:lower():find('n') then
indentexpr_cache.matches = get_matches(bufnr)
Expand Down
Loading