codemirror-rails 3.16 → 3.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -0
  3. data/lib/codemirror/rails/version.rb +2 -2
  4. data/vendor/assets/javascripts/codemirror.js +104 -48
  5. data/vendor/assets/javascripts/codemirror/addons/comment/continuecomment.js +25 -15
  6. data/vendor/assets/javascripts/codemirror/addons/edit/closetag.js +28 -27
  7. data/vendor/assets/javascripts/codemirror/addons/edit/matchtags.js +10 -5
  8. data/vendor/assets/javascripts/codemirror/addons/hint/css-hint.js +50 -0
  9. data/vendor/assets/javascripts/codemirror/addons/hint/html-hint.js +0 -0
  10. data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +10 -7
  11. data/vendor/assets/javascripts/codemirror/addons/lint/css-lint.js +17 -0
  12. data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +1 -1
  13. data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +32 -6
  14. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode-standalone.js +1 -1
  15. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.js +1 -1
  16. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +1 -1
  17. data/vendor/assets/javascripts/codemirror/addons/search/searchcursor.js +2 -2
  18. data/vendor/assets/javascripts/codemirror/addons/tern/tern.js +29 -6
  19. data/vendor/assets/javascripts/codemirror/keymaps/vim.js +13 -0
  20. data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +1 -1
  21. data/vendor/assets/javascripts/codemirror/modes/css.js +15 -13
  22. data/vendor/assets/javascripts/codemirror/modes/d.js +0 -0
  23. data/vendor/assets/javascripts/codemirror/modes/dtd.js +127 -0
  24. data/vendor/assets/javascripts/codemirror/modes/fortran.js +173 -0
  25. data/vendor/assets/javascripts/codemirror/modes/haskell.js +5 -1
  26. data/vendor/assets/javascripts/codemirror/modes/less.js +47 -49
  27. data/vendor/assets/javascripts/codemirror/modes/octave.js +118 -0
  28. data/vendor/assets/javascripts/codemirror/modes/sql.js +8 -5
  29. data/vendor/assets/javascripts/codemirror/modes/toml.js +71 -0
  30. data/vendor/assets/stylesheets/codemirror.css +7 -3
  31. data/vendor/assets/stylesheets/codemirror/addons/display/fullscreen.css +1 -1
  32. data/vendor/assets/stylesheets/codemirror/addons/lint/lint.css +3 -27
  33. data/vendor/assets/stylesheets/codemirror/themes/solarized.css +2 -24
  34. metadata +24 -21
  35. data/vendor/assets/javascripts/codemirror/addons/edit/continuecomment.js +0 -44
  36. data/vendor/assets/javascripts/codemirror/addons/merge/dep/diff_match_patch.js +0 -50
  37. data/vendor/assets/javascripts/codemirror/modes/scss_test.js +0 -80
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a097dd836952a9d7016ff82994bb2cf95bf08c5
4
- data.tar.gz: b9217b3006c879ae8e9df6feee1abffdd92ab939
3
+ metadata.gz: fcaf99c9b9c190aac2de9f68cf058ec3e82d265e
4
+ data.tar.gz: ba0b7668f1502e7e13b6de64a35abf984d910070
5
5
  SHA512:
6
- metadata.gz: 29a02c78ca161d4b336e380ebfcd633a125f213efb655bf7c49a1bd48755458d572f7dd45094382930004a120d0a612478d9c7ba01cdae9e8732f3e7511d010b
7
- data.tar.gz: 8e45db94d110041b68a8c9649b88edd7f1ed11cb045a80b5f9bc2e8de6f6a39690bc994a906bae7f65831959d7f84a28f8495f58082095277790127e4d5c03b8
6
+ metadata.gz: 6eb46499bbe5f971c6349a02248de371288b69be40f59a7d2e591d32b2288b864542152cc3aa55ccdd87e16f299fb4a4e1554299a714a73d9361be56e99a0476
7
+ data.tar.gz: 225e6fe1d5a6ef50d703323bd19c15f36ab22ad7f5574745e2b960908938eb74a5065fa2d2c88c302d6d24350c9b037dfd3f1a6956d0f2493e60c07c476a1bb6
data/README.md CHANGED
@@ -59,6 +59,15 @@ Additional CSS themes can be added to your application.css
59
59
  //= require codemirror/themes/night
