You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
1006 B

5 months ago
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/5/LICENSE
  3. (function(mod) {
  4. if (typeof exports == "object" && typeof module == "object") // CommonJS
  5. mod(require("../../lib/codemirror"));
  6. else if (typeof define == "function" && define.amd) // AMD
  7. define(["../../lib/codemirror"], mod);
  8. else // Plain browser env
  9. mod(CodeMirror);
  10. })(function(CodeMirror) {
  11. CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) {
  12. if (prev == CodeMirror.Init) prev = false;
  13. if (prev && !val)
  14. cm.removeOverlay("trailingspace");
  15. else if (!prev && val)
  16. cm.addOverlay({
  17. token: function(stream) {
  18. for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {}
  19. if (i > stream.pos) { stream.pos = i; return null; }
  20. stream.pos = l;
  21. return "trailingspace";
  22. },
  23. name: "trailingspace"
  24. });
  25. });
  26. });