-
Notifications
You must be signed in to change notification settings - Fork 352
Incorrect indentation following single-line comments #493
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
Comments
try the newest dev update |
Just tried; all the aforementioned bugs are still present. |
i can't reproduce any of these |
I just tested with
I'm trying to track down what combination of settings and/or plugins is causing the behavior; I'll post back as soon as I figure it out. |
Actually, I'm seeing it pretty reliably now with Here's what I'm doing after starting with
set runtimepath=/path-to-javascript-plugin,/other-standard-runtime-paths-except-home-dir-ones
runtime! filetype.vim
runtime! ftplugin.vim
runtime! indent.vim
runtime! syntax/syntax.vim
runtime! plugin/**/*.vim
|
try and comment out this line https://github.com/pangloss/vim-javascript/blob/master/indent/javascript.vim#L19 |
The |
maybe the line above:formatexpr? I'm not able to test now |
Found the problem: " indent/javascript.vim 413:419
" If the line is empty and the previous nonblank line was a multi-line
" comment, use that comment's indent. Deduct one char to account for the
" space in ' */'.
if line =~ '^\s*$' && getline(prevline) !~ '\%(\%(^\s*\/\/\|\/\*\).*\)\@<!\*\/' &&
\ s:IsInComment(prevline, 1)
return indent(prevline) - 1
endif That's erroneously deleting a character from the indentation in the case of a preceding single-line ( |
Changing the above code to the following always does the right thing for me now: " If the line is empty and the previous nonblank line was a comment, use
" that comment's indent.
if line =~ '^\s*$' && s:IsInComment(prevline, 1)
return indent(prevline)
endif I'm not sure what the "deduct one char" bit was trying to do; I'd expect a line following the close of a multi-line comment to indent to the start of the preceding |
i would wait to make a pr, my guess is something else is going on. also, i believe deducting a char is necessary when starting a new line after a multiline comment |
maybe it will work with the above? my mistake if so for the incorrect condition |
give develop another try |
Just chiming in to let you guys know I came across this problem earlier today, and updating to the latest develop fixed the issue for me. |
Closing this because I believe it has been fixed in |
Almost everything looks right now; thanks! There's still one case with single-line comments I'm seeing an issue with: call(
// existing comment 1
// opening a new line here indents to here
// existing comment 2
) |
what settings do you use? does this happen while typing or after |
I see now, this is an issue with the syntax: @amadeus
the third line at col 1, is incorrectly being highlighted (though there are no characters to show it) as a comment |
@bounceme not sure I follow. If I type this out like you have above, I get: |
here is the only way i can reproduce, first install https://github.com/tpope/vim-scriptease
on the third line press |
Still can't reproduce. I don't use scriptease, but I have something similar for getting syntax highlighting state:
I get the scenario you mentioned, where if I press |
what echoes when I use your function is |
this then uses c-indent, try removing this paragraph(edit not on master but dev): |
@bounceme what version of Vim/MacVim do you have? I've seen this sorta thing before, although usually if you type something or wait a second, it fixes itself. |
vim 7.4.1941 |
I can do something to fix the indenting at least, if this is just a general syntax problem |
All the |
that'd be great! thanks |
@bounceme with what I just merged into |
yes, this troublesome issue is gone haha |
On both
master
anddevelop
, a line following a single-line comment is incorrectly indented:But indentation between single-line comments is (usually) fine:
But even those seem to break if your last action was deleting a line
between
// comment 1
and// comment 2
.Calls seem a bit wonky:
And everything behaves differently if there's a non-comment line above the comments:
The text was updated successfully, but these errors were encountered: