Skip to content

Commit d5906e2

Browse files
srguiwizmarijnh
authored andcommitted
[xml-hint addon] Prevent extraneous quote
If typing attribute=" and by closetag it becomes attribute="" and user presses Ctrl-Space to autocomplete and the completion is "x" then by this fix instead of obnoxious attribute="x"" it becomes nice attribute="x".
1 parent 042d981 commit d5906e2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

addon/hint/xml-hint.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@
9292
quote = token.string.charAt(len - 1);
9393
prefix = token.string.substr(n, len - 2);
9494
}
95+
if (n) { // an opening quote
96+
var line = cm.getLine(cur.line);
97+
if (line.length > token.end && line.charAt(token.end) == quote) token.end++; // include a closing quote
98+
}
9599
replaceToken = true;
96100
}
97101
for (var i = 0; i < atValues.length; ++i) if (!prefix || matches(atValues[i], prefix, matchInMiddle))

0 commit comments

Comments
 (0)