fix #1790
This commit is contained in:
parent
bf971abc7f
commit
b99527a349
|
@ -53,7 +53,7 @@ module.exports = (str, indent, warn_fn, opts = {}) ->
|
||||||
else
|
else
|
||||||
return line
|
return line
|
||||||
res1 = line.match(/\[(=*)\[/)
|
res1 = line.match(/\[(=*)\[/)
|
||||||
if res1
|
if res1 and (not new RegExp("\\]#{'='.repeat res1[1].length}\\]").test line)
|
||||||
$template = res1[1].length + 1
|
$template = res1[1].length + 1
|
||||||
if !$template_flag
|
if !$template_flag
|
||||||
line = line.trim()
|
line = line.trim()
|
||||||
|
@ -62,9 +62,9 @@ module.exports = (str, indent, warn_fn, opts = {}) ->
|
||||||
if !line.length
|
if !line.length
|
||||||
return ''
|
return ''
|
||||||
raw_line = line
|
raw_line = line
|
||||||
line = line.replace(/(['"])[^\1]*?\1/, '')
|
line = line.replace(/(['"])[^\1]*?\1/g, '')
|
||||||
# remove all quoted fragments for proper bracket processing
|
# remove all quoted fragments for proper bracket processing
|
||||||
line = line.replace(/\s*--.+/, '')
|
line = line.replace(/\s*--.+$/, '')
|
||||||
# remove all comments; this ignores long bracket style comments
|
# remove all comments; this ignores long bracket style comments
|
||||||
if /^((local )?function|repeat|while)\b/.test(line) and !/\bend\s*[\),;]*$/.test(line) or /\b(then|do)$/.test(line) and !/^elseif\b/.test(line) or /^if\b/.test(line) and /\bthen\b/.test(line) and !/\bend$/.test(line) or /\bfunction ?(?:\w+ )?\([^\)]*\)$/.test(line) and !/\bend$/.test(line)
|
if /^((local )?function|repeat|while)\b/.test(line) and !/\bend\s*[\),;]*$/.test(line) or /\b(then|do)$/.test(line) and !/^elseif\b/.test(line) or /^if\b/.test(line) and /\bthen\b/.test(line) and !/\bend$/.test(line) or /\bfunction ?(?:\w+ )?\([^\)]*\)$/.test(line) and !/\bend$/.test(line)
|
||||||
$nextIndent = $currIndent + 1
|
$nextIndent = $currIndent + 1
|
||||||
|
@ -102,4 +102,4 @@ module.exports = (str, indent, warn_fn, opts = {}) ->
|
||||||
new_line or undefined
|
new_line or undefined
|
||||||
|
|
||||||
warn_fn 'positive indentation at the end' if $currIndent > 0
|
warn_fn 'positive indentation at the end' if $currIndent > 0
|
||||||
new_code.join eol
|
new_code.join eol
|
Loading…
Reference in New Issue