aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKåre Särs <kare.sars@iki.fi>2014-01-20 11:48:27 (GMT)
committerKåre Särs <kare.sars@iki.fi>2014-01-20 11:56:38 (GMT)
commit18ace497e8dfc44f0fdd860a710767379ac3a72c (patch)
tree8e320a3c8501518394512715b1d67d24c07bbc43
parentbc9a9eb4c90db24d7d0a3b5b5ccc009bd7a86713 (diff)
Fix indentation when an opening bracket is not in code
-rw-r--r--part/script/data/indentation/cstyle.js4
-rw-r--r--tests/data/indent/cstyle/brace2/expected5
-rw-r--r--tests/data/indent/cstyle/brace2/input.js2
-rw-r--r--tests/data/indent/cstyle/brace2/origin5
4 files changed, 15 insertions, 1 deletions
diff --git a/part/script/data/indentation/cstyle.js b/part/script/data/indentation/cstyle.js
index e23d09d..64e1ea7 100644
--- a/part/script/data/indentation/cstyle.js
+++ b/part/script/data/indentation/cstyle.js
@@ -387,7 +387,9 @@ function tryBrace(line)
var currentString = document.line(currentLine);
- if (currentString.search(/\{[^\}]*$/) != -1) {
+ var matchColumn = currentString.search(/\{[^\}]*$/);
+
+ if (matchColumn != -1 && document.isCode(currentLine, matchColumn)) {
dbg("tryBrace: Closing bracket in line " + currentLine);
var cursor = tryParenthesisBeforeBrace(currentLine, lastPos);
if (cursor.isValid()) {
diff --git a/tests/data/indent/cstyle/brace2/expected b/tests/data/indent/cstyle/brace2/expected
new file mode 100644
index 0000000..31092b4
--- /dev/null
+++ b/tests/data/indent/cstyle/brace2/expected
@@ -0,0 +1,5 @@
+int main(void)
+{
+ printf("{\n");
+ return 0;
+}
diff --git a/tests/data/indent/cstyle/brace2/input.js b/tests/data/indent/cstyle/brace2/input.js
new file mode 100644
index 0000000..94b6b53
--- /dev/null
+++ b/tests/data/indent/cstyle/brace2/input.js
@@ -0,0 +1,2 @@
+v.setCursorPosition(3,0);
+d.align(new Range(new Cursor(3, 0), new Cursor(3, 0))); \ No newline at end of file
diff --git a/tests/data/indent/cstyle/brace2/origin b/tests/data/indent/cstyle/brace2/origin
new file mode 100644
index 0000000..62c33c6
--- /dev/null
+++ b/tests/data/indent/cstyle/brace2/origin
@@ -0,0 +1,5 @@
+int main(void)
+{
+ printf("{\n");
+ return 0;
+}