summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKåre Särs <kare.sars@iki.fi>2014-01-20 00:00:42 (GMT)
committerKåre Särs <kare.sars@iki.fi>2014-01-20 00:05:31 (GMT)
commit98c6e9fd68966278e411a7891a04b5bc0b76fc0b (patch)
tree05029f72b2d428136b8768a555695e1bb7b930db
parent8037623d6b42ef52d2d664de7488fc074a919100 (diff)
Fix XML indentation after self-closing tags
BUG:330174 FIXED-IN: 3.12.2
-rw-r--r--part/script/data/indentation/xml.js8
-rw-r--r--tests/data/indent/xml/self_closing2/expected5
-rw-r--r--tests/data/indent/xml/self_closing2/input.js8
-rw-r--r--tests/data/indent/xml/self_closing2/origin5
4 files changed, 22 insertions, 4 deletions
diff --git a/part/script/data/indentation/xml.js b/part/script/data/indentation/xml.js
index 6761d5a..2a377da 100644
--- a/part/script/data/indentation/xml.js
+++ b/part/script/data/indentation/xml.js
@@ -70,14 +70,14 @@ function getCode(lineNr) {
if (document.isCode(lineNr, col))
code += line[col];
}
- code = removeSelfClosing(code);
+ code = replaceSelfClosing(code);
return code.trim();
}
// Return given code with all self-closing tags removed.
-function removeSelfClosing(code) {
- return code.replace(/<[^<>]*\/>/g, '');
+function replaceSelfClosing(code) {
+ return code.replace(/<[^<>]*\/>/g, '<tag></tag>');
}
@@ -105,7 +105,7 @@ function _calcAttributeIndent(lineNr, indentWidth) {
} while ((line.countMatches(open_tag) <= line.countMatches(close_tag)) &&
(lineNr > 0));
var prevIndent = Math.max(document.firstVirtualColumn(lineNr), 0);
- code = removeSelfClosing(code);
+ code = replaceSelfClosing(code);
var steps = calcSteps(code);
return prevIndent + indentWidth * steps;
}
diff --git a/tests/data/indent/xml/self_closing2/expected b/tests/data/indent/xml/self_closing2/expected
new file mode 100644
index 0000000..228d0b4
--- /dev/null
+++ b/tests/data/indent/xml/self_closing2/expected
@@ -0,0 +1,5 @@
+<tag1>
+ <tag2/>
+
+ <tag2/>
+</tag1>
diff --git a/tests/data/indent/xml/self_closing2/input.js b/tests/data/indent/xml/self_closing2/input.js
new file mode 100644
index 0000000..a756814
--- /dev/null
+++ b/tests/data/indent/xml/self_closing2/input.js
@@ -0,0 +1,8 @@
+v.setCursorPosition(0,0);
+v.selectAll();
+
+var r = v.selection();
+if( r.isValid() ) {
+ d.align( r );
+}
+
diff --git a/tests/data/indent/xml/self_closing2/origin b/tests/data/indent/xml/self_closing2/origin
new file mode 100644
index 0000000..228d0b4
--- /dev/null
+++ b/tests/data/indent/xml/self_closing2/origin
@@ -0,0 +1,5 @@
+<tag1>
+ <tag2/>
+
+ <tag2/>
+</tag1>