diff --git a/lib/ace/mode/folding/xml.js b/lib/ace/mode/folding/xml.js index 5e8e4b9a..3e69ddfa 100644 --- a/lib/ace/mode/folding/xml.js +++ b/lib/ace/mode/folding/xml.js @@ -3,7 +3,7 @@ * * Copyright (c) 2010, Ajax.org B.V. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright @@ -14,7 +14,7 @@ * * Neither the name of Ajax.org B.V. nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -113,7 +113,7 @@ oop.inherits(FoldMode, BaseFoldMode); }; } value += token.value; - if (value.indexOf(">") !== -1) { + if (token.type.slice(-4) === ".end") { var tag = this._parseTag(value); tag.start = start; tag.end = { @@ -195,7 +195,7 @@ oop.inherits(FoldMode, BaseFoldMode); var iterator = new TokenIterator(session, row, firstTag.column); var start = { row: row, - column: firstTag.column + firstTag.tagName.length + 2 + column: firstTag.column + firstTag.match.length }; while (tag = this._readTagForward(iterator)) { if (tag.selfClosing) { @@ -209,8 +209,9 @@ oop.inherits(FoldMode, BaseFoldMode); if (tag.closing) { this._pop(stack, tag); - if (stack.length == 0) + if (!stack.length) return Range.fromPoints(start, tag.start); + } else { stack.push(tag) @@ -236,9 +237,12 @@ oop.inherits(FoldMode, BaseFoldMode); if (!tag.closing) { this._pop(stack, tag); - if (stack.length == 0) { - tag.start.column += tag.tagName.length + 2; - return Range.fromPoints(tag.start, end); + if (!stack.length) { + if (tag.start.row != tag.end.row) { + tag.end = tag.start; + tag.end.column += session.getLine(tag.end.row).length; + } + return Range.fromPoints(tag.end, end); } } else { @@ -246,9 +250,9 @@ oop.inherits(FoldMode, BaseFoldMode); } } } - + }; -}).call(FoldMode.prototype); + }).call(FoldMode.prototype); });