You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this bug happen when you install plugin without vim-polyglot?
No
Describe the bug:
vim-polyglot autoindent only checks the first 32 lines of the file when guessing. In php files with a large number of include statements, there is typically no indentation information available in the first 32 lines. This means that the autoindent plugin will fail to produce the correct results for php files based solely on the number of includes in the file. For example, a file with a small number of includes ends up with shiftwidth=4, while another file ends up with shiftwidth=2 even though they are in the same project. I think the guess should traverse the entire file until it finds the first line with a leading space, instead of terminating early after only 32 lines. The number of lines to traverse when guessing could be configurable, if performance is a concern, but it should be quite fast to find the first line containing line[0] == " ".
To Reproduce:
Create any two php files, one of which has at least 32 lines of non-indented top-level statements.
The text was updated successfully, but these errors were encountered:
Thanks for the fix. Wouldn't it be simpler and more efficient just to call getline(1,1024) from the start? That way it doesn't need to check the same initial 32 lines a second time.
https://github.com/sheerun/vim-polyglot/blob/master/ftdetect/polyglot.vim#L2609
Does this bug happen when you install plugin without vim-polyglot?
No
Describe the bug:
vim-polyglot autoindent only checks the first 32 lines of the file when guessing. In php files with a large number of include statements, there is typically no indentation information available in the first 32 lines. This means that the autoindent plugin will fail to produce the correct results for php files based solely on the number of includes in the file. For example, a file with a small number of includes ends up with
shiftwidth=4
, while another file ends up withshiftwidth=2
even though they are in the same project. I think the guess should traverse the entire file until it finds the first line with a leading space, instead of terminating early after only 32 lines. The number of lines to traverse when guessing could be configurable, if performance is a concern, but it should be quite fast to find the first line containingline[0] == " "
.To Reproduce:
Create any two php files, one of which has at least 32 lines of non-indented top-level statements.
The text was updated successfully, but these errors were encountered: