codemirror-rails 3.12 → 3.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/codemirror-rails.gemspec +1 -1
  3. data/lib/codemirror/rails/version.rb +2 -2
  4. data/vendor/assets/javascripts/codemirror.js +168 -116
  5. data/vendor/assets/javascripts/codemirror/addons/comment/comment.js +144 -0
  6. data/vendor/assets/javascripts/codemirror/addons/display/placeholder.js +4 -4
  7. data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +2 -2
  8. data/vendor/assets/javascripts/codemirror/addons/fold/brace-fold.js +9 -3
  9. data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +13 -13
  10. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.js +5 -1
  11. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +13 -1
  12. data/vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js +4 -4
  13. data/vendor/assets/javascripts/codemirror/addons/search/search.js +1 -1
  14. data/vendor/assets/javascripts/codemirror/addons/search/searchcursor.js +15 -5
  15. data/vendor/assets/javascripts/codemirror/addons/selection/active-line.js +6 -6
  16. data/vendor/assets/javascripts/codemirror/addons/selection/mark-selection.js +89 -15
  17. data/vendor/assets/javascripts/codemirror/keymaps/vim.js +451 -187
  18. data/vendor/assets/javascripts/codemirror/modes/clike.js +6 -3
  19. data/vendor/assets/javascripts/codemirror/modes/clojure.js +3 -1
  20. data/vendor/assets/javascripts/codemirror/modes/cobol.js +240 -0
  21. data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +2 -1
  22. data/vendor/assets/javascripts/codemirror/modes/commonlisp.js +5 -1
  23. data/vendor/assets/javascripts/codemirror/modes/css.js +63 -24
  24. data/vendor/assets/javascripts/codemirror/modes/erlang.js +3 -2
  25. data/vendor/assets/javascripts/codemirror/modes/gas.js +5 -1
  26. data/vendor/assets/javascripts/codemirror/modes/go.js +4 -1
  27. data/vendor/assets/javascripts/codemirror/modes/haml.js +153 -0
  28. data/vendor/assets/javascripts/codemirror/modes/haskell.js +5 -1
  29. data/vendor/assets/javascripts/codemirror/modes/javascript.js +5 -1
  30. data/vendor/assets/javascripts/codemirror/modes/less.js +0 -8
  31. data/vendor/assets/javascripts/codemirror/modes/lua.js +5 -1
  32. data/vendor/assets/javascripts/codemirror/modes/markdown.js +2 -2
  33. data/vendor/assets/javascripts/codemirror/modes/ocaml.js +4 -1
  34. data/vendor/assets/javascripts/codemirror/modes/php.js +3 -0
  35. data/vendor/assets/javascripts/codemirror/modes/python.js +2 -1
  36. data/vendor/assets/javascripts/codemirror/modes/ruby.js +2 -1
  37. data/vendor/assets/javascripts/codemirror/modes/rust.js +4 -1
  38. data/vendor/assets/javascripts/codemirror/modes/sass.js +8 -27
  39. data/vendor/assets/javascripts/codemirror/modes/scheme.js +3 -1
  40. data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +6 -4
  41. data/vendor/assets/javascripts/codemirror/modes/sql.js +3 -4
  42. data/vendor/assets/javascripts/codemirror/modes/stex.js +1 -1
  43. data/vendor/assets/javascripts/codemirror/modes/xml.js +2 -0
  44. data/vendor/assets/javascripts/codemirror/modes/yaml.js +3 -1
  45. data/vendor/assets/stylesheets/codemirror.css +7 -4
  46. data/vendor/assets/stylesheets/codemirror/addons/lint/lint.css +3 -3
  47. data/vendor/assets/stylesheets/codemirror/themes/rubyblue.css +1 -1
  48. metadata +14 -6
  49. data/vendor/assets/javascripts/codemirror/modes/test.js +0 -64
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2427ad0abadb3c23235f0807a459c7f5d8aad5b6
4
- data.tar.gz: 3feb14d065dfe7f9cd5633dd11a19879c6790345
3
+ metadata.gz: 2f5ff9291537f44a79316e34c24d2d354e2f29c6
4
+ data.tar.gz: dc676429b0b8522bb08b194d5b65715b0f58af6c
5
5
  SHA512:
