fix(scope): properly caluclate start indent when cursor=true for indent scopes. See #5068

This commit is contained in:
Folke Lemaitre 2024-12-15 12:21:52 +01:00
parent 7281912e92
commit e63fa7bf05
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -281,7 +281,9 @@ function IndentScope:find(opts)
end
if opts.cursor then
indent = math.min(indent, opts.pos[2] + 1)
local before = vim.fn.getline(opts.pos[1]):sub(1, opts.pos[2])
before = before:gsub("\t", (" "):rep(vim.bo[opts.buf].tabstop or 2))
indent = math.min(indent, vim.api.nvim_strwidth(before) + 1)
end
-- expand to include bigger indents