do not include tag attributes in the fold

This commit is contained in:
nightwing 2013-05-02 00:28:37 +04:00
commit 10a759feb7

View file

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