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. --- test/functional/lua/text_spec.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/functional/lua/text_spec.lua') diff --git a/test/functional/lua/text_spec.lua b/test/functional/lua/text_spec.lua index a4a41dc862..9e80f81bc5 100644 --- a/test/functional/lua/text_spec.lua +++ b/test/functional/lua/text_spec.lua @@ -47,6 +47,8 @@ describe('vim.text', function() { ' \n \nfoo\n\nbar\nbaz\n \n', 1 }, { vim.text.indent(0, ' \n \n foo\n\n bar\n baz\n \n') } ) + -- Tabs expand when old indent matches new indent #40932. + eq({ ' a', 2 }, { vim.text.indent(2, '\t a', { expandtab = 1 }) }) end) it('real-world cases', function() -- cgit