From dec3d8215dfa5d1ffd3a7d1d06559290db3cffcf Mon Sep 17 00:00:00 2001 From: Artem Krinitsyn Date: Sun, 26 Jul 2026 13:24:39 +0300 Subject: fix(text): indent() ignores `expandtab` when indent unchanged #40932 Problem: After expanding tabs with the `expandtab` option, if the old indent matches the requested one, `vim.text.indent()` returns the input unchanged. The optimization path assumes that if old_indent == size, the input wouldn't be changed, which is not correct when old_indent is formed by expanded tabs. Solution: Apply the optimization only when `expandtab` is not set. --- runtime/lua/vim/text.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/text.lua b/runtime/lua/vim/text.lua index ba038bacf8..3bdb058e30 100644 --- a/runtime/lua/vim/text.lua +++ b/runtime/lua/vim/text.lua @@ -190,7 +190,7 @@ function M.indent(size, text, opts) old_indent = old_indent or 0 prefix = prefix and prefix or ' ' - if old_indent == size then + if not opts.expandtab and old_indent == size then -- Optimization: if the indent is the same, return the text unchanged. return text, old_indent end -- cgit