6
- metadata.gz: 9ed90ea774b637f9c6565bb836db4fe6aef30cc9a2317af6865056141b65b1d1dbecfa4853df73bdee3356f5233a0504dae79a93c845941be3f09f6cbfdc92ad
7
- data.tar.gz: 8eecc04dce862ef3803ce8ce35f6c15979d575c45121a4c95c660afbdb008a54e6fa112c209a828225bc73447ff3d8a83fd3d80de1cf79ff2470946e54403eb9
6
+ metadata.gz: ca0624b4dc29f738fe94f05c8e3b9f01d2f4aeee92432a5080d64d999700b82b98b05473e4e5cb450fb1631fb733eb5bfd609e796474638acc8639764b216611
7
+ data.tar.gz: 7d91163dcafa7486d50bb46ab2c499129fc9ed74f6c969a460f99ebb47e469c513eda6c3316aff62f1552a834b93d6be530616ee525c59071876689f627ffe79
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = `git ls-files`.split("\n")
14
14
 
15
- s.add_runtime_dependency 'railties', '~> 3.0'
15
+ s.add_runtime_dependency 'railties', '>= 3.0', '< 5'
16
16
 
17
17
  s.add_development_dependency 'rails', '~> 3.0'
18
18
  s.add_development_dependency 'sqlite3'
@@ -1,6 +1,6 @@
1
1
  module Codemirror
2
2
  module Rails
3
- VERSION = '3.12'
4
- CODEMIRROR_VERSION = '3.12'
3
+ VERSION = '3.13'
4
+ CODEMIRROR_VERSION = '3.13'
5
5
  end
6
6
  end
@@ -1,4 +1,4 @@
1
- // CodeMirror version 3.12
1
+ // CodeMirror version 3.13
2
2
  //
3
3
  // CodeMirror is the only global var we claim
