-
Notifications
You must be signed in to change notification settings - Fork 6
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
Sets sw=1, ts=1 when file uses tabs #18
Comments
Thanks for the bug report. In a local branch, I added the file you linked as a test case, and can reproduce the problem. Desired behaviorI think the desired behavior for The cause of the bugTo determine where the code is going wrong, I checked the output of
That output shows that the file actually does not use only tabs for indentation. (I think DetectIndent already handles files with only tabbed indentation correctly, leaving my $i;
my @prefixes = find_unique_prefixes(@stuff) unless $opts->{LIST_ONLY};
TOPLOOP: # <------
while (1) {
my $last_lf = 0; The algorithm wrongly guesses that since two of the lines in the file start with 6 spaces, and two lines start with 11 spaces, the desired visual indent size should be the greatest common denominator of 6 and 11, which is 1. How to fix the bugI’m still thinking of the best heuristic for fixing this. In this particular file it seems the indentation of the four space-indented lines should be ignored because they are more properly thought of as using spaces for alignment, not spaces for indentation. But what’s the best heuristic for handling a mix of space-indented lines and tab-indented lines in general? In files where 10% of lines are indented with spaces, the sizes of those indents currently affect the displayed tabstop size, but I think they shouldn’t. However, I think that space-indented lines that consist of 49% of indented lines still should affect the tabstop size. What should the cutoff be? There should probably also be a minimum absolute number of space-indented lines for space-indented lines to be taken into account. |
Good questions without definite answers. Perhaps they could be used
configurable?
|
Here's the file:
https://raw.githubusercontent.com/git/git/master/git-add--interactive.perl
I was expecting sw=4, ts=4 (preferred) or sw=8, ts=8.
Perhaps a user-settable variable to allow a person do define 2, 4, or 8 spaces as default if there are only TABs?
The text was updated successfully, but these errors were encountered: