codemirror-rails 5.12 → 5.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/lib/codemirror/rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/codemirror.js +16 -13
  4. data/vendor/assets/javascripts/codemirror/addons/display/placeholder.js +2 -0
  5. data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +9 -2
  6. data/vendor/assets/javascripts/codemirror/addons/hint/sql-hint.js +42 -15
  7. data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +11 -4
  8. data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +3 -3
  9. data/vendor/assets/javascripts/codemirror/addons/scroll/simplescrollbars.js +10 -8
  10. data/vendor/assets/javascripts/codemirror/keymaps/vim.js +8 -7
  11. data/vendor/assets/javascripts/codemirror/modes/clike.js +1 -1
  12. data/vendor/assets/javascripts/codemirror/modes/clojure.js +1 -0
  13. data/vendor/assets/javascripts/codemirror/modes/dart.js +27 -0
  14. data/vendor/assets/javascripts/codemirror/modes/dylan.js +69 -16
  15. data/vendor/assets/javascripts/codemirror/modes/haskell-literate.js +1 -1
  16. data/vendor/assets/javascripts/codemirror/modes/jsx.js +3 -3
  17. data/vendor/assets/javascripts/codemirror/modes/markdown.js +16 -11
  18. data/vendor/assets/javascripts/codemirror/modes/protobuf.js +68 -0
  19. data/vendor/assets/javascripts/codemirror/modes/r.js +2 -0
  20. data/vendor/assets/javascripts/codemirror/modes/swift.js +1 -1
  21. data/vendor/assets/javascripts/codemirror/modes/tcl.js +12 -20
  22. data/vendor/assets/javascripts/codemirror/modes/troff.js +3 -1
  23. data/vendor/assets/javascripts/codemirror/modes/twig.js +12 -3
  24. data/vendor/assets/javascripts/codemirror/modes/velocity.js +1 -1
  25. data/vendor/assets/javascripts/codemirror/modes/yaml-frontmatter.js +1 -1
  26. data/vendor/assets/stylesheets/codemirror.css +3 -0
  27. data/vendor/assets/stylesheets/codemirror/themes/night.css +1 -2
  28. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d50c6ae9f3c145c8a536553f00140d330628efd
4
- data.tar.gz: 476404365d720f4980f576d5c838b9aeb3caaf14
3
+ metadata.gz: cfc683c617e825011944a7a5c23d4f5d70261ac4
4
+ data.tar.gz: 365c027102d29e10bef6ffe0bd07f188c59a203b
5
5
  SHA512:
6
- metadata.gz: 1d31e447de612a679ee1313a03d87d0cfed89b43c4ad16287fdd30099835df73969c2688ba31070c0d9c579e6745d415a7737aa796cf8e5e07ca581412a7f554
7
- data.tar.gz: 0d276f0875057e15eb8e429bad6e2e3e5743cb6f243f2f495473f87b30de14b7356dd1141ad724d06a92a1e99403d09dce2c0b2f8885147c096d143cd4714401
6
+ metadata.gz: fba3203eaca8a56a75642cdfe20a5db0b0f4c23bf43e4322eb17f32bd8a48507601a9a346ada5611505cd59768a1aef7b6ba782fbe99f396bc40950b12a867e7
7
+ data.tar.gz: 07c6ec78e6b3f583daae6457d5f61989eec4c1d4f0c96fd4e83c25ef7ac139467ddb8e22b30fde4eb2e4b815fc1bdcdbe3be771005b28d295d6448a524567a7f
@@ -1,6 +1,6 @@
1
1
  module Codemirror
2
2
  module Rails
3
- VERSION = '5.12'
4
- CODEMIRROR_VERSION = '5.12'
3
+ VERSION = '5.13.2'
4
+ CODEMIRROR_VERSION = '5.13.2'
5
5
  end
6
6
  end
@@ -747,6 +747,7 @@
747
747
 
748
748
  function postUpdateDisplay(cm, update) {
749
749
  var viewport = update.viewport;
750
+
750
751
  for (var first = true;; first = false) {
751
752
  if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
752
753
  // Clip forced viewport to actual scrollable area.
@@ -762,8 +763,8 @@
762
763
  updateHeightsInViewport(cm);
763
764
  var barMeasure = measureForScrollbars(cm);
764
765
  updateSelection(cm);
765
- setDocumentHeight(cm, barMeasure);
766
766
  updateScrollbars(cm, barMeasure);
767
+ setDocumentHeight(cm, barMeasure);
767
768
  }
768
769
 
769
770
  update.signal(cm, "update", cm);
@@ -780,8 +781,8 @@
780
781
  postUpdateDisplay(cm, update);
781
782
  var barMeasure = measureForScrollbars(cm);
782
783
  updateSelection(cm);
783
- setDocumentHeight(cm, barMeasure);
784
784
  updateScrollbars(cm, barMeasure);
785
+ setDocumentHeight(cm, barMeasure);
785
786
  update.finish();
786
787
  }
787
788
  }
@@ -789,8 +790,7 @@
789
790
  function setDocumentHeight(cm, measure) {
790
791
  cm.display.sizer.style.minHeight = measure.docHeight + "px";
791
792
  cm.display.heightForcer.style.top = measure.docHeight + "px";
792
- cm.display.gutters.style.height = Math.max(measure.docHeight + cm.display.barHeight + scrollGap(cm),
793
- measure.clientHeight) + "px";
793
+ cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px";
794
794
  }
795
795
 
796
796
  // Read the actual heights of the rendered lines, and update their
@@ -2258,13 +2258,15 @@
2258
2258
 
2259
2259
  if (oldPos) {
2260
2260
  var near = m.find(dir < 0 ? 1 : -1), diff;
2261
- if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft) near = movePos(doc, near, -dir, line);
2261
+ if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
2262
+ near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null);
2262
2263
  if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
2263
2264
  return skipAtomicInner(doc, near, pos, dir, mayClear);
2264
2265
  }
2265
2266
 
2266
2267
  var far = m.find(dir < 0 ? -1 : 1);
2267
- if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight) far = movePos(doc, far, dir, line);
2268
+ if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight)
2269
+ far = movePos(doc, far, dir, far.line == pos.line ? line : null);
2268
2270
  return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null;
2269
2271
  }
2270
2272
  }
@@ -2311,6 +2313,7 @@
2311
2313
  for (var i = 0; i < doc.sel.ranges.length; i++) {
2312
2314
  if (primary === false && i == doc.sel.primIndex) continue;
2313
2315
  var range = doc.sel.ranges[i];
2316
+ if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) continue;
2314
2317
  var collapsed = range.empty();
2315
2318
  if (collapsed || cm.options.showCursorWhenSelecting)
2316
2319
  drawSelectionCursor(cm, range.head, curFragment);
@@ -3112,10 +3115,10 @@
3112
3115
 
3113
3116
  if (op.preparedSelection)
3114
3117
  cm.display.input.showSelection(op.preparedSelection);
3115
- if (op.updatedDisplay)
3116
- setDocumentHeight(cm, op.barMeasure);
3117
3118
  if (op.updatedDisplay || op.startHeight != cm.doc.height)
3118
3119
  updateScrollbars(cm, op.barMeasure);
3120
+ if (op.updatedDisplay)
3121
+ setDocumentHeight(cm, op.barMeasure);
3119
3122
 
3120
3123
  if (op.selectionChanged) restartBlink(cm);
3121
3124
 
@@ -3492,7 +3495,7 @@
3492
3495
  over: function(e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }},
3493
3496
  start: function(e){onDragStart(cm, e);},
3494
3497
  drop: operation(cm, onDrop),
3495
- leave: function() {clearDragCursor(cm);}
3498
+ leave: function(e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); }}
3496
3499
  };
3497
3500
 
3498
3501
  var inp = d.input.getField();
@@ -7622,9 +7625,9 @@
7622
7625
  var spans = line.markedSpans;
7623
7626
  if (spans) for (var i = 0; i < spans.length; i++) {
7624
7627
  var span = spans[i];
7625
- if (!(lineNo == from.line && from.ch > span.to ||
7626
- span.from == null && lineNo != from.line||
7627
- lineNo == to.line && span.from > to.ch) &&
7628
+ if (!(span.to != null && lineNo == from.line && from.ch > span.to ||
7629
+ span.from == null && lineNo != from.line ||
7630
+ span.from != null && lineNo == to.line && span.from > to.ch) &&
7628
7631
  (!filter || filter(span.marker)))
7629
7632
  found.push(span.marker.parent || span.marker);
7630
7633
  }
@@ -8886,7 +8889,7 @@
8886
8889
 
8887
8890
  // THE END
8888
8891
 
8889
- CodeMirror.version = "5.12.0";
8892
+ CodeMirror.version = "5.13.2";
8890
8893
 
8891
8894
  return CodeMirror;
8892
8895
  });
@@ -14,10 +14,12 @@
14
14
  if (val && !prev) {
15
15
  cm.on("blur", onBlur);
16
16
  cm.on("change", onChange);
17
+ cm.on("swapDoc", onChange);
17
18
  onChange(cm);
18
19
  } else if (!val && prev) {
19
20
  cm.off("blur", onBlur);
20
21
  cm.off("change", onChange);
22
+ cm.off("swapDoc", onChange);
21
23
  clearPlaceholder(cm);
22
24
  var wrapper = cm.getWrapperElement();
23
25
  wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
@@ -121,11 +121,13 @@
121
121
 
122
122
  finishUpdate: function(data, first) {
123
123
  if (this.data) CodeMirror.signal(this.data, "update");
124
- if (data && this.data && CodeMirror.cmpPos(data.from, this.data.from)) data = null;
125
- this.data = data;
126
124
 
127
125
  var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
128
126
  if (this.widget) this.widget.close();
127
+
128
+ if (data && this.data && isNewCompletion(this.data, data)) return;
129
+ this.data = data;
130
+
129
131
  if (data && data.list.length) {
130
132
  if (picked && data.list.length == 1) {
131
133
  this.pick(data, 0);
@@ -137,6 +139,11 @@
137
139
  }
138
140
  };
139
141
 
142
+ function isNewCompletion(old, nw) {
143
+ var moved = CodeMirror.cmpPos(nw.from, old.from)
144
+ return moved > 0 && old.to.ch - old.from.ch != nw.to.ch - nw.from.ch
145
+ }
146
+
140
147
  function parseOptions(cm, pos, options) {
141
148
  var editor = cm.options.hintOptions;
142
149
  var out = {};
@@ -20,6 +20,8 @@
20
20
  };
21
21
  var Pos = CodeMirror.Pos;
22
22
 
23
+ function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" }
24
+
23
25
  function getKeywords(editor) {
24
26
  var mode = editor.doc.modeOption;
25
27
  if (mode === "sql") mode = "text/x-sql";
@@ -30,10 +32,28 @@
30
32
  return typeof item == "string" ? item : item.text;
31
33
  }
32
34
 
33
- function getItem(list, item) {
34
- if (!list.slice) return list[item];
35
- for (var i = list.length - 1; i >= 0; i--) if (getText(list[i]) == item)
36
- return list[i];
35
+ function wrapTable(name, value) {
36
+ if (isArray(value)) value = {columns: value}
37
+ if (!value.text) value.text = name
38
+ return value
39
+ }
40
+
41
+ function parseTables(input) {
42
+ var result = {}
43
+ if (isArray(input)) {
44
+ for (var i = input.length - 1; i >= 0; i--) {
45
+ var item = input[i]
46
+ result[getText(item).toUpperCase()] = wrapTable(getText(item), item)
47
+ }
48
+ } else if (input) {
49
+ for (var name in input)
50
+ result[name.toUpperCase()] = wrapTable(name, input[name])
51
+ }
52
+ return result
53
+ }
54
+
55
+ function getTable(name) {
56
+ return tables[name.toUpperCase()]
37
57
  }
38
58
 
39
59
  function shallowClone(object) {
@@ -50,11 +70,18 @@
50
70
  }
51
71
 
52
72
  function addMatches(result, search, wordlist, formatter) {
53
- for (var word in wordlist) {
54
- if (!wordlist.hasOwnProperty(word)) continue;
55
- if (wordlist.slice) word = wordlist[word];
56
-
57
- if (match(search, word)) result.push(formatter(word));
73
+ if (isArray(wordlist)) {
74
+ for (var i = 0; i < wordlist.length; i++)
75
+ if (match(search, wordlist[i])) result.push(formatter(wordlist[i]))
76
+ } else {
77
+ for (var word in wordlist) if (wordlist.hasOwnProperty(word)) {
78
+ var val = wordlist[word]
79
+ if (!val || val === true)
80
+ val = word
81
+ else
82
+ val = val.displayText ? {text: val.text, displayText: val.displayText} : val.text
83
+ if (match(search, val)) result.push(formatter(val))
84
+ }
58
85
  }
59
86
  }
60
87
 
@@ -115,13 +142,13 @@
115
142
  var alias = false;
116
143
  var aliasTable = table;
117
144
  // Check if table is available. If not, find table by Alias
118
- if (!getItem(tables, table)) {
145
+ if (!getTable(table)) {
119
146
  var oldTable = table;
120
147
  table = findTableByAlias(table, editor);
121
148
  if (table !== oldTable) alias = true;
122
149
  }
123
150
 
124
- var columns = getItem(tables, table);
151
+ var columns = getTable(table);
125
152
  if (columns && columns.columns)
126
153
  columns = columns.columns;
127
154
 
@@ -184,7 +211,7 @@
184
211
  //find valid range
185
212
  var prevItem = 0;
186
213
  var current = convertCurToNumber(editor.getCursor());
187
- for (var i=0; i< separator.length; i++) {
214
+ for (var i = 0; i < separator.length; i++) {
188
215
  var _v = convertCurToNumber(separator[i]);
189
216
  if (current > prevItem && current <= _v) {
190
217
  validRange = { start: convertNumberToCur(prevItem), end: convertNumberToCur(_v) };
@@ -199,7 +226,7 @@
199
226
  var lineText = query[i];
200
227
  eachWord(lineText, function(word) {
201
228
  var wordUpperCase = word.toUpperCase();
202
- if (wordUpperCase === aliasUpperCase && getItem(tables, previousWord))
229
+ if (wordUpperCase === aliasUpperCase && getTable(previousWord))
203
230
  table = previousWord;
204
231
  if (wordUpperCase !== CONS.ALIAS_KEYWORD)
205
232
  previousWord = word;
@@ -210,10 +237,10 @@
210
237
  }
211
238
 
212
239
  CodeMirror.registerHelper("hint", "sql", function(editor, options) {
213
- tables = (options && options.tables) || {};
240
+ tables = parseTables(options && options.tables)
214
241
  var defaultTableName = options && options.defaultTable;
215
242
  var disableKeywords = options && options.disableKeywords;
216
- defaultTable = defaultTableName && getItem(tables, defaultTableName);
243
+ defaultTable = defaultTableName && getTable(defaultTableName);
217
244
  keywords = keywords || getKeywords(editor);
218
245
 
219
246
  if (defaultTableName && !defaultTable)
@@ -186,9 +186,14 @@
186
186
  state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
187
187
  }
188
188
 
189
- function popupSpanTooltip(ann, e) {
189
+ function popupTooltips(annotations, e) {
190
190
  var target = e.target || e.srcElement;
191
- showTooltipFor(e, annotationTooltip(ann), target);
191
+ var tooltip = document.createDocumentFragment();
192
+ for (var i = 0; i < annotations.length; i++) {
193
+ var ann = annotations[i];
194
+ tooltip.appendChild(annotationTooltip(ann));
195
+ }
196
+ showTooltipFor(e, tooltip, target);
192
197
  }
193
198
 
194
199
  function onMouseOver(cm, e) {
@@ -196,10 +201,12 @@
196
201
  if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
197
202
  var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
198
203
  var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
204
+
205
+ var annotations = [];
199
206
  for (var i = 0; i < spans.length; ++i) {
200
- var ann = spans[i].__annotation;
201
- if (ann) return popupSpanTooltip(ann, e);
207
+ annotations.push(spans[i].__annotation);
202
208
  }
209
+ if (annotations.length) popupTooltips(annotations, e);
203
210
  }
204
211
 
205
212
  CodeMirror.defineOption("lint", false, function(cm, val, old) {
@@ -427,9 +427,9 @@
427
427
 
428
428
  function copyChunk(dv, to, from, chunk) {
429
429
  if (dv.diffOutOfDate) return;
430
- var start = chunk.editTo > to.lastLine() ? Pos(chunk.editFrom - 1) : Pos(chunk.editFrom, 0)
431
- to.replaceRange(from.getRange(Pos(chunk.origFrom, 0), Pos(chunk.origTo, 0)),
432
- start, Pos(chunk.editTo, 0));
430
+ var editStart = chunk.editTo > to.lastLine() ? Pos(chunk.editFrom - 1) : Pos(chunk.editFrom, 0)
431
+ var origStart = chunk.origTo > from.lastLine() ? Pos(chunk.origFrom - 1) : Pos(chunk.origFrom, 0)
432
+ to.replaceRange(from.getRange(origStart, Pos(chunk.origTo, 0)), editStart, Pos(chunk.editTo, 0))
433
433
  }
434
434
 
435
435
  // Merge view, containing 0, 1, or 2 diff views.
@@ -59,16 +59,20 @@
59
59
  CodeMirror.on(this.node, "DOMMouseScroll", onWheel);
60
60
  }
61
61
 
62
- Bar.prototype.moveTo = function(pos, update) {
62
+ Bar.prototype.setPos = function(pos) {
63
63
  if (pos < 0) pos = 0;
64
64
  if (pos > this.total - this.screen) pos = this.total - this.screen;
65
- if (pos == this.pos) return;
65
+ if (pos == this.pos) return false;
66
66
  this.pos = pos;
67
67
  this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
68
68
  (pos * (this.size / this.total)) + "px";
69
- if (update !== false) this.scroll(pos, this.orientation);
69
+ return true
70
70
  };
71
71
 
72
+ Bar.prototype.moveTo = function(pos) {
73
+ if (this.setPos(pos)) this.scroll(pos, this.orientation);
74
+ }
75
+
72
76
  var minButtonSize = 10;
73
77
 
74
78
  Bar.prototype.update = function(scrollSize, clientSize, barSize) {
@@ -83,8 +87,7 @@
83
87
  }
84
88
  this.inner.style[this.orientation == "horizontal" ? "width" : "height"] =
85
89
  buttonSize + "px";
86
- this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
87
- this.pos * (this.size / this.total) + "px";
90
+ this.setPos(this.pos);
88
91
  };
89
92
 
90
93
  function SimpleScrollbars(cls, place, scroll) {
@@ -111,7 +114,6 @@
111
114
  if (needsV) {
112
115
  this.vert.update(measure.scrollHeight, measure.clientHeight,
113
116
  measure.viewHeight - (needsH ? width : 0));
114
- this.vert.node.style.display = "block";
115
117
  this.vert.node.style.bottom = needsH ? width + "px" : "0";
116
118
  }
117
119
  if (needsH) {
@@ -125,11 +127,11 @@
125
127
  };
126
128
 
127
129
  SimpleScrollbars.prototype.setScrollTop = function(pos) {
128
- this.vert.moveTo(pos, false);
130
+ this.vert.setPos(pos);
129
131
  };
130
132
 
131
133
  SimpleScrollbars.prototype.setScrollLeft = function(pos) {
132
- this.horiz.moveTo(pos, false);
134
+ this.horiz.setPos(pos);
133
135
  };
134
136
 
135
137
  SimpleScrollbars.prototype.clear = function() {
@@ -64,9 +64,9 @@
64
64
  { keys: '<C-[>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
65
65
  { keys: '<C-c>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
66
66
  { keys: 's', type: 'keyToKey', toKeys: 'cl', context: 'normal' },
67
- { keys: 's', type: 'keyToKey', toKeys: 'xi', context: 'visual'},
67
+ { keys: 's', type: 'keyToKey', toKeys: 'c', context: 'visual'},
68
68
  { keys: 'S', type: 'keyToKey', toKeys: 'cc', context: 'normal' },
69
- { keys: 'S', type: 'keyToKey', toKeys: 'dcc', context: 'visual' },
69
+ { keys: 'S', type: 'keyToKey', toKeys: 'VdO', context: 'visual' },
70
70
  { keys: '<Home>', type: 'keyToKey', toKeys: '0' },
71
71
  { keys: '<End>', type: 'keyToKey', toKeys: '$' },
72
72
  { keys: '<PageUp>', type: 'keyToKey', toKeys: '<C-b>' },
@@ -1696,11 +1696,12 @@
1696
1696
  var line = motionArgs.forward ? cur.line + repeat : cur.line - repeat;
1697
1697
  var first = cm.firstLine();
1698
1698
  var last = cm.lastLine();
1699
- // Vim cancels linewise motions that start on an edge and move beyond
1700
- // that edge. It does not cancel motions that do not start on an edge.
1701
- if ((line < first && cur.line == first) ||
1702
- (line > last && cur.line == last)) {
1703
- return;
1699
+ // Vim go to line begin or line end when cursor at first/last line and
1700
+ // move to previous/next line is triggered.
1701
+ if (line < first && cur.line == first){
1702
+ return this.moveToStartOfLine(cm, head, motionArgs, vim);
1703
+ }else if (line > last && cur.line == last){
1704
+ return this.moveToEol(cm, head, motionArgs, vim);
1704
1705
  }
1705
1706
  if (motionArgs.toFirstChar){
1706
1707
  endCh=findFirstNonWhiteSpaceCharacter(cm.getLine(line));
@@ -100,7 +100,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
100
100
  }
101
101
  }
102
102
  if (isOperatorChar.test(ch)) {
103
- stream.eatWhile(isOperatorChar);
103
+ while (!stream.match(/^\/[\/*]/, false) && stream.eat(isOperatorChar)) {}
104
104
  return "operator";
105
105
  }
106
106
  stream.eatWhile(/[\w\$_\xa1-\uffff]/);
@@ -245,5 +245,6 @@ CodeMirror.defineMode("clojure", function (options) {
245
245
 
246
246
  CodeMirror.defineMIME("text/x-clojure", "clojure");
247
247
  CodeMirror.defineMIME("text/x-clojurescript", "clojure");
248
+ CodeMirror.defineMIME("application/edn", "clojure");
248
249
 
249
250
  });
@@ -72,6 +72,12 @@
72
72
  return null;
73
73
  }
74
74
  return false;
75
+ },
76
+
77
+ "/": function(stream, state) {
78
+ if (!stream.eat("*")) return false
79
+ state.tokenize = tokenNestedComment(1)
80
+ return state.tokenize(stream, state)
75
81
  }
76
82
  }
77
83
  });
@@ -121,6 +127,27 @@
121
127
  return "variable";
122
128
  }
123
129
 
130
+ function tokenNestedComment(depth) {
131
+ return function (stream, state) {
132
+ var ch
133
+ while (ch = stream.next()) {
134
+ if (ch == "*" && stream.eat("/")) {
135
+ if (depth == 1) {
136
+ state.tokenize = null
137
+ break
138
+ } else {
139
+ state.tokenize = tokenNestedComment(depth - 1)
140
+ return state.tokenize(stream, state)
141
+ }
142
+ } else if (ch == "/" && stream.eat("*")) {
143
+ state.tokenize = tokenNestedComment(depth + 1)
144
+ return state.tokenize(stream, state)
145
+ }
146
+ }
147
+ return "comment"
148
+ }
149
+ }
150
+
124
151
  CodeMirror.registerHelper("hintWords", "application/dart", keywords.concat(atoms).concat(builtins));
125
152
 
126
153
  // This is needed to make loading through meta.js work.
@@ -169,15 +169,16 @@ CodeMirror.defineMode("dylan", function(_config) {
169
169
  } else if (stream.eat("/")) {
170
170
  stream.skipToEnd();
171
171
  return "comment";
172
- } else {
173
- stream.skipTo(" ");
174
- return "operator";
175
172
  }
173
+ stream.backUp(1);
176
174
  }
177
175
  // Decimal
178
- else if (/\d/.test(ch)) {
179
- stream.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/);
180
- return "number";
176
+ else if (/[+\-\d\.]/.test(ch)) {
177
+ if (stream.match(/^[+-]?[0-9]*\.[0-9]*([esdx][+-]?[0-9]+)?/i) ||
178
+ stream.match(/^[+-]?[0-9]+([esdx][+-]?[0-9]+)/i) ||
179
+ stream.match(/^[+-]?\d+/)) {
180
+ return "number";
181
+ }
181
182
  }
182
183
  // Hash
183
184
  else if (ch == "#") {
@@ -186,7 +187,7 @@ CodeMirror.defineMode("dylan", function(_config) {
186
187
  ch = stream.peek();
187
188
  if (ch == '"') {
188
189
  stream.next();
189
- return chain(stream, state, tokenString('"', "string-2"));
190
+ return chain(stream, state, tokenString('"', "string"));
190
191
  }
191
192
  // Binary number
192
193
  else if (ch == "b") {
@@ -206,11 +207,51 @@ CodeMirror.defineMode("dylan", function(_config) {
206
207
  stream.eatWhile(/[0-7]/);
207
208
  return "number";
208
209
  }
210
+ // Token concatenation in macros
211
+ else if (ch == '#') {
212
+ stream.next();
213
+ return "punctuation";
214
+ }
215
+ // Sequence literals
216
+ else if ((ch == '[') || (ch == '(')) {
217
+ stream.next();
218
+ return "bracket";
209
219
  // Hash symbol
210
- else {
220
+ } else if (stream.match(/f|t|all-keys|include|key|next|rest/i)) {
221
+ return "atom";
222
+ } else {
211
223
  stream.eatWhile(/[-a-zA-Z]/);
212
- return "keyword";
224
+ return "error";
225
+ }
226
+ } else if (ch == "~") {
227
+ stream.next();
228
+ ch = stream.peek();
229
+ if (ch == "=") {
230
+ stream.next();
231
+ ch = stream.peek();
232
+ if (ch == "=") {
233
+ stream.next();
234
+ return "operator";
235
+ }
236
+ return "operator";
213
237
  }
238
+ return "operator";
239
+ } else if (ch == ":") {
240
+ stream.next();
241
+ ch = stream.peek();
242
+ if (ch == "=") {
243
+ stream.next();
244
+ return "operator";
245
+ } else if (ch == ":") {
246
+ stream.next();
247
+ return "punctuation";
248
+ }
249
+ } else if ("[](){}".indexOf(ch) != -1) {
250
+ stream.next();
251
+ return "bracket";
252
+ } else if (".,".indexOf(ch) != -1) {
253
+ stream.next();
254
+ return "punctuation";
214
255
  } else if (stream.match("end")) {
215
256
  return "keyword";
216
257
  }
@@ -223,6 +264,10 @@ CodeMirror.defineMode("dylan", function(_config) {
223
264
  return patternStyles[name];
224
265
  }
225
266
  }
267
+ if (/[+\-*\/^=<>&|]/.test(ch)) {
268
+ stream.next();
269
+ return "operator";
270
+ }
226
271
  if (stream.match("define")) {
227
272
  return "def";
228
273
  } else {
@@ -240,29 +285,37 @@ CodeMirror.defineMode("dylan", function(_config) {
240
285
  }
241
286
 
242
287
  function tokenComment(stream, state) {
243
- var maybeEnd = false,
244
- ch;
288
+ var maybeEnd = false, maybeNested = false, nestedCount = 0, ch;
245
289
  while ((ch = stream.next())) {
246
290
  if (ch == "/" && maybeEnd) {
247
- state.tokenize = tokenBase;
248
- break;
291
+ if (nestedCount > 0) {
292
+ nestedCount--;
293
+ } else {
294
+ state.tokenize = tokenBase;
295
+ break;
296
+ }
297
+ } else if (ch == "*" && maybeNested) {
298
+ nestedCount++;
249
299
  }
250
300
  maybeEnd = (ch == "*");
301
+ maybeNested = (ch == "/");
251
302
  }
252
303
  return "comment";
253
304
  }
254
305
 
255
306
  function tokenString(quote, style) {
256
307
  return function(stream, state) {
257
- var next, end = false;
308
+ var escaped = false, next, end = false;
258
309
  while ((next = stream.next()) != null) {
259
- if (next == quote) {
310
+ if (next == quote && !escaped) {
260
311
  end = true;
261
312
  break;
262
313
  }
314
+ escaped = !escaped && next == "\\";
263
315
  }
264
- if (end)
316
+ if (end || !escaped) {
265
317
  state.tokenize = tokenBase;
318
+ }
266
319
  return style;
267
320
  };
268
321
  }
@@ -40,4 +40,4 @@
40
40
  }, "haskell")
41
41
 
42
42
  CodeMirror.defineMIME("text/x-literate-haskell", "haskell-literate")
43
- })
43
+ });
@@ -25,9 +25,9 @@
25
25
  context.prev && copyContext(context.prev))
26
26
  }
27
27
 
28
- CodeMirror.defineMode("jsx", function(config) {
28
+ CodeMirror.defineMode("jsx", function(config, modeConfig) {
29
29
  var xmlMode = CodeMirror.getMode(config, {name: "xml", allowMissing: true, multilineTagIndentPastTag: false})
30
- var jsMode = CodeMirror.getMode(config, "javascript")
30
+ var jsMode = CodeMirror.getMode(config, modeConfig && modeConfig.base || "javascript")
31
31
 
32
32
  function flatXMLIndent(state) {
33
33
  var tagName = state.tagName
@@ -144,4 +144,4 @@
144
144
  }, "xml", "javascript")
145
145
 
146
146
  CodeMirror.defineMIME("text/jsx", "jsx")
147
- })
147
+ });
@@ -149,10 +149,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
149
149
  state.list = null;
150
150
  } else if (state.indentation > 0) {
151
151
  state.list = null;
152
- state.listDepth = Math.floor(state.indentation / 4);
153
152
  } else { // No longer a list
154
153
  state.list = false;
155
- state.listDepth = 0;
156
154
  }
157
155
  }
158
156
 
@@ -199,7 +197,17 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
199
197
  }
200
198
  state.indentation = stream.column() + stream.current().length;
201
199
  state.list = true;
202
- state.listDepth++;
200
+
201
+ // While this list item's marker's indentation
202
+ // is less than the deepest list item's content's indentation,
203
+ // pop the deepest list item indentation off the stack.
204
+ while (state.listStack && stream.column() < state.listStack[state.listStack.length - 1]) {
205
+ state.listStack.pop();
206
+ }
207
+
208
+ // Add this list item's content's indentation to the stack
209
+ state.listStack.push(state.indentation);
210
+
203
211
  if (modeCfg.taskLists && stream.match(taskListRE, false)) {
204
212
  state.taskList = true;
205
213
  }
@@ -321,7 +329,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
321
329
  }
322
330
 
323
331
  if (state.list !== false) {
324
- var listMod = (state.listDepth - 1) % 3;
332
+ var listMod = (state.listStack.length - 1) % 3;
325
333
  if (!listMod) {
326
334
  styles.push(tokenTypes.list1);
327
335
  } else if (listMod === 1) {
@@ -697,7 +705,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
697
705
  hr: false,
698
706
  taskList: false,
699
707
  list: false,
700
- listDepth: 0,
708
+ listStack: [],
701
709
  quote: 0,
702
710
  trailingSpace: 0,
703
711
  trailingSpaceNewLine: false,
@@ -732,7 +740,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
732
740
  hr: s.hr,
733
741
  taskList: s.taskList,
734
742
  list: s.list,
735
- listDepth: s.listDepth,
743
+ listStack: s.listStack.slice(0),
736
744
  quote: s.quote,
737
745
  indentedCode: s.indentedCode,
738
746
  trailingSpace: s.trailingSpace,
@@ -772,11 +780,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
772
780
 
773
781
  state.f = state.block;
774
782
  var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, ' ').length;
775
- var difference = Math.floor((indentation - state.indentation) / 4) * 4;
776
- if (difference > 4) difference = 4;
777
- var adjustedIndentation = state.indentation + difference;
778
- state.indentationDiff = adjustedIndentation - state.indentation;
779
- state.indentation = adjustedIndentation;
783
+ state.indentationDiff = Math.min(indentation - state.indentation, 4);
784
+ state.indentation = state.indentation + state.indentationDiff;
780
785
  if (indentation > 0) return null;
781
786
  }
782
787
  return state.f(stream, state);
@@ -0,0 +1,68 @@
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
+ function wordRegexp(words) {
15
+ return new RegExp("^((" + words.join(")|(") + "))\\b", "i");
16
+ };
17
+
18
+ var keywordArray = [
19
+ "package", "message", "import", "syntax",
20
+ "required", "optional", "repeated", "reserved", "default", "extensions", "packed",
21
+ "bool", "bytes", "double", "enum", "float", "string",
22
+ "int32", "int64", "uint32", "uint64", "sint32", "sint64", "fixed32", "fixed64", "sfixed32", "sfixed64"
23
+ ];
24
+ var keywords = wordRegexp(keywordArray);
25
+
26
+ CodeMirror.registerHelper("hintWords", "protobuf", keywordArray);
27
+
28
+ var identifiers = new RegExp("^[_A-Za-z\xa1-\uffff][_A-Za-z0-9\xa1-\uffff]*");
29
+
30
+ function tokenBase(stream) {
31
+ // whitespaces
32
+ if (stream.eatSpace()) return null;
33
+
34
+ // Handle one line Comments
35
+ if (stream.match("//")) {
36
+ stream.skipToEnd();
37
+ return "comment";
38
+ }
39
+
40
+ // Handle Number Literals
41
+ if (stream.match(/^[0-9\.+-]/, false)) {
42
+ if (stream.match(/^[+-]?0x[0-9a-fA-F]+/))
43
+ return "number";
44
+ if (stream.match(/^[+-]?\d*\.\d+([EeDd][+-]?\d+)?/))
45
+ return "number";
46
+ if (stream.match(/^[+-]?\d+([EeDd][+-]?\d+)?/))
47
+ return "number";
48
+ }
49
+
50
+ // Handle Strings
51
+ if (stream.match(/^"([^"]|(""))*"/)) { return "string"; }
52
+ if (stream.match(/^'([^']|(''))*'/)) { return "string"; }
53
+
54
+ // Handle words
55
+ if (stream.match(keywords)) { return "keyword"; }
56
+ if (stream.match(identifiers)) { return "variable"; } ;
57
+
58
+ // Handle non-detected items
59
+ stream.next();
60
+ return null;
61
+ };
62
+
63
+ CodeMirror.defineMode("protobuf", function() {
64
+ return {token: tokenBase};
65
+ });
66
+
67
+ CodeMirror.defineMIME("text/x-protobuf", "protobuf");
68
+ });
@@ -11,6 +11,8 @@
11
11
  })(function(CodeMirror) {
12
12
  "use strict";
13
13
 
14
+ CodeMirror.registerHelper("wordChars", "r", /[\w.]/);
15
+
14
16
  CodeMirror.defineMode("r", function(config) {
15
17
  function wordObj(str) {
16
18
  var words = str.split(" "), res = {};
@@ -199,4 +199,4 @@
199
199
  })
200
200
 
201
201
  CodeMirror.defineMIME("text/x-swift","swift")
202
- })
202
+ });
@@ -42,42 +42,34 @@ CodeMirror.defineMode("tcl", function() {
42
42
  var beforeParams = state.beforeParams;
43
43
  state.beforeParams = false;
44
44
  var ch = stream.next();
45
- if ((ch == '"' || ch == "'") && state.inParams)
45
+ if ((ch == '"' || ch == "'") && state.inParams) {
46
46
  return chain(stream, state, tokenString(ch));
47
- else if (/[\[\]{}\(\),;\.]/.test(ch)) {
47
+ } else if (/[\[\]{}\(\),;\.]/.test(ch)) {
48
48
  if (ch == "(" && beforeParams) state.inParams = true;
49
49
  else if (ch == ")") state.inParams = false;
50
50
  return null;
51
- }
52
- else if (/\d/.test(ch)) {
51
+ } else if (/\d/.test(ch)) {
53
52
  stream.eatWhile(/[\w\.]/);
54
53
  return "number";
55
- }
56
- else if (ch == "#" && stream.eat("*")) {
57
- return chain(stream, state, tokenComment);
58
- }
59
- else if (ch == "#" && stream.match(/ *\[ *\[/)) {
60
- return chain(stream, state, tokenUnparsed);
61
- }
62
- else if (ch == "#" && stream.eat("#")) {
54
+ } else if (ch == "#") {
55
+ if (stream.eat("*"))
56
+ return chain(stream, state, tokenComment);
57
+ if (ch == "#" && stream.match(/ *\[ *\[/))
58
+ return chain(stream, state, tokenUnparsed);
63
59
  stream.skipToEnd();
64
60
  return "comment";
65
- }
66
- else if (ch == '"') {
61
+ } else if (ch == '"') {
67
62
  stream.skipTo(/"/);
68
63
  return "comment";
69
- }
70
- else if (ch == "$") {
64
+ } else if (ch == "$") {
71
65
  stream.eatWhile(/[$_a-z0-9A-Z\.{:]/);
72
66
  stream.eatWhile(/}/);
73
67
  state.beforeParams = true;
74
68
  return "builtin";
75
- }
76
- else if (isOperatorChar.test(ch)) {
69
+ } else if (isOperatorChar.test(ch)) {
77
70
  stream.eatWhile(isOperatorChar);
78
71
  return "comment";
79
- }
80
- else {
72
+ } else {
81
73
  stream.eatWhile(/[\w\$_{}\xa1-\uffff]/);
82
74
  var word = stream.current().toLowerCase();
83
75
  if (keywords && keywords.propertyIsEnumerable(word))
@@ -77,6 +77,8 @@ CodeMirror.defineMode('troff', function() {
77
77
  };
78
78
  });
79
79
 
80
- CodeMirror.defineMIME('troff', 'troff');
80
+ CodeMirror.defineMIME('text/troff', 'troff');
81
+ CodeMirror.defineMIME('text/x-troff', 'troff');
82
+ CodeMirror.defineMIME('application/x-troff', 'troff');
81
83
 
82
84
  });
@@ -3,15 +3,15 @@
3
3
 
4
4
  (function(mod) {
5
5
  if (typeof exports == "object" && typeof module == "object") // CommonJS
6
- mod(require("../../lib/codemirror"));
6
+ mod(require("../../lib/codemirror"), require("../../addon/mode/multiplex"));
7
7
  else if (typeof define == "function" && define.amd) // AMD
8
- define(["../../lib/codemirror"], mod);
8
+ define(["../../lib/codemirror", "../../addon/mode/multiplex"], mod);
9
9
  else // Plain browser env
10
10
  mod(CodeMirror);
11
11
  })(function(CodeMirror) {
12
12
  "use strict";
13
13
 
14
- CodeMirror.defineMode("twig", function() {
14
+ CodeMirror.defineMode("twig:inner", function() {
15
15
  var keywords = ["and", "as", "autoescape", "endautoescape", "block", "do", "endblock", "else", "elseif", "extends", "for", "endfor", "embed", "endembed", "filter", "endfilter", "flush", "from", "if", "endif", "in", "is", "include", "import", "not", "or", "set", "spaceless", "endspaceless", "with", "endwith", "trans", "endtrans", "blocktrans", "endblocktrans", "macro", "endmacro", "use", "verbatim", "endverbatim"],
16
16
  operator = /^[+\-*&%=<>!?|~^]/,
17
17
  sign = /^[:\[\(\{]/,
@@ -128,5 +128,14 @@
128
128
  };
129
129
  });
130
130
 
131
+ CodeMirror.defineMode("twig", function(config, parserConfig) {
132
+ var twigInner = CodeMirror.getMode(config, "twig:inner");
133
+ if (!parserConfig || !parserConfig.base) return twigInner;
134
+ return CodeMirror.multiplexingMode(
135
+ CodeMirror.getMode(config, parserConfig.base), {
136
+ open: /\{[{#%]/, close: /[}#%]\}/, mode: twigInner, parseDelimiters: true
137
+ }
138
+ );
139
+ });
131
140
  CodeMirror.defineMIME("text/x-twig", "twig");
132
141
  });
@@ -34,7 +34,7 @@ CodeMirror.defineMode("velocity", function() {
34
34
  state.beforeParams = false;
35
35
  var ch = stream.next();
36
36
  // start of unparsed string?
37
- if ((ch == "'") && state.inParams) {
37
+ if ((ch == "'") && !state.inString && state.inParams) {
38
38
  state.lastTokenWasBuiltin = false;
39
39
  return chain(stream, state, tokenString(ch));
40
40
  }
@@ -191,6 +191,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
191
191
 
192
192
  .CodeMirror-gutters {
193
193
  position: absolute; left: 0; top: 0;
194
+ min-height: 100%;
194
195
  z-index: 3;
195
196
  }
196
197
  .CodeMirror-gutter {
@@ -245,6 +246,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
245
246
  position: relative;
246
247
  overflow: visible;
247
248
  -webkit-tap-highlight-color: transparent;
249
+ -webkit-font-variant-ligatures: none;
250
+ font-variant-ligatures: none;
248
251
  }
249
252
  .CodeMirror-wrap pre {
250
253
  word-wrap: break-word;
@@ -10,7 +10,7 @@
10
10
  .cm-s-night .CodeMirror-linenumber { color: #f8f8f8; }
11
11
  .cm-s-night .CodeMirror-cursor { border-left: 1px solid white; }
12
12
 
13
- .cm-s-night span.cm-comment { color: #6900a1; }
13
+ .cm-s-night span.cm-comment { color: #8900d1; }
14
14
  .cm-s-night span.cm-atom { color: #845dc4; }
15
15
  .cm-s-night span.cm-number, .cm-s-night span.cm-attribute { color: #ffd500; }
16
16
  .cm-s-night span.cm-keyword { color: #599eff; }
@@ -19,7 +19,6 @@
19
19
  .cm-s-night span.cm-variable-2, .cm-s-night span.cm-tag { color: #99b2ff; }
20
20
  .cm-s-night span.cm-variable-3, .cm-s-night span.cm-def { color: white; }
21
21
  .cm-s-night span.cm-bracket { color: #8da6ce; }
22
- .cm-s-night span.cm-comment { color: #6900a1; }
23
22
  .cm-s-night span.cm-builtin, .cm-s-night span.cm-special { color: #ff9e59; }
24
23
  .cm-s-night span.cm-link { color: #845dc4; }
25
24
  .cm-s-night span.cm-error { color: #9d1e15; }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codemirror-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: '5.12'
4
+ version: 5.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Fixler
@@ -218,6 +218,7 @@ files:
218
218
  - vendor/assets/javascripts/codemirror/modes/php.js
219
219
  - vendor/assets/javascripts/codemirror/modes/pig.js
220
220
  - vendor/assets/javascripts/codemirror/modes/properties.js
221
+ - vendor/assets/javascripts/codemirror/modes/protobuf.js
221
222
  - vendor/assets/javascripts/codemirror/modes/puppet.js
222
223
  - vendor/assets/javascripts/codemirror/modes/python.js
223
224
  - vendor/assets/javascripts/codemirror/modes/q.js