4
4
  window.CodeMirror = (function() {
@@ -99,7 +99,7 @@ window.CodeMirror = (function() {
99
99
  else input.setAttribute("wrap", "off");
100
100
  // if border: 0; -- iOS fails to open keyboard (issue #1287)
101
101
  if (ios) input.style.border = "1px solid black";
102
- input.setAttribute("autocorrect", "off"); input.setAttribute("autocapitalize", "off");
102
+ input.setAttribute("autocorrect", "off"); input.setAttribute("autocapitalize", "off"); input.setAttribute("spellcheck", "false");
103
103
 
104
104
  // Wraps and hides input textarea
105
105
  d.inputDiv = elt("div", [input], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
@@ -107,8 +107,9 @@ window.CodeMirror = (function() {
107
107
  d.scrollbarH = elt("div", [elt("div", null, null, "height: 1px")], "CodeMirror-hscrollbar");
108
108
  d.scrollbarV = elt("div", [elt("div", null, null, "width: 1px")], "CodeMirror-vscrollbar");
109
109
  d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
110
+ d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
110
111
  // DIVs containing the selection and the actual code
111
- d.lineDiv = elt("div");
112
+ d.lineDiv = elt("div", null, "CodeMirror-code");
112
113
  d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
113
114
  // Blinky cursor, and element used to ensure cursor fits at the end of a line
114
115
  d.cursor = elt("div", "\u00a0", "CodeMirror-cursor");
@@ -128,14 +129,12 @@ window.CodeMirror = (function() {
128
129
  // Will contain the gutters, if any
129
130
  d.gutters = elt("div", null, "CodeMirror-gutters");
130
131
  d.lineGutter = null;
131
- // Helper element to properly size the gutter backgrounds
132
- var scrollerInner = elt("div", [d.sizer, d.heightForcer, d.gutters], null, "position: relative; min-height: 100%");
133
132
  // Provides scrolling
134
- d.scroller = elt("div", [scrollerInner], "CodeMirror-scroll");
133
+ d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
135
134
  d.scroller.setAttribute("tabIndex", "-1");
136
135
  // The element in which the editor lives.
137
136
  d.wrapper = elt("div", [d.inputDiv, d.scrollbarH, d.scrollbarV,
138
- d.scrollbarFiller, d.scroller], "CodeMirror");
137
+ d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
139
138
  // Work around IE7 z-index bug
140
139
  if (ie_lt8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
141
140
  if (place.appendChild) place.appendChild(d.wrapper); else place(d.wrapper);
@@ -214,7 +213,7 @@ window.CodeMirror = (function() {
214
213
  estimateLineHeights(cm);
215
214
  regChange(cm);
216
215
  clearCaches(cm);
217
- setTimeout(function(){updateScrollbars(cm.display, cm.doc.height);}, 100);
216
+ setTimeout(function(){updateScrollbars(cm);}, 100);
218
217
  }
219
218
 
220
219
  function estimateHeight(cm) {
@@ -253,6 +252,7 @@ window.CodeMirror = (function() {
253
252
  function guttersChanged(cm) {
254
253
  updateGutters(cm);
255
254
  regChange(cm);
255
+ setTimeout(function(){alignHorizontally(cm);}, 20);
256
256
  }
257
257
 
258
258
  function updateGutters(cm) {
@@ -319,9 +319,11 @@ window.CodeMirror = (function() {
319
319
 
320
320
  // Re-synchronize the fake scrollbars with the actual size of the
321
321
  // content. Optionally force a scrollTop.
322
- function updateScrollbars(d /* display */, docHeight) {
322
+ function updateScrollbars(cm) {
323
+ var d = cm.display, docHeight = cm.doc.height;
323
324
  var totalHeight = docHeight + paddingVert(d);
324
325
  d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + "px";
326
+ d.gutters.style.height = Math.max(totalHeight, d.scroller.clientHeight - scrollerCutOff) + "px";
325
327
  var scrollHeight = Math.max(totalHeight, d.scroller.scrollHeight);
326
328
  var needsH = d.scroller.scrollWidth > d.scroller.clientWidth;
327
329
  var needsV = scrollHeight > d.scroller.clientHeight;
@@ -341,6 +343,11 @@ window.CodeMirror = (function() {
341
343
  d.scrollbarFiller.style.display = "block";
342
344
  d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = scrollbarWidth(d.measure) + "px";
343
345
  } else d.scrollbarFiller.style.display = "";
346
+ if (needsH && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
347
+ d.gutterFiller.style.display = "block";
348
+ d.gutterFiller.style.height = scrollbarWidth(d.measure) + "px";
349
+ d.gutterFiller.style.width = d.gutters.offsetWidth + "px";
350
+ } else d.gutterFiller.style.display = "";
344
351
 
345
352
  if (mac_geLion && scrollbarWidth(d.measure) === 0)
346
353
  d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = mac_geMountainLion ? "18px" : "12px";
@@ -399,14 +406,10 @@ window.CodeMirror = (function() {
399
406
  var oldFrom = cm.display.showingFrom, oldTo = cm.display.showingTo, updated;
400
407
  var visible = visibleLines(cm.display, cm.doc, viewPort);
401
408
  for (;;) {
402
- if (updateDisplayInner(cm, changes, visible)) {
403
- updated = true;
404
- signalLater(cm, "update", cm);
405
- if (cm.display.showingFrom != oldFrom || cm.display.showingTo != oldTo)
406
- signalLater(cm, "viewportChange", cm, cm.display.showingFrom, cm.display.showingTo);
407
- } else break;
409
+ if (!updateDisplayInner(cm, changes, visible)) break;
410
+ updated = true;
408
411
  updateSelection(cm);
409
- updateScrollbars(cm.display, cm.doc.height);
412
+ updateScrollbars(cm);
410
413
 
411
414
  // Clip forced viewport to actual scrollable area
412
415
  if (viewPort)
@@ -418,6 +421,11 @@ window.CodeMirror = (function() {
418
421
  changes = [];
419
422
  }
420
423
 
424
+ if (updated) {
425
+ signalLater(cm, "update", cm);
426
+ if (cm.display.showingFrom != oldFrom || cm.display.showingTo != oldTo)
427
+ signalLater(cm, "viewportChange", cm, cm.display.showingFrom, cm.display.showingTo);
428
+ }
421
429
  return updated;
422
430
  }
423
431
 
@@ -978,23 +986,28 @@ window.CodeMirror = (function() {
978
986
  if (memo.text == line.text && memo.markedSpans == line.markedSpans &&
979
987
  cm.display.scroller.clientWidth == memo.width &&
980
988
  memo.classes == line.textClass + "|" + line.bgClass + "|" + line.wrapClass)
981
- return memo.measure;
989
+ return memo;
982
990
  }
983
991
  }
984
992
 
993
+ function clearCachedMeasurement(cm, line) {
994
+ var exists = findCachedMeasurement(cm, line);
995
+ if (exists) exists.text = exists.measure = exists.markedSpans = null;
996
+ }
997
+
985
998
  function measureLine(cm, line) {
986
999
  // First look in the cache
987
- var measure = findCachedMeasurement(cm, line);
988
- if (!measure) {
989
- // Failing that, recompute and store result in cache
990
- measure = measureLineInner(cm, line);
991
- var cache = cm.display.measureLineCache;
992
- var memo = {text: line.text, width: cm.display.scroller.clientWidth,
993
- markedSpans: line.markedSpans, measure: measure,
994
- classes: line.textClass + "|" + line.bgClass + "|" + line.wrapClass};
995
- if (cache.length == 16) cache[++cm.display.measureLineCachePos % 16] = memo;
996
- else cache.push(memo);
997
- }
1000
+ var cached = findCachedMeasurement(cm, line);
1001
+ if (cached) return cached.measure;
1002
+
1003
+ // Failing that, recompute and store result in cache
1004
+ var measure = measureLineInner(cm, line);
1005
+ var cache = cm.display.measureLineCache;
1006
+ var memo = {text: line.text, width: cm.display.scroller.clientWidth,
1007
+ markedSpans: line.markedSpans, measure: measure,
1008
+ classes: line.textClass + "|" + line.bgClass + "|" + line.wrapClass};
1009
+ if (cache.length == 16) cache[++cm.display.measureLineCachePos % 16] = memo;
1010
+ else cache.push(memo);
998
1011
  return measure;
999
1012
  }
1000
1013
 
@@ -1070,7 +1083,7 @@ window.CodeMirror = (function() {
1070
1083
  if (sp.collapsed && (sp.to == null || sp.to == line.text.length)) hasBadSpan = true;
1071
1084
  }
1072
1085
  var cached = !hasBadSpan && findCachedMeasurement(cm, line);
1073
- if (cached) return measureChar(cm, line, line.text.length, cached).right;
1086
+ if (cached) return measureChar(cm, line, line.text.length, cached.measure).right;
1074
1087
 
1075
1088
  var pre = lineContent(cm, line);
1076
1089
  var end = pre.appendChild(zeroWidthElement(cm.display.measure));
@@ -1138,32 +1151,26 @@ window.CodeMirror = (function() {
1138
1151
  if (right) m.left = m.right; else m.right = m.left;
1139
1152
  return intoCoordSystem(cm, lineObj, m, context);
1140
1153
  }
1141
- var order = getOrder(lineObj), ch = pos.ch;
1142
- if (!order) return get(ch);
1143
- var main, other, linedir = order[0].level;
1144
- for (var i = 0; i < order.length; ++i) {
1145
- var part = order[i], rtl = part.level % 2, nb, here;
1146
- if (part.from < ch && part.to > ch) return get(ch, rtl);
1147
- var left = rtl ? part.to : part.from, right = rtl ? part.from : part.to;
1148
- if (left == ch) {
1149
- // IE returns bogus offsets and widths for edges where the
1150
- // direction flips, but only for the side with the lower
1151
- // level. So we try to use the side with the higher level.
1152
- if (i && part.level < (nb = order[i-1]).level) here = get(nb.level % 2 ? nb.from : nb.to - 1, true);
1153
- else here = get(rtl && part.from != part.to ? ch - 1 : ch);
1154
- if (rtl == linedir) main = here; else other = here;
1155
- } else if (right == ch) {
1156
- var nb = i < order.length - 1 && order[i+1];
1157
- if (!rtl && nb && nb.from == nb.to) continue;
1158
- if (nb && part.level < nb.level) here = get(nb.level % 2 ? nb.to - 1 : nb.from);
1159
- else here = get(rtl ? ch : ch - 1, true);
1160
- if (rtl == linedir) main = here; else other = here;
1154
+ function getBidi(ch, partPos) {
1155
+ var part = order[partPos], right = part.level % 2;
1156
+ if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
1157
+ part = order[--partPos];
1158
+ ch = bidiRight(part) - (part.level % 2 ? 0 : 1);
1159
+ right = true;
1160
+ } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
1161
+ part = order[++partPos];
1162
+ ch = bidiLeft(part) - part.level % 2;
1163
+ right = false;
1161
1164
  }
1165
+ if (right && ch == part.to && ch > part.from) return get(ch - 1);
1166
+ return get(ch, right);
1162
1167
  }
1163
- if (linedir && !ch) other = get(order[0].to - 1);
1164
- if (!main) return other;
1165
- if (other) main.other = other;
1166
- return main;
1168
+ var order = getOrder(lineObj), ch = pos.ch;
1169
+ if (!order) return get(ch);
1170
+ var partPos = getBidiPartAt(order, ch);
1171
+ var val = getBidi(ch, partPos);
1172
+ if (bidiOther != null) val.other = getBidi(ch, bidiOther);
1173
+ return val;
1167
1174
  }
1168
1175
 
1169
1176
  function PosMaybeOutside(line, ch, outside) {
@@ -1587,7 +1594,7 @@ window.CodeMirror = (function() {
1587
1594
  var target = e_target(e);
1588
1595
  if (target == display.scrollbarH || target == display.scrollbarH.firstChild ||
1589
1596
  target == display.scrollbarV || target == display.scrollbarV.firstChild ||
1590
- target == display.scrollbarFiller) return null;
1597
+ target == display.scrollbarFiller || target == display.gutterFiller) return null;
1591
1598
  }
1592
1599
  var x, y, space = getRect(display.lineSpace);
1593
1600
  // Fails unpredictably on IE[67] when mouse is dragged around quickly.
@@ -2092,6 +2099,13 @@ window.CodeMirror = (function() {
2092
2099
  // Adds "Select all" to context menu in FF
2093
2100
  if (posEq(sel.from, sel.to)) display.input.value = display.prevInput = " ";
2094
2101
 
2102
+ function prepareSelectAllHack() {
2103
+ if (display.input.selectionStart != null) {
2104
+ var extval = display.input.value = " " + (posEq(sel.from, sel.to) ? "" : display.input.value);
2105
+ display.prevInput = " ";
2106
+ display.input.selectionStart = 1; display.input.selectionEnd = extval.length;
2107
+ }
2108
+ }
2095
2109
  function rehide() {
2096
2110
  display.inputDiv.style.position = "relative";
2097
2111
  display.input.style.cssText = oldCSS;
@@ -2099,12 +2113,10 @@ window.CodeMirror = (function() {
2099
2113
  slowPoll(cm);
2100
2114
 
2101
2115
  // Try to detect the user choosing select-all
2102
- if (display.input.selectionStart != null && (!ie || ie_lt9)) {
2116
+ if (display.input.selectionStart != null) {
2117
+ if (!ie || ie_lt9) prepareSelectAllHack();
2103
2118
  clearTimeout(detectingSelectAll);
2104
- var extval = display.input.value = " " + (posEq(sel.from, sel.to) ? "" : display.input.value), i = 0;
2105
- display.prevInput = " ";
2106
- display.input.selectionStart = 1; display.input.selectionEnd = extval.length;
2107
- var poll = function(){
2119
+ var i = 0, poll = function(){
2108
2120
  if (display.prevInput == " " && display.input.selectionStart == 0)
2109
2121
  operation(cm, commands.selectAll)(cm);
2110
2122
  else if (i++ < 10) detectingSelectAll = setTimeout(poll, 500);
@@ -2114,6 +2126,7 @@ window.CodeMirror = (function() {
2114
2126
  }
2115
2127
  }
2116
2128
 
2129
+ if (ie && !ie_lt9) prepareSelectAllHack();
2117
2130
  if (captureMiddleClick) {
2118
2131
  e_stop(e);
2119
2132
  var mouseup = function() {
@@ -2514,7 +2527,7 @@ window.CodeMirror = (function() {
2514
2527
  // SCROLLING
2515
2528
 
2516
2529
  function scrollCursorIntoView(cm) {
2517
- var coords = scrollPosIntoView(cm, cm.doc.sel.head);
2530
+ var coords = scrollPosIntoView(cm, cm.doc.sel.head, cm.options.cursorScrollMargin);
2518
2531
  if (!cm.state.focused) return;
2519
2532
  var display = cm.display, box = getRect(display.sizer), doScroll = null, pTop = paddingTop(cm.display);
2520
2533
  if (coords.top + pTop + box.top < 0) doScroll = true;
@@ -2645,7 +2658,7 @@ window.CodeMirror = (function() {
2645
2658
  }
2646
2659
 
2647
2660
  function findPosH(doc, pos, dir, unit, visually) {
2648
- var line = pos.line, ch = pos.ch;
2661
+ var line = pos.line, ch = pos.ch, origDir = dir;
2649
2662
  var lineObj = getLine(doc, line);
2650
2663
  var possible = true;
2651
2664
  function findNextLine() {
@@ -2684,7 +2697,7 @@ window.CodeMirror = (function() {
2684
2697
  if (dir > 0 && !moveOnce(!first)) break;
2685
2698
  }
2686
2699
  }
2687
- var result = skipAtomic(doc, Pos(line, ch), dir, true);
2700
+ var result = skipAtomic(doc, Pos(line, ch), origDir, true);
2688
2701
  if (!possible) result.hitSide = true;
2689
2702
  return result;
2690
2703
  }
@@ -2730,6 +2743,7 @@ window.CodeMirror = (function() {
2730
2743
  // 'wrap f in an operation, performed on its `this` parameter'
2731
2744
 
2732
2745
  CodeMirror.prototype = {
2746
+ constructor: CodeMirror,
2733
2747
  focus: function(){window.focus(); focusInput(this); onFocus(this); fastPoll(this);},
2734
2748
 
2735
2749
  setOption: function(option, value) {
@@ -2990,7 +3004,8 @@ window.CodeMirror = (function() {
2990
3004
  sel.goalColumn = pos.left;
2991
3005
  }),
2992
3006
 
2993
- toggleOverwrite: function() {
3007
+ toggleOverwrite: function(value) {
3008
+ if (value != null && value == this.state.overwrite) return;
2994
3009
  if (this.state.overwrite = !this.state.overwrite)
2995
3010
  this.display.cursor.className += " CodeMirror-overwrite";
2996
3011
  else
@@ -3113,6 +3128,7 @@ window.CodeMirror = (function() {
3113
3128
  cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
3114
3129
  cm.refresh();
3115
3130
  }, true);
3131
+ option("coverGutterNextToScrollbar", false, updateScrollbars, true);
3116
3132
  option("lineNumbers", false, function(cm) {
3117
3133
  setGuttersForLineNumbers(cm.options);
3118
3134
  guttersChanged(cm);
@@ -3128,6 +3144,7 @@ window.CodeMirror = (function() {
3128
3144
  option("dragDrop", true);
3129
3145
 
3130
3146
  option("cursorBlinkRate", 530);
3147
+ option("cursorScrollMargin", 0);
3131
3148
  option("cursorHeight", 1);
3132
3149
  option("workTime", 100);
3133
3150
  option("workDelay", 100);
@@ -3165,10 +3182,15 @@ window.CodeMirror = (function() {
3165
3182
  };
3166
3183
 
3167
3184
  CodeMirror.resolveMode = function(spec) {
3168
- if (typeof spec == "string" && mimeModes.hasOwnProperty(spec))
3185
+ if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
3169
3186
  spec = mimeModes[spec];
3170
- else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec))
3187
+ } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
3188
+ var found = mimeModes[spec.name];
3189
+ spec = createObj(found, spec);
3190
+ spec.name = found.name;
3191
+ } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
3171
3192
  return CodeMirror.resolveMode("application/xml");
3193
+ }
3172
3194
  if (typeof spec == "string") return {name: spec};
3173
3195
  else return spec || {name: "null"};
3174
3196
  };
@@ -3598,15 +3620,18 @@ window.CodeMirror = (function() {
3598
3620
  return from && {from: from, to: to};
3599
3621
  };
3600
3622
 
3601
- TextMarker.prototype.getOptions = function(copyWidget) {
3602
- var repl = this.replacedWith;
3603
- return {className: this.className,
3604
- inclusiveLeft: this.inclusiveLeft, inclusiveRight: this.inclusiveRight,
3605
- atomic: this.atomic,
3606
- collapsed: this.collapsed,
3607
- replacedWith: copyWidget ? repl && repl.cloneNode(true) : repl,
3608
- readOnly: this.readOnly,
3609
- startStyle: this.startStyle, endStyle: this.endStyle};
3623
+ TextMarker.prototype.changed = function() {
3624
+ var pos = this.find(), cm = this.doc.cm;
3625
+ if (!pos || !cm) return;
3626
+ var line = getLine(this.doc, pos.from.line);
3627
+ clearCachedMeasurement(cm, line);
3628
+ if (pos.from.line >= cm.display.showingFrom && pos.from.line < cm.display.showingTo) {
3629
+ for (var node = cm.display.lineDiv.firstChild; node; node = node.nextSibling) if (node.lineObj == line) {
3630
+ if (node.offsetHeight != line.height) updateLineHeight(line, node.offsetHeight);
3631
+ break;
3632
+ }
3633
+ runInOp(cm, function() { cm.curOp.selectionChanged = true; });
3634
+ }
3610
3635
  };
3611
3636
 
3612
3637
  TextMarker.prototype.attachLine = function(line) {
@@ -3706,11 +3731,6 @@ window.CodeMirror = (function() {
3706
3731
  SharedTextMarker.prototype.find = function() {
3707
3732
  return this.primary.find();
3708
3733
  };
3709
- SharedTextMarker.prototype.getOptions = function(copyWidget) {
3710
- var inner = this.primary.getOptions(copyWidget);
3711
- inner.shared = true;
3712
- return inner;
3713
- };
3714
3734
 
3715
3735
  function markTextShared(doc, from, to, options, type) {
3716
3736
  options = copyObj(options);
@@ -4218,8 +4238,7 @@ window.CodeMirror = (function() {
4218
4238
  if (ch >= "\ud800" && ch < "\udbff" && i < text.length - 1) {
4219
4239
  ch = text.slice(i, i + 2);
4220
4240
  ++i;
4221
- } else if (i && wrapping &&
4222
- spanAffectsWrapping.test(text.slice(i - 1, i + 1))) {
4241
+ } else if (i && wrapping && spanAffectsWrapping(text, i)) {
4223
4242
  builder.pre.appendChild(elt("wbr"));
4224
4243
  }
4225
4244
  var span = builder.measure[builder.pos] =
@@ -4518,6 +4537,7 @@ window.CodeMirror = (function() {
4518
4537
  };
4519
4538
 
4520
4539
  Doc.prototype = createObj(BranchChunk.prototype, {
4540
+ constructor: Doc,
4521
4541
  iter: function(from, to, op) {
4522
4542
  if (op) this.iterN(from - this.first, to - from, op);
4523
4543
  else this.iterN(this.first, this.first + this.size, from);
@@ -5182,7 +5202,7 @@ window.CodeMirror = (function() {
5182
5202
  return function(){return f.apply(null, args);};
5183
5203
  }
5184
5204
 
5185
- var nonASCIISingleCaseWordChar = /[\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc]/;
5205
+ var nonASCIISingleCaseWordChar = /[\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
5186
5206
  function isWordChar(ch) {
5187
5207
  return /\w/.test(ch) || ch > "\x80" &&
5188
5208
  (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
@@ -5243,13 +5263,24 @@ window.CodeMirror = (function() {
5243
5263
  // word wrapping between certain characters *only* if a new inline
5244
5264
  // element is started between them. This makes it hard to reliably
5245
5265
  // measure the position of things, since that requires inserting an
5246
- // extra span. This terribly fragile set of regexps matches the
5266
+ // extra span. This terribly fragile set of tests matches the
5247
5267
  // character combinations that suffer from this phenomenon on the
5248
5268
  // various browsers.
5249
- var spanAffectsWrapping = /^$/; // Won't match any two-character string
5250
- if (gecko) spanAffectsWrapping = /$'/;
5251
- else if (safari && !/Version\/([6-9]|\d\d)\b/.test(navigator.userAgent)) spanAffectsWrapping = /\-[^ \-?]|\?[^ !'\"\),.\-\/:;\?\]\}]/;
5252
- else if (webkit) spanAffectsWrapping = /[~!#%&*)=+}\]|\"\.>,:;][({[<]|-[^\-?\.]|\?[\w~`@#$%\^&*(_=+{[|><]/;
5269
+ function spanAffectsWrapping() { return false; }
5270
+ if (gecko) // Only for "$'"
5271
+ spanAffectsWrapping = function(str, i) {
5272
+ return str.charCodeAt(i - 1) == 36 && str.charCodeAt(i) == 39;
5273
+ };
5274
+ else if (safari && !/Version\/([6-9]|\d\d)\b/.test(navigator.userAgent))
5275
+ spanAffectsWrapping = function(str, i) {
5276
+ return /\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}]/.test(str.slice(i - 1, i + 1));
5277
+ };
5278
+ else if (webkit)
5279
+ spanAffectsWrapping = function(str, i) {
5280
+ if (i > 1 && str.charCodeAt(i - 1) == 45 && /\w/.test(str.charAt(i - 2)) && /[^\-?\.]/.test(str.charAt(i)))
5281
+ return true;
5282
+ return /[~!#%&*)=+}\]|\"\.>,:;][({[<]|\?[\w~`@#$%\^&*(_=+{[|><]/.test(str.slice(i - 1, i + 1));
5283
+ };
5253
5284
 
5254
5285
  var knownScrollbarWidth;
5255
5286
  function scrollbarWidth(measure) {
@@ -5368,6 +5399,40 @@ window.CodeMirror = (function() {
5368
5399
  return Pos(lineN, ch);
5369
5400
  }
5370
5401
 
5402
+ function compareBidiLevel(order, a, b) {
5403
+ var linedir = order[0].level;
5404
+ if (a == linedir) return true;
5405
+ if (b == linedir) return false;
5406
+ return a < b;
5407
+ }
5408
+ var bidiOther;
5409
+ function getBidiPartAt(order, pos) {
5410
+ for (var i = 0, found; i < order.length; ++i) {
5411
+ var cur = order[i];
5412
+ if (cur.from < pos && cur.to > pos) { bidiOther = null; return i; }
5413
+ if (cur.from == pos || cur.to == pos) {
5414
+ if (found == null) {
5415
+ found = i;
5416
+ } else if (compareBidiLevel(order, cur.level, order[found].level)) {
5417
+ bidiOther = found;
5418
+ return i;
5419
+ } else {
5420
+ bidiOther = i;
5421
+ return found;
5422
+ }
5423
+ }
5424
+ }
5425
+ bidiOther = null;
5426
+ return found;
5427
+ }
5428
+
5429
+ function moveInLine(line, pos, dir, byUnit) {
5430
+ if (!byUnit) return pos + dir;
5431
+ do pos += dir;
5432
+ while (pos > 0 && isExtendingChar.test(line.text.charAt(pos)));
5433
+ return pos;
5434
+ }
5435
+
5371
5436
  // This is somewhat involved. It is needed in order to move
5372
5437
  // 'visually' through bi-directional text -- i.e., pressing left
5373
5438
  // should make the cursor go left, even when in RTL text. The
@@ -5377,37 +5442,24 @@ window.CodeMirror = (function() {
5377
5442
  function moveVisually(line, start, dir, byUnit) {
5378
5443
  var bidi = getOrder(line);
5379
5444
  if (!bidi) return moveLogically(line, start, dir, byUnit);
5380
- var moveOneUnit = byUnit ? function(pos, dir) {
5381
- do pos += dir;
5382
- while (pos > 0 && isExtendingChar.test(line.text.charAt(pos)));
5383
- return pos;
5384
- } : function(pos, dir) { return pos + dir; };
5385
- var linedir = bidi[0].level;
5386
- for (var i = 0; i < bidi.length; ++i) {
5387
- var part = bidi[i], sticky = part.level % 2 == linedir;
5388
- if ((part.from < start && part.to > start) ||
5389
- (sticky && (part.from == start || part.to == start))) break;
5390
- }
5391
- var target = moveOneUnit(start, part.level % 2 ? -dir : dir);
5392
-
5393
- while (target != null) {
5394
- if (part.level % 2 == linedir) {
5395
- if (target < part.from || target > part.to) {
5396
- part = bidi[i += dir];
5397
- target = part && (dir > 0 == part.level % 2 ? moveOneUnit(part.to, -1) : moveOneUnit(part.from, 1));
5398
- } else break;
5445
+ var pos = getBidiPartAt(bidi, start), part = bidi[pos];
5446
+ var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit);
5447
+
5448
+ for (;;) {
5449
+ if (target > part.from && target < part.to) return target;
5450
+ if (target == part.from || target == part.to) {
5451
+ if (getBidiPartAt(bidi, target) == pos) return target;
5452
+ part = bidi[pos += dir];
5453
+ return (dir > 0) == part.level % 2 ? part.to : part.from;
5399
5454
  } else {
5400
- if (target == bidiLeft(part)) {
5401
- part = bidi[--i];
5402
- target = part && bidiRight(part);
5403
- } else if (target == bidiRight(part)) {
5404
- part = bidi[++i];
5405
- target = part && bidiLeft(part);
5406
- } else break;
5455
+ part = bidi[pos += dir];
5456
+ if (!part) return null;
5457
+ if ((dir > 0) == part.level % 2)
5458
+ target = moveInLine(line, part.to, -1, byUnit);
5459
+ else
5460
+ target = moveInLine(line, part.from, 1, byUnit);
5407
5461
  }
5408
5462
  }
5409
-
5410
- return target < 0 || target > line.text.length ? null : target;
5411
5463
  }
5412
5464
 
5413
5465
  function moveLogically(line, start, dir, byUnit) {
@@ -5579,7 +5631,7 @@ window.CodeMirror = (function() {
5579
5631
 
5580
5632
  // THE END
5581
5633
 
5582
- CodeMirror.version = "3.12";
5634
+ CodeMirror.version = "3.13";
5583
5635
 
5584
5636
  return CodeMirror;
5585
5637
  })();