move a few things away in to-be-integrated/
[myslice.git] / to-be-integrated / third-party / codemirror-3.15 / addon / edit / trailingspace.js
diff --git a/to-be-integrated/third-party/codemirror-3.15/addon/edit/trailingspace.js b/to-be-integrated/third-party/codemirror-3.15/addon/edit/trailingspace.js
new file mode 100644 (file)
index 0000000..f6bb026
--- /dev/null
@@ -0,0 +1,15 @@
+CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) {
+  if (prev == CodeMirror.Init) prev = false;
+  if (prev && !val)
+    cm.removeOverlay("trailingspace");
+  else if (!prev && val)
+    cm.addOverlay({
+      token: function(stream) {
+        for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {}
+        if (i > stream.pos) { stream.pos = i; return null; }
+        stream.pos = l;
+        return "trailingspace";
+      },
+      name: "trailingspace"
+    });
+});