Skip to content

Commit fd98935

Browse files
committed
more fixes (#432)
also I'm removing all the template string indentation, will leave it as a comment if someone can justify actually changing a string
1 parent dc11766 commit fd98935

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

indent/javascript.vim

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,11 @@ function s:IndentWithContinuation(lnum, ind, width)
291291
if s:Match(lnum, s:continuation_regex)
292292
if lnum == p_lnum
293293
return msl_ind + a:width
294-
else
294+
elseif !s:InMultiVarStatement(a:lnum)
295295
return msl_ind
296-
endif
296+
else
297+
return msl_ind - a:width
298+
end
297299
endif
298300

299301
return a:ind
@@ -401,8 +403,12 @@ function GetJavascriptIndent()
401403
" If the line is comma first, dedent 1 level
402404
if (getline(prevline) =~ s:comma_first)
403405
return indent(prevline) - s:sw()
404-
elseif getline(s:PrevNonBlankNonString(prevline - 1)) =~ '[])}]' . s:comma_last && getline(prevline) !~ s:comma_last && getline(prevline) !~ s:block_regex
405-
return indent(prevline) - s:sw()
406+
elseif getline(s:PrevNonBlankNonString(prevline - 1)) =~ '[])}]' . s:comma_last && getline(prevline) !~ s:block_regex
407+
if getline(prevline) !~ s:comma_last
408+
return indent(prevline) - s:sw()
409+
else
410+
return indent(prevline)
411+
end
406412
end
407413

408414
" If line starts with an operator...
@@ -447,13 +453,13 @@ function GetJavascriptIndent()
447453
end
448454
end
449455

450-
if getline(prevline) =~ '^\s*`$' && s:IsInTempl(v:lnum, 1)
451-
if line !~ '^\s*`$'
452-
return indent(prevline) + s:sw()
453-
endif
454-
elseif line =~ '^\s*`$' && s:IsInTempl(prevline, 1)
455-
return indent(prevline) - s:sw()
456-
endif
456+
" if getline(prevline) =~ '^\s*`$' && s:IsInTempl(v:lnum, 1)
457+
" if line !~ '^\s*`$'
458+
" return indent(prevline) + s:sw()
459+
" endif
460+
" elseif line =~ '^\s*`$' && s:IsInTempl(prevline, 1)
461+
" return indent(prevline) - s:sw()
462+
" endif
457463

458464
" Check for multiple var assignments
459465
" let var_indent = s:GetVarIndent(v:lnum)

0 commit comments

Comments
 (0)