Bug 1355233 - quote unmatched open paren in function tokens correctly; r=gl

When rewriting in the rule view, the rewriter quotes unmatched open
parens to avoid some edits affecting the rest of the style sheet.  This
was bug 1321970.  However, that change didn't correctly handle the case
of a function token, where the paren in question appears at the end, not
the start, of the token.

MozReview-Commit-ID: GjA40M2KsvX
This commit is contained in:
Tom Tromey
2017-04-17 08:00:58 -06:00
parent 2254360dc9
commit 7351af74b9
2 changed files with 15 additions and 3 deletions

View File

@@ -616,9 +616,12 @@ RuleRewriter.prototype = {
// Push a closing paren on the stack.
let pushParen = (token, closer) => {
result += text.substring(previousOffset, token.startOffset);
parenStack.push({closer, offset: result.length});
result += text.substring(token.startOffset, token.endOffset);
result = result + text.substring(previousOffset, token.startOffset) +
text.substring(token.startOffset, token.endOffset);
// We set the location of the paren in a funny way, to handle
// the case where we've seen a function token, where the paren
// appears at the end.
parenStack.push({closer, offset: result.length - 1});
previousOffset = token.endOffset;
};