Skip to content

fix: correct indent calculation for shiftwidth=0#116

Open
xlucn wants to merge 1 commit intozbirenbaum:masterfrom
xlucn:master
Open

fix: correct indent calculation for shiftwidth=0#116
xlucn wants to merge 1 commit intozbirenbaum:masterfrom
xlucn:master

Conversation

@xlucn
Copy link
Copy Markdown

@xlucn xlucn commented Aug 28, 2024

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.

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.
zhimsel added a commit to zhimsel/dotfiles that referenced this pull request Sep 3, 2024
This should be reverted when
zbirenbaum/copilot-cmp#116 is merged
@zhimsel
Copy link
Copy Markdown

zhimsel commented Sep 3, 2024

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

Thanks @xlucn!

@zhimsel
Copy link
Copy Markdown

zhimsel commented Nov 22, 2024

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

@sybereal
Copy link
Copy Markdown

sybereal commented Jul 7, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants