f6bb02645dd4b333a52e7b4308e35da4c4af1924
[myslice.git] / third-party / codemirror-3.15 / addon / edit / trailingspace.js
1 CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) {
2   if (prev == CodeMirror.Init) prev = false;
3   if (prev && !val)
4     cm.removeOverlay("trailingspace");
5   else if (!prev && val)
6     cm.addOverlay({
7       token: function(stream) {
8         for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {}
9         if (i > stream.pos) { stream.pos = i; return null; }
10         stream.pos = l;
11         return "trailingspace";
12       },
13       name: "trailingspace"
14     });
15 });