Test for number of parens
This commit is contained in:
parent
938a9d22ec
commit
3093a74d57
@ -46,6 +46,10 @@ function Commander (ronin) {
|
||||
this.reindent = function () {
|
||||
let val = this._input.value.replace(/\n/g, '').replace(/ +(?= )/g, '').replace(/\( \(/g, '((').replace(/\) \)/g, '))').trim()
|
||||
let depth = 0
|
||||
if (val.split('(').length !== val.split(')').length) {
|
||||
ronin.log('Uneven number of parens.')
|
||||
return
|
||||
}
|
||||
for (let i = 0; i < val.length; i++) {
|
||||
const c = val.charAt(i)
|
||||
if (c === '(') { depth++ } else if (c === ')') { depth-- }
|
||||
|
Loading…
x
Reference in New Issue
Block a user