Keep popping scopes until we find a matching start scope tag

This commit is contained in:
Nathan Sobo
2015-07-17 11:06:41 -07:00
parent b24258056d
commit f254c46a62

View File

@@ -394,20 +394,21 @@ class TokenizedBuffer extends Model
if (tag % 2) is -1
scopes.push(tag)
else
expectedScope = tag + 1
poppedScope = scopes.pop()
unless poppedScope is expectedScope
error = new Error("Encountered an invalid scope end id. Popped #{poppedScope}, expected to pop #{expectedScope}.")
error.metadata = {
grammarScopeName: @grammar.scopeName
}
path = require 'path'
error.privateMetadataDescription = "The contents of `#{path.basename(@buffer.getPath())}`"
error.privateMetadata = {
filePath: @buffer.getPath()
fileContents: @buffer.getText()
}
throw error
matchingStartTag = tag + 1
loop
break if scopes.pop() is matchingStartTag
if scopes.length is 0
atom.assert false, "Encountered an unmatched scope end tag.", (error) =>
error.metadata = {
grammarScopeName: @grammar.scopeName
unmatchedEndTag: @grammar.scopeForId(tag)
}
path = require 'path'
error.privateMetadataDescription = "The contents of `#{path.basename(@buffer.getPath())}`"
error.privateMetadata = {
filePath: @buffer.getPath()
fileContents: @buffer.getText()
}
scopes
indentLevelForRow: (bufferRow) ->