copilot-cmp
copilot-cmp copied to clipboard
fix: correct indent calculation for shiftwidth=0
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.
Just tested this PR with shiftwidth=0 and it works as expected. The indentation is no longer removed.
Thanks @xlucn!
@zbirenbaum any chance of this getting merged any time soon?
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.