codemirror-rails 5.5 → 5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/lib/codemirror/rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/codemirror.js +54 -20
  4. data/vendor/assets/javascripts/codemirror/addons/display/autorefresh.js +47 -0
  5. data/vendor/assets/javascripts/codemirror/addons/edit/closetag.js +6 -3
  6. data/vendor/assets/javascripts/codemirror/addons/hint/anyword-hint.js +1 -1
  7. data/vendor/assets/javascripts/codemirror/addons/lint/html-lint.js +46 -0
  8. data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +8 -2
  9. data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +2 -2
  10. data/vendor/assets/javascripts/codemirror/addons/search/search.js +11 -0
  11. data/vendor/assets/javascripts/codemirror/addons/tern/tern.js +6 -5
  12. data/vendor/assets/javascripts/codemirror/modes/css.js +26 -10
  13. data/vendor/assets/javascripts/codemirror/modes/cypher.js +2 -2
  14. data/vendor/assets/javascripts/codemirror/modes/dockerfile.js +4 -1
  15. data/vendor/assets/javascripts/codemirror/modes/go.js +1 -1
  16. data/vendor/assets/javascripts/codemirror/modes/javascript.js +1 -6
  17. data/vendor/assets/javascripts/codemirror/modes/php.js +6 -5
  18. data/vendor/assets/javascripts/codemirror/modes/rust.js +39 -432
  19. data/vendor/assets/javascripts/codemirror/modes/stylus.js +10 -9
  20. data/vendor/assets/stylesheets/codemirror.css +12 -10
  21. data/vendor/assets/stylesheets/codemirror/themes/3024-day.css +20 -20
  22. data/vendor/assets/stylesheets/codemirror/themes/3024-night.css +20 -20
  23. data/vendor/assets/stylesheets/codemirror/themes/abcdef.css +32 -0
  24. data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +7 -9
  25. data/vendor/assets/stylesheets/codemirror/themes/base16-dark.css +24 -24
  26. data/vendor/assets/stylesheets/codemirror/themes/base16-light.css +24 -24
  27. data/vendor/assets/stylesheets/codemirror/themes/blackboard.css +5 -5
  28. data/vendor/assets/stylesheets/codemirror/themes/cobalt.css +4 -4
  29. data/vendor/assets/stylesheets/codemirror/themes/colorforth.css +3 -3
  30. data/vendor/assets/stylesheets/codemirror/themes/dracula.css +25 -71
  31. data/vendor/assets/stylesheets/codemirror/themes/eclipse.css +21 -21
  32. data/vendor/assets/stylesheets/codemirror/themes/elegant.css +12 -12
  33. data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +4 -4
  34. data/vendor/assets/stylesheets/codemirror/themes/icecoder.css +29 -29
  35. data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +14 -14
  36. data/vendor/assets/stylesheets/codemirror/themes/liquibyte.css +5 -5
  37. data/vendor/assets/stylesheets/codemirror/themes/material.css +28 -80
  38. data/vendor/assets/stylesheets/codemirror/themes/mbo.css +23 -23
  39. data/vendor/assets/stylesheets/codemirror/themes/mdn-like.css +6 -6
  40. data/vendor/assets/stylesheets/codemirror/themes/midnight.css +22 -24
  41. data/vendor/assets/stylesheets/codemirror/themes/monokai.css +21 -21
  42. data/vendor/assets/stylesheets/codemirror/themes/neat.css +3 -3
  43. data/vendor/assets/stylesheets/codemirror/themes/neo.css +7 -7
  44. data/vendor/assets/stylesheets/codemirror/themes/night.css +4 -4
  45. data/vendor/assets/stylesheets/codemirror/themes/paraiso-dark.css +24 -24
  46. data/vendor/assets/stylesheets/codemirror/themes/paraiso-light.css +24 -24
  47. data/vendor/assets/stylesheets/codemirror/themes/pastel-on-dark.css +3 -3
  48. data/vendor/assets/stylesheets/codemirror/themes/rubyblue.css +3 -3
  49. data/vendor/assets/stylesheets/codemirror/themes/seti.css +25 -69
  50. data/vendor/assets/stylesheets/codemirror/themes/solarized.css +7 -9
  51. data/vendor/assets/stylesheets/codemirror/themes/the-matrix.css +21 -21
  52. data/vendor/assets/stylesheets/codemirror/themes/tomorrow-night-bright.css +24 -24
  53. data/vendor/assets/stylesheets/codemirror/themes/tomorrow-night-eighties.css +24 -24
  54. data/vendor/assets/stylesheets/codemirror/themes/ttcn.css +45 -46
  55. data/vendor/assets/stylesheets/codemirror/themes/twilight.css +7 -7
  56. data/vendor/assets/stylesheets/codemirror/themes/vibrant-ink.css +9 -9
  57. data/vendor/assets/stylesheets/codemirror/themes/xq-dark.css +20 -20
  58. data/vendor/assets/stylesheets/codemirror/themes/xq-light.css +18 -18
  59. data/vendor/assets/stylesheets/codemirror/themes/yeti.css +24 -66
  60. data/vendor/assets/stylesheets/codemirror/themes/zenburn.css +3 -3
  61. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9653550a47590b85abbf8924efa06589e5e525ec
4
- data.tar.gz: 575475714f3369c55478f451f7af4d8cd06b87e3
3
+ metadata.gz: 95aed5d670b225a60a9b6fe42757c35fc4f2e57e
4
+ data.tar.gz: d016c556fb97792a9a7e5006c8b9e4e829cc8605
5
5
  SHA512:
6
- metadata.gz: fda74337e21a23dc3c55ff3ed93de8015234e7360b38b2c7b34136de561d6af0bb65c1c803bb0b4eab3f4ef50db6f1b144975bf31c0c8442125185f41789aea1
7
- data.tar.gz: ba3c3869dcee61b638ba6a5dfe37a1c1b09f3574e7faeac1148eac39bf53c0f2284ead29b6baf2550e4b5841d314446c3f866d53b81e20cf32428fcc8ac5bc70
6
+ metadata.gz: 3fb0a350ed05a56863602cd6b7a140c04357358d428f19b0579b101b12d335cbc76e1672768bdce2750a66f92bafb79d74720828361f1ebfb9cced0c72f77419
7
+ data.tar.gz: 5e7b240ff00353319fdb8e790ee58036ad32ddbd6f91b2e5de6b8cfb156dfbd053589fbd0da523a4d2037422029515701ffdb8d6a78754e01986b085f1926ebc
@@ -1,6 +1,6 @@
1
1
  module Codemirror
2
2
  module Rails
3
- VERSION = '5.5'
4
- CODEMIRROR_VERSION = '5.5'
3
+ VERSION = '5.6'
4
+ CODEMIRROR_VERSION = '5.6'
5
5
  end
6
6
  end
@@ -87,6 +87,7 @@
87
87
  focused: false,
88
88
  suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
89
89
  pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
90
+ selectingText: false,
90
91
  draggingText: false,
91
92
  highlight: new Delayed(), // stores highlight worker timeout
92
93
  keySeq: null, // Unfinished key sequence
@@ -1135,7 +1136,8 @@
1135
1136
  var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
1136
1137
  if (pasted) {
1137
1138
  e.preventDefault();
1138
- runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
1139
+ if (!isReadOnly(cm) && !cm.options.disableInput)
1140
+ runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
1139
1141
  return true;
1140
1142
  }
1141
1143
  }
@@ -2270,7 +2272,7 @@
2270
2272
  var range = doc.sel.ranges[i];
2271
2273
  var collapsed = range.empty();
2272
2274
  if (collapsed || cm.options.showCursorWhenSelecting)
2273
- drawSelectionCursor(cm, range, curFragment);
2275
+ drawSelectionCursor(cm, range.head, curFragment);
2274
2276
  if (!collapsed)
2275
2277
  drawSelectionRange(cm, range, selFragment);
2276
2278
  }
@@ -2278,8 +2280,8 @@
2278
2280
  }
2279
2281
 
2280
2282
  // Draws a cursor for the given range
2281
- function drawSelectionCursor(cm, range, output) {
2282
- var pos = cursorCoords(cm, range.head, "div", null, null, !cm.options.singleCursorHeightPerLine);
2283
+ function drawSelectionCursor(cm, head, output) {
2284
+ var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
2283
2285
 
2284
2286
  var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
2285
2287
  cursor.style.left = pos.left + "px";
@@ -2403,8 +2405,8 @@
2403
2405
 
2404
2406
  doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
2405
2407
  if (doc.frontier >= cm.display.viewFrom) { // Visible
2406
- var oldStyles = line.styles;
2407
- var highlighted = highlightLine(cm, line, state, true);
2408
+ var oldStyles = line.styles, tooLong = line.text.length > cm.options.maxHighlightLength;
2409
+ var highlighted = highlightLine(cm, line, tooLong ? copyState(doc.mode, state) : state, true);
2408
2410
  line.styles = highlighted.styles;
2409
2411
  var oldCls = line.styleClasses, newCls = highlighted.classes;
2410
2412
  if (newCls) line.styleClasses = newCls;
@@ -2413,9 +2415,10 @@
2413
2415
  oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
2414
2416
  for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
2415
2417
  if (ischange) changedLines.push(doc.frontier);
2416
- line.stateAfter = copyState(doc.mode, state);
2418
+ line.stateAfter = tooLong ? state : copyState(doc.mode, state);
2417
2419
  } else {
2418
- processLine(cm, line.text, state);
2420
+ if (line.text.length <= cm.options.maxHighlightLength)
2421
+ processLine(cm, line.text, state);
2419
2422
  line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
2420
2423
  }
2421
2424
  ++doc.frontier;
@@ -2978,12 +2981,12 @@
2978
2981
  var callbacks = group.delayedCallbacks, i = 0;
2979
2982
  do {
2980
2983
  for (; i < callbacks.length; i++)
2981
- callbacks[i]();
2984
+ callbacks[i].call(null);
2982
2985
  for (var j = 0; j < group.ops.length; j++) {
2983
2986
  var op = group.ops[j];
2984
2987
  if (op.cursorActivityHandlers)
2985
2988
  while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
2986
- op.cursorActivityHandlers[op.cursorActivityCalled++](op.cm);
2989
+ op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm);
2987
2990
  }
2988
2991
  } while (i < callbacks.length);
2989
2992
  }
@@ -3443,9 +3446,11 @@
3443
3446
  on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
3444
3447
 
3445
3448
  d.dragFunctions = {
3446
- simple: function(e) {if (!signalDOMEvent(cm, e)) e_stop(e);},
3449
+ enter: function(e) {if (!signalDOMEvent(cm, e)) e_stop(e);},
3450
+ over: function(e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }},
3447
3451
  start: function(e){onDragStart(cm, e);},
3448
- drop: operation(cm, onDrop)
3452
+ drop: operation(cm, onDrop),
3453
+ leave: function() {clearDragCursor(cm);}
3449
3454
  };
3450
3455
 
3451
3456
  var inp = d.input.getField();
@@ -3462,8 +3467,9 @@
3462
3467
  var funcs = cm.display.dragFunctions;
3463
3468
  var toggle = value ? on : off;
3464
3469
  toggle(cm.display.scroller, "dragstart", funcs.start);
3465
- toggle(cm.display.scroller, "dragenter", funcs.simple);
3466
- toggle(cm.display.scroller, "dragover", funcs.simple);
3470
+ toggle(cm.display.scroller, "dragenter", funcs.enter);
3471
+ toggle(cm.display.scroller, "dragover", funcs.over);
3472
+ toggle(cm.display.scroller, "dragleave", funcs.leave);
3467
3473
  toggle(cm.display.scroller, "drop", funcs.drop);
3468
3474
  }
3469
3475
  }
@@ -3536,7 +3542,10 @@
3536
3542
 
3537
3543
  switch (e_button(e)) {
3538
3544
  case 1:
3539
- if (start)
3545
+ // #3261: make sure, that we're not starting a second selection
3546
+ if (cm.state.selectingText)
3547
+ cm.state.selectingText(e);
3548
+ else if (start)
3540
3549
  leftButtonDown(cm, e, start);
3541
3550
  else if (e_target(e) == display.scroller)
3542
3551
  e_preventDefault(e);
@@ -3656,7 +3665,8 @@
3656
3665
  setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
3657
3666
  {scroll: false, origin: "*mouse"});
3658
3667
  } else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) {
3659
- setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0));
3668
+ setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
3669
+ {scroll: false, origin: "*mouse"});
3660
3670
  startSel = doc.sel;
3661
3671
  } else {
3662
3672
  replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
@@ -3734,6 +3744,7 @@
3734
3744
  }
3735
3745
 
3736
3746
  function done(e) {
3747
+ cm.state.selectingText = false;
3737
3748
  counter = Infinity;
3738
3749
  e_preventDefault(e);
3739
3750
  display.input.focus();
@@ -3747,6 +3758,7 @@
3747
3758
  else extend(e);
3748
3759
  });
3749
3760
  var up = operation(cm, done);
3761
+ cm.state.selectingText = up;
3750
3762
  on(document, "mousemove", move);
3751
3763
  on(document, "mouseup", up);
3752
3764
  }
