Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"git-commit" language ignores indent setting in languages.toml #12783

Open
m4rch3n1ng opened this issue Feb 5, 2025 · 5 comments
Open

"git-commit" language ignores indent setting in languages.toml #12783

m4rch3n1ng opened this issue Feb 5, 2025 · 5 comments

Comments

@m4rch3n1ng
Copy link

m4rch3n1ng commented Feb 5, 2025

my languages.toml looks like this:

[[language]]
name = "git-commit"
indent = { tab-width = 4, unit = "\t" }

but when i want to edit a git commit message (via e.g. git -c core.editor=helix commit --amend) it still uses 1 space indentation (pressing tab inserts one space, and :indent-style returns "1 space")

it is very possible that i a doing something wrong, but currently the only way i have found to fix that is by manually setting :indent-style t 4 every time i want to edit a git commit message.

@m4rch3n1ng m4rch3n1ng changed the title git-commit "git-commit" language ignores indent setting in languages.toml Feb 5, 2025
@AlexanderBrevig
Copy link
Contributor

AlexanderBrevig commented Feb 6, 2025

Unable to reproduce (tab works with OP languages.toml).
I am on b0e1eaf.

@m4rch3n1ng
Copy link
Author

i think i found the underlying issue: i use git commit --verbose (with that i still can't get it to reproduce on the helix repository, i think because it uses spaces), but i can consistently reproduce it both with a build from master and the current release:

$ git clone https://github.com/m4rch3n1ng/mayland # or any other rust repository that uses tabs
$ cd mayland
$ git -c core.editor=helix commit --amend --verbose

@AlexanderBrevig
Copy link
Contributor

AlexanderBrevig commented Feb 6, 2025

With --verbose I can reproduce the error with that mayland repo.

@the-mikedavis
Copy link
Member

We auto-detect the indentation of a file and this sometimes produces bad interpretations, also see #9556

Aside from short files we should probably also try to ignore comments in the calculation, and treat the part after the scissors in the commit message as a sort of block comment

@AlexanderBrevig
Copy link
Contributor

I had a go in #12810. It effectively skews the indent heuristic to only prefer guessing if the amount of indent of a type exceeds the amount of lines with no indents at all.

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

No branches or pull requests

3 participants