Misc #18891
closedExpand tabs in C code
Description
Problem¶
There's no way to handle tab/space-mixed indentation of CRuby's C code properly in VSCode. It impacts the productivity of the VSCode users a lot, including myself.
Suggested solutions¶
I implemented option 2 out of the following options at https://github.com/ruby/ruby/pull/6094.
- You tell me how to do that in VSCode.
- In VSCode, there seems to be no native feature to show tabs as 8 spaces while still indenting with 4 spaces. At least https://github.com/microsoft/vscode/issues/42740 is still open.
- @alanwu (Alan Wu) built https://github.com/XrXr/vscode-tabs-are-two-indents exactly for this purpose, but even with the extension, it still seems to wrongly detect an indentation level on new lines.
-
Expand all tabs in most of the C code at once and add the commit to
.git-blame-ignore-revs
- pros: GitHub and
git blame --ignore-revs-file
support it. Unlike option 3, commit logs and.git-blame-ignore-revs
can be short. - cons: It might be a bit difficult to find out which C files shouldn't be a target. Bare
git blame
could be inconvenient.
- pros: GitHub and
- Allow expanding all tabs in each C file as we want and manage the list of such commits in
.git-blame-ignore-revs
- pros: GitHub and
git blame --ignore-revs-file
support it. You don't introduce unnecessary changes to files you don't care about. - cons: We might see too many commits for this in the commit history. Bare
git blame
could be inconvenient for such files.
- pros: GitHub and
- Discourage contributions to CRuby from VSCode users. (proposed by @graywolf)
Drawbacks¶
The expected drawbacks of doing option 2 are:
- Existing patches on hard-tab lines may conflict.
- Backporting patches on hard-tab lines made after this commit to revisions before this commit may conflict.
I assume that resolving such conflicts wouldn't be too difficult and this problem will not last forever.
Out of scope¶
I'm not interested in discussing the adoption of clang-format. It would change a lot of things that are not related to the problem.
Past discussion¶
https://bugs.ruby-lang.org/issues/16112 touched this topic before, but we haven't discussed --ignore-revs-file
so much. I also didn't know VSCode still can't deal with it in 2022 (as I've been using Vim).