@@ -3786,6 +3798,7 @@
3786
3798
 
3787
3799
  function onDrop(e) {
3788
3800
  var cm = this;
3801
+ clearDragCursor(cm);
3789
3802
  if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
3790
3803
  return;
3791
3804
  e_preventDefault(e);
@@ -3858,6 +3871,25 @@
3858
3871
  }
3859
3872
  }
3860
3873
 
3874
+ function onDragOver(cm, e) {
3875
+ var pos = posFromMouse(cm, e);
3876
+ if (!pos) return;
3877
+ var frag = document.createDocumentFragment();
3878
+ drawSelectionCursor(cm, pos, frag);
3879
+ if (!cm.display.dragCursor) {
3880
+ cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors");
3881
+ cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv);
3882
+ }
3883
+ removeChildrenAndAdd(cm.display.dragCursor, frag);
3884
+ }
3885
+
3886
+ function clearDragCursor(cm) {
3887
+ if (cm.display.dragCursor) {
3888
+ cm.display.lineSpace.removeChild(cm.display.dragCursor);
3889
+ cm.display.dragCursor = null;
3890
+ }
3891
+ }
3892
+
3861
3893
  // SCROLL EVENTS
3862
3894
 
3863
3895
  // Sync the scrollable area and scrollbars, ensure the viewport
@@ -5064,7 +5096,7 @@
5064
5096
 
5065
5097
  execCommand: function(cmd) {
5066
5098
  if (commands.hasOwnProperty(cmd))
5067
- return commands[cmd](this);
5099
+ return commands[cmd].call(null, this);
5068
5100
  },
5069
5101
 
5070
5102
  triggerElectric: methodOp(function(text) { triggerElectric(this, text); }),
@@ -6783,7 +6815,9 @@
6783
6815
 
6784
6816
  function getLineStyles(cm, line, updateFrontier) {
6785
6817
  if (!line.styles || line.styles[0] != cm.state.modeGen) {
6786
- var result = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line)));
6818
+ var state = getStateBefore(cm, lineNo(line));
6819
+ var result = highlightLine(cm, line, line.text.length > cm.options.maxHighlightLength ? copyState(cm.doc.mode, state) : state);
6820
+ line.stateAfter = state;
6787
6821
  line.styles = result.styles;
6788
6822
  if (result.classes) line.styleClasses = result.classes;
6789
6823
  else if (line.styleClasses) line.styleClasses = null;
@@ -6800,7 +6834,7 @@
6800
6834
  var stream = new StringStream(text, cm.options.tabSize);
6801
6835
  stream.start = stream.pos = startAt || 0;
6802
6836
  if (text == "") callBlankLine(mode, state);
6803
- while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) {
6837
+ while (!stream.eol()) {
6804
6838
  readToken(mode, stream, state);
6805
6839
  stream.start = stream.pos;
6806
6840
  }
@@ -8782,7 +8816,7 @@
8782
8816
 
8783
8817
  // THE END
8784
8818
 
8785
- CodeMirror.version = "5.5.0";
8819
+ CodeMirror.version = "5.6.0";
8786
8820
 
8787
8821
  return CodeMirror;
8788
8822
  });
@@ -0,0 +1,47 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function(mod) {
5
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
6
+ mod(require("../../lib/codemirror"))
7
+ else if (typeof define == "function" && define.amd) // AMD
8
+ define(["../../lib/codemirror"], mod)
9
+ else // Plain browser env
10
+ mod(CodeMirror)
11
+ })(function(CodeMirror) {
12
+ "use strict"
13
+
14
+ CodeMirror.defineOption("autoRefresh", false, function(cm, val) {
15
+ if (cm.state.autoRefresh) {
16
+ stopListening(cm, cm.state.autoRefresh)
17
+ cm.state.autoRefresh = null
18
+ }
19
+ if (val && cm.display.wrapper.offsetHeight == 0)
20
+ startListening(cm, cm.state.autoRefresh = {delay: val.delay || 250})
21
+ })
22
+
23
+ function startListening(cm, state) {
24
+ function check() {
25
+ if (cm.display.wrapper.offsetHeight) {
26
+ stopListening(cm, state)
27
+ if (cm.display.lastWrapHeight != cm.display.wrapper.clientHeight)
28
+ cm.refresh()
29
+ } else {
30
+ state.timeout = setTimeout(check, state.delay)
31
+ }
32
+ }
33
+ state.timeout = setTimeout(check, state.delay)
34
+ state.hurry = function() {
35
+ clearTimeout(state.timeout)
36
+ state.timeout = setTimeout(check, 50)
37
+ }
38
+ CodeMirror.on(window, "mouseup", state.hurry)
39
+ CodeMirror.on(window, "keyup", state.hurry)
40
+ }
41
+
42
+ function stopListening(_cm, state) {
43
+ clearTimeout(state.timeout)
44
+ CodeMirror.off(window, "mouseup", state.hurry)
45
+ CodeMirror.off(window, "keyup", state.hurry)
46
+ }
47
+ });
@@ -108,19 +108,22 @@
108
108
  // when completing in JS/CSS snippet in htmlmixed mode. Does not
