Skip to content

Commit 90819c5

Browse files
pe4ceymarijnh
authored andcommitted
[cypher mode] Highlight empty string literals correctly
1 parent 0a90aa4 commit 90819c5

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

mode/cypher/cypher.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
CodeMirror.defineMode("cypher", function(config) {
2121
var tokenBase = function(stream/*, state*/) {
2222
var ch = stream.next();
23-
if (ch === "\"") {
24-
stream.match(/.+?["]/);
23+
if (ch ==='"') {
24+
stream.match(/.*?"/);
2525
return "string";
2626
}
2727
if (ch === "'") {
28-
stream.match(/.+?[']/);
28+
stream.match(/.*?'/);
2929
return "string";
3030
}
3131
if (/[{}\(\),\.;\[\]]/.test(ch)) {

mode/cypher/test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,22 @@
1616

1717
MT("singleQuotedString",
1818
"[string 'a'][variable b]");
19+
20+
MT("single attribute (with content)",
21+
"[node {][atom a:][string 'a'][node }]");
22+
23+
MT("multiple attribute, singleQuotedString (with content)",
24+
"[node {][atom a:][string 'a'][node ,][atom b:][string 'b'][node }]");
25+
26+
MT("multiple attribute, doubleQuotedString (with content)",
27+
"[node {][atom a:][string \"a\"][node ,][atom b:][string \"b\"][node }]");
28+
29+
MT("single attribute (without content)",
30+
"[node {][atom a:][string 'a'][node }]");
31+
32+
MT("multiple attribute, singleQuotedString (without content)",
33+
"[node {][atom a:][string ''][node ,][atom b:][string ''][node }]");
34+
35+
MT("multiple attribute, doubleQuotedString (without content)",
36+
"[node {][atom a:][string \"\"][node ,][atom b:][string \"\"][node }]");
1937
})();

0 commit comments

Comments
 (0)