browser/devtools/sourceeditor/codemirror/trailingspace.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:044a92602da1
1 (function(mod) {
2 if (typeof exports == "object" && typeof module == "object") // CommonJS
3 mod(require("../../lib/codemirror"));
4 else if (typeof define == "function" && define.amd) // AMD
5 define(["../../lib/codemirror"], mod);
6 else // Plain browser env
7 mod(CodeMirror);
8 })(function(CodeMirror) {
9 CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) {
10 if (prev == CodeMirror.Init) prev = false;
11 if (prev && !val)
12 cm.removeOverlay("trailingspace");
13 else if (!prev && val)
14 cm.addOverlay({
15 token: function(stream) {
16 for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {}
17 if (i > stream.pos) { stream.pos = i; return null; }
18 stream.pos = l;
19 return "trailingspace";
20 },
21 name: "trailingspace"
22 });
23 });
24 });

mercurial