109
109
  // work for other XML embedded languages (there is no general
110
110
  // way to go from a mixed mode to its current XML state).
111
+ var replacement;
111
112
  if (inner.mode.name != "xml") {
112
113
  if (cm.getMode().name == "htmlmixed" && inner.mode.name == "javascript")
113
- replacements[i] = head + "script>";
114
+ replacement = head + "script";
114
115
  else if (cm.getMode().name == "htmlmixed" && inner.mode.name == "css")
115
- replacements[i] = head + "style>";
116
+ replacement = head + "style";
116
117
  else
117
118
  return CodeMirror.Pass;
118
119
  } else {
119
120
  if (!state.context || !state.context.tagName ||
120
121
  closingTagExists(cm, state.context.tagName, pos, state))
121
122
  return CodeMirror.Pass;
122
- replacements[i] = head + state.context.tagName + ">";
123
+ replacement = head + state.context.tagName;
123
124
  }
125
+ if (cm.getLine(pos.line).charAt(tok.end) != ">") replacement += ">";
126
+ replacements[i] = replacement;
124
127
  }
125
128
  cm.replaceSelections(replacements);
126
129
  ranges = cm.listSelections();
@@ -21,7 +21,7 @@
21
21
  while (start && word.test(curLine.charAt(start - 1))) --start;
22
22
  var curWord = start != end && curLine.slice(start, end);
23
23
 
24
- var list = [], seen = {};
24
+ var list = options && options.list || [], seen = {};
25
25
  var re = new RegExp(word.source, "g");
26
26
  for (var dir = -1; dir <= 1; dir += 2) {
27
27
  var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
@@ -0,0 +1,46 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ // Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js
5
+
6
+ // declare global: HTMLHint
7
+
8
+ (function(mod) {
9
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
10
+ mod(require("../../lib/codemirror"), require("htmlhint"));
11
+ else if (typeof define == "function" && define.amd) // AMD
12
+ define(["../../lib/codemirror", "htmlhint"], mod);
13
+ else // Plain browser env
14
+ mod(CodeMirror);
15
+ })(function(CodeMirror) {
16
+ "use strict";
17
+
18
+ var defaultRules = {
19
+ "tagname-lowercase": true,
20
+ "attr-lowercase": true,
21
+ "attr-value-double-quotes": true,
22
+ "doctype-first": false,
23
+ "tag-pair": true,
24
+ "spec-char-escape": true,
25
+ "id-unique": true,
26
+ "src-not-empty": true,
27
+ "attr-no-duplication": true
28
+ };
29
+
30
+ CodeMirror.registerHelper("lint", "html", function(text, options) {
31
+ var found = [];
32
+ if (!window.HTMLHint) return found;
33
+ var messages = HTMLHint.verify(text, options && options.rules || defaultRules);
34
+ for (var i = 0; i < messages.length; i++) {
35
+ var message = messages[i];
36
+ var startLine = message.line - 1, endLine = message.line - 1, startCol = message.col - 1, endCol = message.col;
37
+ found.push({
38
+ from: CodeMirror.Pos(startLine, startCol),
39
+ to: CodeMirror.Pos(endLine, endCol),
40
+ message: message.message,
41
+ severity : message.type
42
+ });
43
+ }
44
+ return found;
45
+ });
46
+ });
@@ -187,7 +187,8 @@
187
187
  CodeMirror.defineOption("lint", false, function(cm, val, old) {
188
188
  if (old && old != CodeMirror.Init) {
189
189
  clearMarks(cm);
190
- cm.off("change", onChange);
190
+ if (cm.state.lint.options.lintOnChange !== false)
191
+ cm.off("change", onChange);
191
192
  CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
192
193
  clearTimeout(cm.state.lint.timeout);
193
194
  delete cm.state.lint;
@@ -197,11 +198,16 @@
197
198
  var gutters = cm.getOption("gutters"), hasLintGutter = false;
198
199
  for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
199
200
  var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
200
- cm.on("change", onChange);
201
+ if (state.options.lintOnChange !== false)
202
+ cm.on("change", onChange);
201
203
  if (state.options.tooltips != false)
202
204
  CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
203
205
 
204
206
  startLinting(cm);
205
207
  }
206
208
  });
209
+
210
+ CodeMirror.defineExtension("performLint", function() {
211
+ if (this.state.lint) startLinting(this);
212
+ });
207
213
  });