60
60
  ```
61
61
 
62
+ ### Precompiling Codemirror
63
+
64
+ If your project is using precompiling, depending on your method of grabbing files to precompile, you might need to add the below line to your ```` application.rb```, to get rails to precompile all js, css files used by codemirror. You can also manually whitelist only the files that you use.
65
+
66
+ ```rb
67
+ config.assets.precompile += ["codemirror*", "codemirror/**/*"]
68
+ ```
69
+
70
+
62
71
  ## CodeMirror for Rails 3
63
72
 
64
73
  You can use the generator included with this gem to copy the CodeMirror 2
@@ -1,6 +1,6 @@
1
1
  module Codemirror
2
2
  module Rails
3
- VERSION = '3.16'
4
- CODEMIRROR_VERSION = '3.16'
3
+ VERSION = '3.17'
4
+ CODEMIRROR_VERSION = '3.17'
5
5
  end
6
6
  end
@@ -1,5 +1,3 @@
1
- // CodeMirror version 3.16
2
- //
3
1
  // CodeMirror is the only global var we claim
4
2
  window.CodeMirror = (function() {
5
3
  "use strict";
@@ -306,15 +304,13 @@ window.CodeMirror = (function() {
306
304
  // Make sure the gutters options contains the element
307
305
  // "CodeMirror-linenumbers" when the lineNumbers option is true.
308
306
  function setGuttersForLineNumbers(options) {
309
- var found = false;
310
- for (var i = 0; i < options.gutters.length; ++i) {
311
- if (options.gutters[i] == "CodeMirror-linenumbers") {
312
- if (options.lineNumbers) found = true;
313
- else options.gutters.splice(i--, 1);
314
- }
307
+ var found = indexOf(options.gutters, "CodeMirror-linenumbers");
308
+ if (found == -1 && options.lineNumbers) {
309
+ options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
310
+ } else if (found > -1 && !options.lineNumbers) {
311
+ options.gutters = options.gutters.slice(0);
312
+ options.gutters.splice(i, 1);
315
313
  }
316
- if (!found && options.lineNumbers)
317
- options.gutters.push("CodeMirror-linenumbers");
318
314
  }
319
315
 
320
316
  // SCROLLBARS
@@ -413,12 +409,18 @@ window.CodeMirror = (function() {
413
409
  function updateDisplay(cm, changes, viewPort, forced) {
414
410
  var oldFrom = cm.display.showingFrom, oldTo = cm.display.showingTo, updated;
415
411
  var visible = visibleLines(cm.display, cm.doc, viewPort);
416
- for (;;) {
412
+ for (var first = true;; first = false) {
413
+ var oldWidth = cm.display.scroller.clientWidth;
417
414
  if (!updateDisplayInner(cm, changes, visible, forced)) break;
418
- forced = false;
419
415
  updated = true;
416
+ changes = [];
420
417
  updateSelection(cm);
421
418
  updateScrollbars(cm);
419
+ if (first && cm.options.lineWrapping && oldWidth != cm.display.scroller.clientWidth) {
420
+ forced = true;
421
+ continue;
422
+ }
423
+ forced = false;
422
424
 
423
425
  // Clip forced viewport to actual scrollable area
424
426
  if (viewPort)
@@ -427,7 +429,6 @@ window.CodeMirror = (function() {
427
429
  visible = visibleLines(cm.display, cm.doc, viewPort);
428
430
  if (visible.from >= cm.display.showingFrom && visible.to <= cm.display.showingTo)
429
431
  break;
430
- changes = [];
431
432
  }
432
433
 
433
434
  if (updated) {
@@ -665,10 +666,11 @@ window.CodeMirror = (function() {
665
666
  }
666
667
 
667
668
  function buildLineElement(cm, line, lineNo, dims, reuse) {
668
- var lineElement = lineContent(cm, line);
669
+ var built = buildLineContent(cm, line), lineElement = built.pre;
669
670
  var markers = line.gutterMarkers, display = cm.display, wrap;
670
671
 
671
- if (!cm.options.lineNumbers && !markers && !line.bgClass && !line.wrapClass && !line.widgets)
672
+ var bgClass = built.bgClass ? built.bgClass + " " + (line.bgClass || "") : line.bgClass;
673
+ if (!cm.options.lineNumbers && !markers && !bgClass && !line.wrapClass && !line.widgets)
672
674
  return lineElement;
673
675
 
674
676
  // Lines with gutter elements, widgets or a background class need
@@ -706,8 +708,8 @@ window.CodeMirror = (function() {
706
708
  wrap.appendChild(lineElement);
707
709
  }
708
710
  // Kludge to make sure the styled element lies behind the selection (by z-index)
709
- if (line.bgClass)
710
- wrap.insertBefore(elt("div", null, line.bgClass + " CodeMirror-linebackground"), wrap.firstChild);
711
+ if (bgClass)
712
+ wrap.insertBefore(elt("div", null, bgClass + " CodeMirror-linebackground"), wrap.firstChild);
711
713
  if (cm.options.lineNumbers || markers) {
712
714
  var gutterWrap = wrap.insertBefore(elt("div", null, null, "position: absolute; left: " +
713
715
  (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"),
@@ -974,6 +976,10 @@ window.CodeMirror = (function() {
974
976
  function measureChar(cm, line, ch, data, bias) {
975
977
  var dir = -1;
976
978
  data = data || measureLine(cm, line);
979
+ if (data.crude) {
980
+ var left = data.left + ch * data.width;
981
+ return {left: left, right: left + data.width, top: data.top, bottom: data.bottom};
982
+ }
977
983
 
978
984
  for (var pos = ch;; pos += dir) {
979
985
  var r = data[pos];
@@ -995,7 +1001,7 @@ window.CodeMirror = (function() {
995
1001
  var memo = cache[i];
996
1002
  if (memo.text == line.text && memo.markedSpans == line.markedSpans &&
997
1003
  cm.display.scroller.clientWidth == memo.width &&
998
- memo.classes == line.textClass + "|" + line.bgClass + "|" + line.wrapClass)
1004
+ memo.classes == line.textClass + "|" + line.wrapClass)
999
1005
  return memo;
1000
1006
  }
1001
1007
  }
@@ -1015,15 +1021,18 @@ window.CodeMirror = (function() {
1015
1021
  var cache = cm.display.measureLineCache;
1016
1022
  var memo = {text: line.text, width: cm.display.scroller.clientWidth,
1017
1023
  markedSpans: line.markedSpans, measure: measure,
1018
- classes: line.textClass + "|" + line.bgClass + "|" + line.wrapClass};
1024
+ classes: line.textClass + "|" + line.wrapClass};
1019
1025
  if (cache.length == 16) cache[++cm.display.measureLineCachePos % 16] = memo;
1020
1026
  else cache.push(memo);
1021
1027
  return measure;
1022
1028
  }
1023
1029
 
1024
1030
  function measureLineInner(cm, line) {
1031
+ if (!cm.options.lineWrapping && line.text.length >= cm.options.crudeMeasuringFrom)
1032
+ return crudelyMeasureLine(cm, line);
1033
+
1025
1034
  var display = cm.display, measure = emptyArray(line.text.length);
1026
- var pre = lineContent(cm, line, measure, true);
1035
+ var pre = buildLineContent(cm, line, measure, true).pre;
1027
1036
 
1028
1037
  // IE does not cache element positions of inline elements between
1029
1038
  // calls to getBoundingClientRect. This makes the loop below,
@@ -1108,6 +1117,15 @@ window.CodeMirror = (function() {
1108
1117
  return data;
1109
1118
  }
1110
1119
 
1120
+ function crudelyMeasureLine(cm, line) {
1121
+ var copy = new Line(line.text.slice(0, 100), null);
1122
+ if (line.textClass) copy.textClass = line.textClass;
1123
+ var measure = measureLineInner(cm, copy);
1124
+ var left = measureChar(cm, copy, 0, measure, "left");
1125
+ var right = measureChar(cm, copy, 99, measure, "right");
1126
+ return {crude: true, top: left.top, left: left.left, bottom: left.bottom, width: (right.right - left.left) / 100};
1127
+ }
1128
+
1111
1129
  function measureLineWidth(cm, line) {
1112
1130
  var hasBadSpan = false;
1113
1131
  if (line.markedSpans) for (var i = 0; i < line.markedSpans; ++i) {
@@ -1115,9 +1133,10 @@ window.CodeMirror = (function() {
1115
1133
  if (sp.collapsed && (sp.to == null || sp.to == line.text.length)) hasBadSpan = true;
1116
1134
  }
1117
1135
  var cached = !hasBadSpan && findCachedMeasurement(cm, line);
1118
- if (cached) return measureChar(cm, line, line.text.length, cached.measure, "right").right;
1136
+ if (cached || line.text.length >= cm.options.crudeMeasuringFrom)
1137
+ return measureChar(cm, line, line.text.length, cached && cached.measure, "right").right;
1119
1138
 
1120
- var pre = lineContent(cm, line, null, true);
1139
+ var pre = buildLineContent(cm, line, null, true).pre;
1121
1140
  var end = pre.appendChild(zeroWidthElement(cm.display.measure));
1122
1141
  removeChildrenAndAdd(cm.display.measure, pre);
1123
1142
  return getRect(end).right - getRect(cm.display.lineDiv).left;
@@ -1586,7 +1605,10 @@ window.CodeMirror = (function() {
1586
1605
  if (signalDOMEvent(cm, e) || cm.options.onKeyEvent && cm.options.onKeyEvent(cm, addStop(e))) return;
1587
1606
  if (e.keyCode == 16) cm.doc.sel.shift = false;
1588
1607
  }));
1589
- on(d.input, "input", bind(fastPoll, cm));
1608
+ on(d.input, "input", function() {
1609
+ if (ie && !ie_lt9 && cm.display.inputHasSelection) cm.display.inputHasSelection = null;
1610
+ fastPoll(cm);
1611
+ });
1590
1612
  on(d.input, "keydown", operation(cm, onKeyDown));
1591
1613
  on(d.input, "keypress", operation(cm, onKeyPress));
1592
1614
  on(d.input, "focus", bind(onFocus, cm));
@@ -1802,17 +1824,16 @@ window.CodeMirror = (function() {
1802
1824
  on(document, "mouseup", up);
1803
1825
  }
1804
1826
 
1805
- function clickInGutter(cm, e) {
1806
- var display = cm.display;
1827
+ function gutterEvent(cm, e, type, prevent, signalfn) {
1807
1828
  try { var mX = e.clientX, mY = e.clientY; }
1808
1829
  catch(e) { return false; }
1830
+ if (mX >= Math.floor(getRect(cm.display.gutters).right)) return false;
1831
+ if (prevent) e_preventDefault(e);
1809
1832
 
1810
- if (mX >= Math.floor(getRect(display.gutters).right)) return false;
1811
- e_preventDefault(e);
1812
- if (!hasHandler(cm, "gutterClick")) return true;
1813
-
1833
+ var display = cm.display;
1814
1834
  var lineBox = getRect(display.lineDiv);
1815
- if (mY > lineBox.bottom) return true;
1835
+
1836
+ if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e);
1816
1837
  mY -= lineBox.top - display.viewOffset;
1817
1838
 
1818
1839
  for (var i = 0; i < cm.options.gutters.length; ++i) {
@@ -1820,11 +1841,19 @@ window.CodeMirror = (function() {
1820
1841
  if (g && getRect(g).right >= mX) {
1821
1842
  var line = lineAtHeight(cm.doc, mY);
1822
1843
  var gutter = cm.options.gutters[i];
1823
- signalLater(cm, "gutterClick", cm, line, gutter, e);
1824
- break;
1844
+ signalfn(cm, type, cm, line, gutter, e);
1845
+ return e_defaultPrevented(e);
1825
1846
  }
1826
1847
  }
1827
- return true;
1848
+ }
1849
+
1850
+ function contextMenuInGutter(cm, e) {
1851
+ if (!hasHandler(cm, "gutterContextMenu")) return false;
1852
+ return gutterEvent(cm, e, "gutterContextMenu", false, signal);
1853
+ }
1854
+
1855
+ function clickInGutter(cm, e) {
1856
+ return gutterEvent(cm, e, "gutterClick", true, signalLater);
1828
1857
  }
1829
1858
 
1830
1859
  // Kludge to work around strange IE behavior where it'll sometimes
@@ -1887,6 +1916,7 @@ window.CodeMirror = (function() {
1887
1916
  // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
1888
1917
  if (e.dataTransfer.setDragImage && !safari) {
1889
1918
  var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
1919
+ img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
1890
1920
  if (opera) {
1891
1921
  img.width = img.height = 1;
1892
1922
  cm.display.wrapper.appendChild(img);
@@ -2145,7 +2175,7 @@ window.CodeMirror = (function() {
2145
2175
  function onContextMenu(cm, e) {
2146
2176
  if (signalDOMEvent(cm, e, "contextmenu")) return;
2147
2177
  var display = cm.display, sel = cm.doc.sel;
2148
- if (eventInWidget(display, e)) return;
2178
+ if (eventInWidget(display, e) || contextMenuInGutter(cm, e)) return;
2149
2179
 
2150
2180
  var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
2151
2181
  if (!pos || opera) return; // Opera is difficult.
@@ -2164,8 +2194,8 @@ window.CodeMirror = (function() {
2164
2194
 
2165
2195
  function prepareSelectAllHack() {
2166
2196
  if (display.input.selectionStart != null) {
2167
- var extval = display.input.value = " " + (posEq(sel.from, sel.to) ? "" : display.input.value);
2168
- display.prevInput = " ";
2197
+ var extval = display.input.value = "\u200b" + (posEq(sel.from, sel.to) ? "" : display.input.value);
2198
+ display.prevInput = "\u200b";
2169
2199
  display.input.selectionStart = 1; display.input.selectionEnd = extval.length;
2170
2200
  }
2171
2201
  }
@@ -2299,6 +2329,7 @@ window.CodeMirror = (function() {
2299
2329
  }
2300
2330
 
2301
2331
  function makeChangeNoReadonly(doc, change, selUpdate) {
2332
+ if (change.text.length == 1 && change.text[0] == "" && posEq(change.from, change.to)) return;
2302
2333
  var selAfter = computeSelAfterChange(doc, change, selUpdate);
2303
2334
  addToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
2304
2335
 
@@ -2521,6 +2552,7 @@ window.CodeMirror = (function() {
2521
2552
 
2522
2553
  var sel = doc.sel;
2523
2554
  sel.goalColumn = null;
2555
+ if (bias == null) bias = posLess(head, sel.head) ? -1 : 1;
2524
2556
  // Skip over atomic spans.
2525
2557
  if (checkAtomic || !posEq(anchor, sel.anchor))
2526
2558
  anchor = skipAtomic(doc, anchor, bias, checkAtomic != "push");
@@ -3165,9 +3197,11 @@ window.CodeMirror = (function() {
3165
3197
  operation: function(f){return runInOp(this, f);},
3166
3198
 
3167
3199
  refresh: operation(null, function() {
3200
+ var badHeight = this.display.cachedTextHeight == null;
3168
3201
  clearCaches(this);
3169
3202
  updateScrollPos(this, this.doc.scrollLeft, this.doc.scrollTop);
3170
3203
  regChange(this);
3204
+ if (badHeight) estimateLineHeights(this);
3171
3205
  }),
3172
3206
 
3173
3207
  swapDoc: operation(null, function(doc) {
@@ -3268,6 +3302,7 @@ window.CodeMirror = (function() {
3268
3302
  option("historyEventDelay", 500);
3269
3303
  option("viewportMargin", 10, function(cm){cm.refresh();}, true);
3270
3304
  option("maxHighlightLength", 10000, function(cm){loadMode(cm); cm.refresh();}, true);
3305
+ option("crudeMeasuringFrom", 10000);
3271
3306
  option("moveInputWithCursor", true, function(cm, val) {
3272
3307
  if (!val) cm.display.inputDiv.style.top = cm.display.inputDiv.style.left = 0;
3273
3308
  });
@@ -4210,8 +4245,7 @@ window.CodeMirror = (function() {
4210
4245
  while (!stream.eol()) {
4211
4246
  if (stream.pos > cm.options.maxHighlightLength) {
4212
4247
  flattenSpans = false;
4213
- // Webkit seems to refuse to render text nodes longer than 57444 characters
4214
- stream.pos = Math.min(text.length, stream.start + 50000);
4248
+ stream.pos = text.length;
4215
4249
  style = null;
4216
4250
  } else {
4217
4251
  style = mode.token(stream, state);
@@ -4222,7 +4256,12 @@ window.CodeMirror = (function() {
4222
4256
  }
4223
4257
  stream.start = stream.pos;
4224
4258
  }
4225
- if (curStart < stream.pos) f(stream.pos, curStyle);
4259
+ while (curStart < stream.pos) {
4260
+ // Webkit seems to refuse to render text nodes longer than 57444 characters
4261
+ var pos = Math.min(stream.pos, curStart + 50000);
4262
+ f(pos, curStyle);
4263
+ curStart = pos;
4264
+ }
4226
4265
  }
4227
4266
 
4228
4267
  function highlightLine(cm, line, state) {
@@ -4280,13 +4319,23 @@ window.CodeMirror = (function() {
4280
4319
  }
4281
4320
 
4282
4321
  var styleToClassCache = {};
4283
- function styleToClass(style) {
4322
+ function interpretTokenStyle(style, builder) {
4284
4323
  if (!style) return null;
4324
+ for (;;) {
4325
+ var lineClass = style.match(/(?:^|\s)line-(background-)?(\S+)/);
4326
+ if (!lineClass) break;
4327
+ style = style.slice(0, lineClass.index) + style.slice(lineClass.index + lineClass[0].length);
4328
+ var prop = lineClass[1] ? "bgClass" : "textClass";
4329
+ if (builder[prop] == null)
4330
+ builder[prop] = lineClass[2];
4331
+ else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(builder[prop]))
4332
+ builder[prop] += " " + lineClass[2];
4333
+ }
4285
4334
  return styleToClassCache[style] ||
4286
4335
  (styleToClassCache[style] = "cm-" + style.replace(/ +/g, " cm-"));
4287
4336
  }
4288
4337
 
4289
- function lineContent(cm, realLine, measure, copyWidgets) {
4338
+ function buildLineContent(cm, realLine, measure, copyWidgets) {
4290
4339
  var merged, line = realLine, empty = true;
4291
4340
  while (merged = collapsedSpanAtStart(line))
4292
4341
  line = getLine(cm.doc, merged.find().from.line);
@@ -4294,7 +4343,6 @@ window.CodeMirror = (function() {
4294
4343
  var builder = {pre: elt("pre"), col: 0, pos: 0,
4295
4344
  measure: null, measuredSomething: false, cm: cm,
4296
4345
  copyWidgets: copyWidgets};
4297
- if (line.textClass) builder.pre.className = line.textClass;
4298
4346
 
4299
4347
  do {
4300
4348
  if (line.text) empty = false;
@@ -4331,8 +4379,11 @@ window.CodeMirror = (function() {
4331
4379
  }
4332
4380
  }
4333
4381
 
4382
+ var textClass = builder.textClass ? builder.textClass + " " + (realLine.textClass || "") : realLine.textClass;
4383
+ if (textClass) builder.pre.className = textClass;
4384
+
4334
4385
  signal(cm, "renderLine", cm, realLine, builder.pre);
4335
- return builder.pre;
4386
+ return builder;
4336
4387
  }
4337
4388
 
4338
4389
  var tokenSpecialChars = /[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\uFEFF]/g;
@@ -4443,7 +4494,7 @@ window.CodeMirror = (function() {
4443
4494
  var spans = line.markedSpans, allText = line.text, at = 0;
4444
4495
  if (!spans) {
4445
4496
  for (var i = 1; i < styles.length; i+=2)
4446
- builder.addToken(builder, allText.slice(at, at = styles[i]), styleToClass(styles[i+1]));
4497
+ builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder));
4447
4498
  return;
4448
4499
  }
4449
4500
 
@@ -4493,7 +4544,7 @@ window.CodeMirror = (function() {
4493
4544
  spanStartStyle = "";
4494
4545
  }
4495
4546
  text = allText.slice(at, at = styles[i++]);
4496
- style = styleToClass(styles[i++]);
4547
+ style = interpretTokenStyle(styles[i++], builder);
4497
4548
  }
4498
4549
  }
4499
4550
  }
@@ -5461,13 +5512,18 @@ window.CodeMirror = (function() {
5461
5512
  spanAffectsWrapping = function(str, i) {
5462
5513
  return /\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}]/.test(str.slice(i - 1, i + 1));
5463
5514
  };
5464
- else if (webkit && !/Chrome\/(?:29|[3-9]\d|\d\d\d)\./.test(navigator.userAgent))
5515
+ else if (webkit && /Chrome\/(?:29|[3-9]\d|\d\d\d)\./.test(navigator.userAgent))
5516
+ spanAffectsWrapping = function(str, i) {
5517
+ var code = str.charCodeAt(i - 1);
5518
+ return code >= 8208 && code <= 8212;
5519
+ };
5520
+ else if (webkit)
5465
5521
  spanAffectsWrapping = function(str, i) {
5466
5522
  if (i > 1 && str.charCodeAt(i - 1) == 45) {
5467
5523
  if (/\w/.test(str.charAt(i - 2)) && /[^\-?\.]/.test(str.charAt(i))) return true;
5468
5524
  if (i > 2 && /[\d\.,]/.test(str.charAt(i - 2)) && /[\d\.,]/.test(str.charAt(i))) return false;
5469
5525
  }
5470
- return /[~!#%&*)=+}\]|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^&*(_=+{[|><]|…[\w~`@#$%\^&*(_=+{[><]/.test(str.slice(i - 1, i + 1));
5526
+ return /[~!#%&*)=+}\]\\|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^&*(_=+{[|><]|…[\w~`@#$%\^&*(_=+{[><]/.test(str.slice(i - 1, i + 1));
5471
5527
  };
5472
5528
 
5473
5529
  var knownScrollbarWidth;
@@ -5823,7 +5879,7 @@ window.CodeMirror = (function() {
5823
5879
 
5824
5880
  // THE END
5825
5881
 
5826
- CodeMirror.version = "3.16.0";
5882
+ CodeMirror.version = "3.17.0";
5827
5883
 
5828
5884
  return CodeMirror;
5829
5885
  })();
@@ -1,35 +1,43 @@
1
1
  (function() {
2
2
  var modes = ["clike", "css", "javascript"];
3
3
  for (var i = 0; i < modes.length; ++i)
4
- CodeMirror.extendMode(modes[i], {blockCommentStart: "/*",
5
- blockCommentEnd: "*/",
6
- blockCommentContinue: " * "});
4
+ CodeMirror.extendMode(modes[i], {blockCommentContinue: " * "});
7
5
 
8
6
  function continueComment(cm) {
9
7
  var pos = cm.getCursor(), token = cm.getTokenAt(pos);
8
+ if (token.type != "comment") return CodeMirror.Pass;
10
9
  var mode = CodeMirror.innerMode(cm.getMode(), token.state).mode;
11
- var space;
12
10
 
13
- if (token.type == "comment" && mode.blockCommentStart && mode.blockCommentContinue) {
11
+ var insert;
12
+ if (mode.blockCommentStart && mode.blockCommentContinue) {
14
13
  var end = token.string.indexOf(mode.blockCommentEnd);
15
14
  var full = cm.getRange(CodeMirror.Pos(pos.line, 0), CodeMirror.Pos(pos.line, token.end)), found;
16
15
  if (end != -1 && end == token.string.length - mode.blockCommentEnd.length) {
17
16
  // Comment ended, don't continue it
18
17
  } else if (token.string.indexOf(mode.blockCommentStart) == 0) {
19
- space = full.slice(0, token.start);
20
- if (!/^\s*$/.test(space)) {
21
- space = "";
22
- for (var i = 0; i < token.start; ++i) space += " ";
18
+ insert = full.slice(0, token.start);
19
+ if (!/^\s*$/.test(insert)) {
20
+ insert = "";
21
+ for (var i = 0; i < token.start; ++i) insert += " ";
23
22
  }
24
23
  } else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
25
24
  found + mode.blockCommentContinue.length > token.start &&
26
25
  /^\s*$/.test(full.slice(0, found))) {
27
- space = full.slice(0, found);
26
+ insert = full.slice(0, found);
27
+ }
28
+ if (insert != null) insert += mode.blockCommentContinue;
29
+ }
30
+ if (insert == null && mode.lineComment) {
31
+ var line = cm.getLine(pos.line), found = line.indexOf(mode.lineComment);
32
+ if (found > -1) {
33
+ insert = line.slice(0, found);
34
+ if (/\S/.test(insert)) insert = null;
35
+ else insert += mode.lineComment + line.slice(found + mode.lineComment.length).match(/^\s*/)[0];
28
36
  }
29
37
  }
30
38
 
31
- if (space != null)
32
- cm.replaceSelection("\n" + space + mode.blockCommentContinue, "end");
39
+ if (insert != null)
40
+ cm.replaceSelection("\n" + insert, "end");
33
41
  else
34
42
  return CodeMirror.Pass;
35
43
  }
@@ -37,8 +45,10 @@
37
45
  CodeMirror.defineOption("continueComments", null, function(cm, val, prev) {
38
46
  if (prev && prev != CodeMirror.Init)
39
47
  cm.removeKeyMap("continueComment");
40
- var map = {name: "continueComment"};
41
- map[typeof val == "string" ? val : "Enter"] = continueComment;
42
- cm.addKeyMap(map);
48
+ if (val) {
49
+ var map = {name: "continueComment"};
50
+ map[typeof val == "string" ? val : "Enter"] = continueComment;
51
+ cm.addKeyMap(map);
52
+ }
43
53
  });
44
54
  })();