copilot-cmp icon indicating copy to clipboard operation
copilot-cmp copied to clipboard

fix: correct indent calculation for shiftwidth=0

Open xlucn opened this issue 1 year ago • 2 comments

Addressing some cases in #45. Fixed the logic for calculating indentation in format.lua. Previously in the case of shiftwidth=0, the indent was not using the value of tabstop, leading to incorrect indentation.

xlucn avatar Aug 28 '24 05:08 xlucn

Just tested this PR with shiftwidth=0 and it works as expected. The indentation is no longer removed.

Thanks @xlucn!

zhimsel avatar Sep 03 '24 14:09 zhimsel

@zbirenbaum any chance of this getting merged any time soon?

zhimsel avatar Nov 22 '24 15:11 zhimsel

The help says to "use the shiftwidth() function to get the effective shiftwidth value." Therefore, wouldn't it be easier to simply replace the reference to vim.o.shiftwidth with vim.fn.shiftwidth() and avoid reimplementing the fallback logic? That should hopefully also avoid any edge cases in case the behavior subtly changes in the future and new edge cases are introduced.

sybereal avatar Jul 07 '25 12:07 sybereal