@@ -9,8 +9,8 @@
9
9
  else if (typeof define == "function" && define.amd) // AMD
10
10
  define(["../../lib/codemirror", "diff_match_patch"], mod);
11
11
  else // Plain browser env
12
- mod(CodeMirror, diff_match_patch);
13
- })(function(CodeMirror, diff_match_patch) {
12
+ mod(CodeMirror);
13
+ })(function(CodeMirror) {
14
14
  "use strict";
15
15
  var Pos = CodeMirror.Pos;
16
16
  var svgNS = "http://www.w3.org/2000/svg";
@@ -76,11 +76,21 @@
76
76
  else if (confirm(shortText)) fs[0]();
77
77
  }
78
78
 
79
+ function parseString(string) {
80
+ return string.replace(/\\(.)/g, function(_, ch) {
81
+ if (ch == "n") return "\n"
82
+ if (ch == "r") return "\r"
83
+ return ch
84
+ })
85
+ }
86
+
79
87
  function parseQuery(query) {
80
88
  var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
81
89
  if (isRE) {
82
90
  try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); }
83
91
  catch(e) {} // Not a regular expression after all, do a string search
92
+ } else {
93
+ query = parseString(query)
84
94
  }
85
95
  if (typeof query == "string" ? query == "" : query.test(""))
86
96
  query = /x^/;
@@ -157,6 +167,7 @@
157
167
  if (!query) return;
158
168
  query = parseQuery(query);
159
169
  dialog(cm, replacementQueryDialog, "Replace with:", "", function(text) {
170
+ text = parseString(text)
160
171
  if (all) {
161
172
  cm.operation(function() {
162
173
  for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
@@ -266,7 +266,7 @@
266
266
  child.target = "_blank";
267
267
  }
268
268
  }
269
- tempTooltip(cm, tip);
269
+ tempTooltip(cm, tip, ts);
270
270
  if (c) c();
271
271
  }, pos);
272
272
  }
@@ -466,11 +466,12 @@
466
466
  ts.request(cm, {type: "refs"}, function(error, data) {
467
467
  if (error) return showError(ts, cm, error);
468
468
  var ranges = [], cur = 0;
469
+ var curPos = cm.getCursor();
469
470
  for (var i = 0; i < data.refs.length; i++) {
470
471
  var ref = data.refs[i];
471
472
  if (ref.file == name) {
472
473
  ranges.push({anchor: ref.start, head: ref.end});
473
- if (cmpPos(cur, ref.start) >= 0 && cmpPos(cur, ref.end) <= 0)
474
+ if (cmpPos(curPos, ref.start) >= 0 && cmpPos(curPos, ref.end) <= 0)
474
475
  cur = ranges.length - 1;
475
476
  }
476
477
  }
@@ -592,7 +593,7 @@
592
593
 
593
594
  // Tooltips
594
595
 
595
- function tempTooltip(cm, content) {
596
+ function tempTooltip(cm, content, ts) {
596
597
  if (cm.state.ternTooltip) remove(cm.state.ternTooltip);
597
598
  var where = cm.cursorCoords();
598
599
  var tip = cm.state.ternTooltip = makeTooltip(where.right + 1, where.bottom, content);
@@ -616,7 +617,7 @@
616
617
  else mouseOnTip = false;
617
618
  }
618
619
  });
619
- setTimeout(maybeClear, 1700);
620
+ setTimeout(maybeClear, ts.options.hintDelay ? ts.options.hintDelay : 1700);
620
621
  cm.on("cursorActivity", clear);
621
622
  cm.on('blur', clear);
622
623
  cm.on('scroll', clear);
@@ -644,7 +645,7 @@
644
645
  if (ts.options.showError)
645
646
  ts.options.showError(cm, msg);
646
647
  else
647
- tempTooltip(cm, String(msg));
648
+ tempTooltip(cm, String(msg), ts);
648
649
  }
649
650
 
650
651
  function closeArgHints(ts) {