codemirror-rails 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. data/codemirror-rails-0.0.0.gem +0 -0
  2. data/codemirror-rails-0.1.gem +0 -0
  3. data/lib/codemirror/rails/version.rb +2 -2
  4. data/vendor/assets/javascripts/codemirror.js +122 -63
  5. data/vendor/assets/javascripts/codemirror/modes/clike.js +221 -0
  6. data/vendor/assets/javascripts/codemirror/modes/css.js +124 -0
  7. data/vendor/assets/javascripts/codemirror/modes/diff.js +13 -0
  8. data/vendor/assets/javascripts/codemirror/modes/haskell.js +242 -0
  9. data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +79 -0
  10. data/vendor/assets/javascripts/codemirror/modes/javascript.js +348 -0
  11. data/vendor/assets/javascripts/codemirror/modes/lua.js +138 -0
  12. data/vendor/assets/javascripts/codemirror/modes/php.js +111 -0
  13. data/vendor/assets/javascripts/codemirror/modes/plsql.js +217 -0
  14. data/vendor/assets/javascripts/codemirror/modes/python.js +321 -0
  15. data/vendor/assets/javascripts/codemirror/modes/rst.js +333 -0
  16. data/vendor/assets/javascripts/codemirror/modes/scheme.js +181 -0
  17. data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +122 -0
  18. data/vendor/assets/javascripts/codemirror/modes/stex.js +167 -0
  19. data/vendor/assets/javascripts/codemirror/modes/xml.js +227 -0
  20. data/vendor/assets/javascripts/codemirror/modes/yaml.js +95 -0
  21. data/vendor/assets/javascripts/codemirror/overlay.js +51 -0
  22. data/vendor/assets/javascripts/codemirror/runmode.js +27 -0
  23. data/vendor/assets/stylesheets/codemirror.css +3 -0
  24. data/vendor/assets/stylesheets/codemirror/modes/clike.css +7 -0
  25. data/vendor/assets/stylesheets/codemirror/modes/diff.css +3 -0
  26. data/vendor/assets/stylesheets/codemirror/modes/rst.css +75 -0
  27. metadata +25 -3
  28. data/codemirror-rails-0.1.1.gem +0 -0
Binary file
Binary file
@@ -1,6 +1,6 @@
1
1
  module Codemirror
2
2
  module Rails
3
- VERSION = '0.1.1'
4
- CODEMIRROR_VERSION = '2.1'
3
+ VERSION = '0.1.2'
4
+ CODEMIRROR_VERSION = '2.11'
5
5
  end
6
6
  end
@@ -74,17 +74,15 @@ var CodeMirror = (function() {
74
74
  // can be kept static when scrolling.
75
75
  var maxLine = "";
76
76
 
77
- // Initialize the content. Somewhat hacky (delayed prepareInput)
78
- // to work around browser issues.
77
+ // Initialize the content.
79
78
  operation(function(){setValue(options.value || ""); updateInput = false;})();
80
- setTimeout(prepareInput, 20);
81
79
 
82
80
  // Register our event handlers.
83
81
  connect(scroller, "mousedown", operation(onMouseDown));
84
82
  // Gecko browsers fire contextmenu *after* opening the menu, at
85
83
  // which point we can't mess with it anymore. Context menu is
86
84
  // handled in onMouseDown for Gecko.
87
- if (!gecko) connect(scroller, "contextmenu", operation(onContextMenu));
85
+ if (!gecko) connect(scroller, "contextmenu", onContextMenu);
88
86
  connect(code, "dblclick", operation(onDblClick));
89
87
  connect(scroller, "scroll", function() {updateDisplay([]); if (options.onScroll) options.onScroll(instance);});
90
88
  connect(window, "resize", function() {updateDisplay(true);});
@@ -104,7 +102,7 @@ var CodeMirror = (function() {
104
102
  // IE throws unspecified error in certain cases, when
105
103
  // trying to access activeElement before onload
106
104
  var hasFocus; try { hasFocus = (targetDocument.activeElement == input); } catch(e) { }
107
- if (hasFocus) onFocus();
105
+ if (hasFocus) setTimeout(onFocus, 20);
108
106
  else onBlur();
109
107
 
110
108
  function isLine(l) {return l >= 0 && l < lines.length;}
@@ -118,7 +116,7 @@ var CodeMirror = (function() {
118
116
  setValue: operation(setValue),
119
117
  getSelection: getSelection,
120
118
  replaceSelection: operation(replaceSelection),
121
- focus: function(){focusInput(); onFocus(); prepareInput(); fastPoll();},
119
+ focus: function(){focusInput(); onFocus(); fastPoll();},
122
120
  setOption: function(option, value) {
123
121
  options[option] = value;
124
122
  if (option == "lineNumbers" || option == "gutter") gutterChanged();
@@ -136,6 +134,10 @@ var CodeMirror = (function() {
136
134
  pos = clipPos(pos);
137
135
  return lines[pos.line].getTokenAt(mode, getStateBefore(pos.line), pos.ch);
138
136
  },
137
+ getStateAfter: function(line) {
138
+ line = clipLine(line == null ? lines.length - 1: line);
139
+ return getStateBefore(line + 1);
140
+ },
139
141
  cursorCoords: function(start){
140
142
  if (start == null) start = sel.inverted;
141
143
  return pageCoords(start ? sel.from : sel.to);
@@ -152,13 +154,22 @@ var CodeMirror = (function() {
152
154
  clearMarker: removeGutterMarker,
153
155
  setLineClass: operation(setLineClass),
154
156
  lineInfo: lineInfo,
155
- addWidget: function(pos, node, scroll) {
156
- var pos = localCoords(clipPos(pos), true);
157
- node.style.top = (showingFrom * lineHeight() + pos.yBot + paddingTop()) + "px";
158
- node.style.left = (pos.x + paddingLeft()) + "px";
157
+ addWidget: function(pos, node, scroll, where) {
158
+ pos = localCoords(clipPos(pos));
159
+ var top = pos.yBot, left = pos.x;
160
+ node.style.position = "absolute";
159
161
  code.appendChild(node);
162
+ node.style.left = left + "px";
163
+ if (where == "over") top = pos.y;
164
+ else if (where == "fit") {
165
+ var vspace = lines.length * lineHeight(), hspace = code.clientWidth - paddingLeft();
166
+ top = pos.y + node.offsetHeight > vspace ? vspace - node.offsetHeight : pos.y;
167
+ if (left + node.offsetWidth > hspace) left = hspace - node.offsetWidth;
168
+ }
169
+ node.style.top = (top + paddingTop()) + "px";
170
+ node.style.left = (left + paddingLeft()) + "px";
160
171
  if (scroll)
161
- scrollIntoView(pos.x, pos.yBot, pos.x + node.offsetWidth, pos.yBot + node.offsetHeight);
172
+ scrollIntoView(left, top, left + node.offsetWidth, top + node.offsetHeight);
162
173
  },
163
174
 
164
175
  lineCount: function() {return lines.length;},
@@ -185,7 +196,8 @@ var CodeMirror = (function() {
185
196
  operation: function(f){return operation(f)();},
186
197
  refresh: function(){updateDisplay(true);},
187
198
  getInputField: function(){return input;},
188
- getWrapperElement: function(){return wrapper;}
199
+ getWrapperElement: function(){return wrapper;},
200
+ getScrollerElement: function(){return scroller;}
189
201
  };
190
202
 
191
203
  function setValue(code) {
@@ -212,12 +224,18 @@ var CodeMirror = (function() {
212
224
  return e.stop();
213
225
  }
214
226
 
215
- if (gecko && e.button() == 3) onContextMenu(e);
216
- if (e.button() != 1) return;
227
+ var start = posFromMouse(e);
228
+ switch (e.button()) {
229
+ case 3:
230
+ if (gecko && !mac) onContextMenu(e);
231
+ return;
232
+ case 2:
233
+ if (start) setCursor(start.line, start.ch, true);
234
+ return;
235
+ }
217
236
  // For button 1, if it was clicked inside the editor
218
237
  // (posFromMouse returning non-null), we have to adjust the
219
238
  // selection.
220
- var start = posFromMouse(e), last = start, going;
221
239
  if (!start) {if (e.target() == scroller) e.stop(); return;}
222
240
 
223
241
  if (!focused) onFocus();
@@ -225,6 +243,7 @@ var CodeMirror = (function() {
225
243
  if (ld && +new Date - ld < 400) return selectLine(start.line);
226
244
 
227
245
  setCursor(start.line, start.ch, true);
246
+ var last = start, going;
228
247
  // And then we have to see if it's a drag event, in which case
229
248
  // the dragged-over text must be selected.
230
249
  function end() {
@@ -266,11 +285,10 @@ var CodeMirror = (function() {
266
285
  lastDoubleClick = +new Date;
267
286
  }
268
287
  function onDrop(e) {
288
+ e.e.preventDefault();
269
289
  var pos = posFromMouse(e, true), files = e.e.dataTransfer.files;
270
290
  if (!pos || options.readOnly) return;
271
291
  if (files && files.length && window.FileReader && window.File) {
272
- var n = files.length, text = Array(n), read = 0;
273
- for (var i = 0; i < n; ++i) loadFile(files[i], i);
274
292
  function loadFile(file, i) {
275
293
  var reader = new FileReader;
276
294
  reader.onload = function() {
@@ -279,6 +297,8 @@ var CodeMirror = (function() {
279
297
  };
280
298
  reader.readAsText(file);
281
299
  }
300
+ var n = files.length, text = Array(n), read = 0;
301
+ for (var i = 0; i < n; ++i) loadFile(files[i], i);
282
302
  }
283
303
  else {
284
304
  try {
@@ -354,19 +374,24 @@ var CodeMirror = (function() {
354
374
 
355
375
  function onFocus() {
356
376
  if (options.readOnly == "nocursor") return;
357
- if (!focused && options.onFocus) options.onFocus(instance);
358
- focused = true;
377
+ if (!focused) {
378
+ if (options.onFocus) options.onFocus(instance);
379
+ focused = true;
380
+ if (wrapper.className.search(/\bCodeMirror-focused\b/) == -1)
381
+ wrapper.className += " CodeMirror-focused";
382
+ if (!leaveInputAlone) prepareInput();
383
+ }
359
384
  slowPoll();
360
- if (wrapper.className.search(/\bCodeMirror-focused\b/) == -1)
361
- wrapper.className += " CodeMirror-focused";
362
385
  restartBlink();
363
386
  }
364
387
  function onBlur() {
365
- if (focused && options.onBlur) options.onBlur(instance);
388
+ if (focused) {
389
+ if (options.onBlur) options.onBlur(instance);
390
+ focused = false;
391
+ wrapper.className = wrapper.className.replace(" CodeMirror-focused", "");
392
+ }
366
393
  clearInterval(blinker);
367
- shiftSelecting = null;
368
- focused = false;
369
- wrapper.className = wrapper.className.replace(" CodeMirror-focused", "");
394
+ setTimeout(function() {if (!focused) shiftSelecting = null;}, 150);
370
395
  }
371
396
 
372
397
  // Replace the range from from to to by the strings in newText.
@@ -379,8 +404,6 @@ var CodeMirror = (function() {
379
404
  while (history.done.length > options.undoDepth) history.done.shift();
380
405
  }
381
406
  updateLinesNoUndo(from, to, newText, selFrom, selTo);
382
- if (newText.length < 5)
383
- highlightLines(from.line, from.line + newText.length)
384
407
  }
385
408
  function unredoHelper(from, to) {
386
409
  var change = from.pop();
@@ -454,7 +477,12 @@ var CodeMirror = (function() {
454
477
  if (task < from.line) newWork.push(task);
455
478
  else if (task > to.line) newWork.push(task + lendiff);
456
479
  }
457
- if (newText.length) newWork.push(from.line);
480
+ if (newText.length < 5) {
481
+ highlightLines(from.line, from.line + newText.length);
482
+ newWork.push(from.line + newText.length);
483
+ } else {
484
+ newWork.push(from.line);
485
+ }
458
486
  work = newWork;
459
487
  startWorker(100);
460
488
  // Remember that these lines changed, for updating the display
@@ -735,6 +763,8 @@ var CodeMirror = (function() {
735
763
 
736
764
  var textWidth = stringWidth(maxLine);
737
765
  lineSpace.style.width = textWidth > scroller.clientWidth ? textWidth + "px" : "";
766
+ // Needed to prevent odd wrapping/hiding of widgets placed in here.
767
+ code.style.width = (lineSpace.offsetWidth + lineSpace.offsetLeft) + "px";
738
768
 
739
769
  // Since this is all rather error prone, it is honoured with the
740
770
  // only assertion in the whole file.
@@ -927,12 +957,17 @@ var CodeMirror = (function() {
927
957
  indentLine(sel.from.line, options.enterMode == "keep" ? "prev" : "smart");
928
958
  }
929
959
  function handleTab(shift) {
960
+ function indentSelected(mode) {
961
+ if (posEq(sel.from, sel.to)) return indentLine(sel.from.line, mode);
962
+ var e = sel.to.line - (sel.to.ch ? 1 : 0);
963
+ for (var i = sel.from.line; i < e; ++i) indentLine(i, mode);
964
+ }
930
965
  shiftSelecting = null;
931
966
  switch (options.tabMode) {
932
967
  case "default":
933
968
  return false;
934
969
  case "indent":
935
- for (var i = sel.from.line, e = sel.to.line; i <= e; ++i) indentLine(i, "smart");
970
+ indentSelected("smart");
936
971
  break;
937
972
  case "classic":
938
973
  if (posEq(sel.from, sel.to)) {
@@ -941,7 +976,7 @@ var CodeMirror = (function() {
941
976
  break;
942
977
  }
943
978
  case "shift":
944
- for (var i = sel.from.line, e = sel.to.line; i <= e; ++i) indentLine(i, shift ? "subtract" : "add");
979
+ indentSelected(shift ? "subtract" : "add");
945
980
  break;
946
981
  }
947
982
  return true;
@@ -1122,7 +1157,9 @@ var CodeMirror = (function() {
1122
1157
  function paddingLeft() {return lineSpace.offsetLeft;}
1123
1158
 
1124
1159
  function posFromMouse(e, liberal) {
1125
- var offW = eltOffset(scroller, true), x = e.e.clientX, y = e.e.clientY;
1160
+ var offW = eltOffset(scroller, true), x, y;
1161
+ // Fails unpredictably on IE[67] when mouse is dragged around quickly.
1162
+ try { x = e.e.clientX; y = e.e.clientY; } catch (e) { return null; }
1126
1163
  // This is a mess of a heuristic to try and determine whether a
1127
1164
  // scroll-bar was clicked or not, and to return null if one was
1128
1165
  // (and !liberal).
@@ -1136,18 +1173,21 @@ var CodeMirror = (function() {
1136
1173
  var pos = posFromMouse(e);
1137
1174
  if (!pos || window.opera) return; // Opera is difficult.
1138
1175
  if (posEq(sel.from, sel.to) || posLess(pos, sel.from) || !posLess(pos, sel.to))
1139
- setCursor(pos.line, pos.ch);
1176
+ operation(setCursor)(pos.line, pos.ch);
1140
1177
 
1141
1178
  var oldCSS = input.style.cssText;
1179
+ inputDiv.style.position = "absolute";
1142
1180
  input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.pageY() - 1) +
1143
1181
  "px; left: " + (e.pageX() - 1) + "px; z-index: 1000; background: white; " +
1144
- "border-width: 0; outline: none; overflow: hidden; opacity: .05;";
1182
+ "border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
1183
+ leaveInputAlone = true;
1145
1184
  var val = input.value = getSelection();
1146
1185
  focusInput();
1147
1186
  setSelRange(input, 0, input.value.length);
1148
- leaveInputAlone = true;
1149
1187
  function rehide() {
1150
- if (input.value != val) operation(replaceSelection)(input.value, "end");
1188
+ var newVal = splitLines(input.value).join("\n");
1189
+ if (newVal != val) operation(replaceSelection)(newVal, "end");
1190
+ inputDiv.style.position = "relative";
1151
1191
  input.style.cssText = oldCSS;
1152
1192
  leaveInputAlone = false;
1153
1193
  prepareInput();
@@ -1155,7 +1195,7 @@ var CodeMirror = (function() {
1155
1195
  }
1156
1196
 
1157
1197
  if (gecko) {
1158
- e.stop()
1198
+ e.stop();
1159
1199
  var mouseup = connect(window, "mouseup", function() {
1160
1200
  mouseup();
1161
1201
  setTimeout(rehide, 20);
@@ -1202,19 +1242,20 @@ var CodeMirror = (function() {
1202
1242
  }
1203
1243
  }
1204
1244
  }
1205
- for (var i = head.line, e = forward ? Math.min(i + 50, lines.length) : Math.max(-1, i - 50); i != e; i+=d) {
1245
+ for (var i = head.line, e = forward ? Math.min(i + 100, lines.length) : Math.max(-1, i - 100); i != e; i+=d) {
1206
1246
  var line = lines[i], first = i == head.line;
1207
1247
  var found = scan(line, first && forward ? pos + 1 : 0, first && !forward ? pos : line.text.length);
1208
- if (found) {
1209
- var style = found.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
1210
- var one = markText({line: head.line, ch: pos}, {line: head.line, ch: pos+1}, style),
1211
- two = markText({line: i, ch: found.pos}, {line: i, ch: found.pos + 1}, style);
1212
- var clear = operation(function(){one(); two();});
1213
- if (autoclear) setTimeout(clear, 800);
1214
- else bracketHighlighted = clear;
1215
- break;
1216
- }
1248
+ if (found) break;
1217
1249
  }
1250
+ if (!found) found = {pos: null, match: false};
1251
+ var style = found.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
1252
+ var one = markText({line: head.line, ch: pos}, {line: head.line, ch: pos+1}, style),
1253
+ two = found.pos != null
1254
+ ? markText({line: i, ch: found.pos}, {line: i, ch: found.pos + 1}, style)
1255
+ : function() {};
1256
+ var clear = operation(function(){one(); two();});
1257
+ if (autoclear) setTimeout(clear, 800);
1258
+ else bracketHighlighted = clear;
1218
1259
  }
1219
1260
 
1220
1261
  // Finds the line to start with when starting a parse. Tries to
@@ -1267,7 +1308,7 @@ var CodeMirror = (function() {
1267
1308
  if (state) state = copyState(mode, state);
1268
1309
  else state = startState(mode);
1269
1310
 
1270
- var unchanged = 0;
1311
+ var unchanged = 0, compare = mode.compareStates;
1271
1312
  for (var i = start, l = lines.length; i < l; ++i) {
1272
1313
  var line = lines[i], hadState = line.stateAfter;
1273
1314
  if (+new Date > end) {
@@ -1278,8 +1319,12 @@ var CodeMirror = (function() {
1278
1319
  }
1279
1320
  var changed = line.highlight(mode, state);
1280
1321
  line.stateAfter = copyState(mode, state);
1281
- if (changed || !hadState) unchanged = 0;
1282
- else if (++unchanged > 3) break;
1322
+ if (compare) {
1323
+ if (hadState && compare(hadState, state)) break;
1324
+ } else {
1325
+ if (changed || !hadState) unchanged = 0;
1326
+ else if (++unchanged > 3) break;
1327
+ }
1283
1328
  }
1284
1329
  changes.push({from: task, to: i});
1285
1330
  }
@@ -1308,7 +1353,8 @@ var CodeMirror = (function() {
1308
1353
 
1309
1354
  // updateInput can be set to a boolean value to force/prevent an
1310
1355
  // update.
1311
- if (!leaveInputAlone && (updateInput === true || (updateInput !== false && selectionChanged)))
1356
+ if (focused && !leaveInputAlone &&
1357
+ (updateInput === true || (updateInput !== false && selectionChanged)))
1312
1358
  prepareInput();
1313
1359
 
1314
1360
  if (selectionChanged && options.matchBrackets)
@@ -1435,7 +1481,15 @@ var CodeMirror = (function() {
1435
1481
  },
1436
1482
 
1437
1483
  from: function() {if (this.atOccurrence) return copyPos(this.pos.from);},
1438
- to: function() {if (this.atOccurrence) return copyPos(this.pos.to);}
1484
+ to: function() {if (this.atOccurrence) return copyPos(this.pos.to);},
1485
+
1486
+ replace: function(newText) {
1487
+ var self = this;
1488
+ if (this.atOccurrence)
1489
+ operation(function() {
1490
+ self.pos.to = replaceRange(newText, self.pos.from, self.pos.to);
1491
+ })();
1492
+ }
1439
1493
  };
1440
1494
 
1441
1495
  for (var ext in extensions)
@@ -1495,7 +1549,7 @@ var CodeMirror = (function() {
1495
1549
  return CodeMirror.getMode(options, "text/plain");
1496
1550
  }
1497
1551
  return mfactory(options, config || {});
1498
- }
1552
+ };
1499
1553
  CodeMirror.listModes = function() {
1500
1554
  var list = [];
1501
1555
  for (var m in modes)
@@ -1930,17 +1984,21 @@ var CodeMirror = (function() {
1930
1984
  return n;
1931
1985
  }
1932
1986
 
1987
+ function computedStyle(elt) {
1988
+ if (elt.currentStyle) return elt.currentStyle;
1989
+ return window.getComputedStyle(elt, null);
1990
+ }
1933
1991
  // Find the position of an element by following the offsetParent chain.
1934
1992
  // If screen==true, it returns screen (rather than page) coordinates.
1935
1993
  function eltOffset(node, screen) {
1936
1994
  var doc = node.ownerDocument.body;
1937
- var x = 0, y = 0, hitDoc = false;
1995
+ var x = 0, y = 0, skipDoc = false;
1938
1996
  for (var n = node; n; n = n.offsetParent) {
1939
1997
  x += n.offsetLeft; y += n.offsetTop;
1940
- // Fixed-position elements don't have the document in their offset chain
1941
- if (n == doc) hitDoc = true;
1998
+ if (screen && computedStyle(n).position == "fixed")
1999
+ skipDoc = true;
1942
2000
  }
1943
- var e = screen && hitDoc ? null : doc;
2001
+ var e = screen && !skipDoc ? null : doc;
1944
2002
  for (var n = node.parentNode; n != e; n = n.parentNode)
1945
2003
  if (n.scrollLeft != null) { x -= n.scrollLeft; y -= n.scrollTop;}
1946
2004
  return {left: x, top: y};
@@ -1981,8 +2039,9 @@ var CodeMirror = (function() {
1981
2039
 
1982
2040
  // See if "".split is the broken IE version, if so, provide an
1983
2041
  // alternative way to split lines.
2042
+ var splitLines, selRange, setSelRange;
1984
2043
  if ("\n\nb".split(/\n/).length != 3)
1985
- var splitLines = function(string) {
2044
+ splitLines = function(string) {
1986
2045
  var pos = 0, nl, result = [];
1987
2046
  while ((nl = string.indexOf("\n", pos)) > -1) {
1988
2047
  result.push(string.slice(pos, string.charAt(nl-1) == "\r" ? nl - 1 : nl));
@@ -1992,12 +2051,12 @@ var CodeMirror = (function() {
1992
2051
  return result;
1993
2052
  };
1994
2053
  else
1995
- var splitLines = function(string){return string.split(/\r?\n/);};
2054
+ splitLines = function(string){return string.split(/\r?\n/);};
1996
2055
  CodeMirror.splitLines = splitLines;
1997
2056
 
1998
2057
  // Sane model of finding and setting the selection in a textarea
1999
2058
  if (window.getSelection) {
2000
- var selRange = function(te) {
2059
+ selRange = function(te) {
2001
2060
  try {return {start: te.selectionStart, end: te.selectionEnd};}
2002
2061
  catch(e) {return null;}
2003
2062
  };
@@ -2008,7 +2067,7 @@ var CodeMirror = (function() {
2008
2067
  // the left. If you press shift-right, the anchor ends up at the
2009
2068
  // front. This is not what CodeMirror wants, so it does a
2010
2069
  // spurious modify() call to get out of limbo.
2011
- var setSelRange = function(te, start, end) {
2070
+ setSelRange = function(te, start, end) {
2012
2071
  if (start == end)
2013
2072
  te.setSelectionRange(start, end);
2014
2073
  else {
@@ -2017,14 +2076,14 @@ var CodeMirror = (function() {
2017
2076
  }
2018
2077
  };
2019
2078
  else
2020
- var setSelRange = function(te, start, end) {
2079
+ setSelRange = function(te, start, end) {
2021
2080
  try {te.setSelectionRange(start, end);}
2022
2081
  catch(e) {} // Fails on Firefox when textarea isn't part of the document
2023
2082
  };
2024
2083
  }
2025
2084
  // IE model. Don't ask.
2026
2085
  else {
2027
- var selRange = function(te) {
2086
+ selRange = function(te) {
2028
2087
  try {var range = te.ownerDocument.selection.createRange();}
2029
2088
  catch(e) {return null;}
2030
2089
  if (!range || range.parentElement() != te) return null;
@@ -2046,7 +2105,7 @@ var CodeMirror = (function() {
2046
2105
  for (var i = val.indexOf("\r"); i > -1 && i < end; i = val.indexOf("\r", i+1), end++) {}
2047
2106
  return {start: start, end: end};
2048
2107
  };
2049
- var setSelRange = function(te, start, end) {
2108
+ setSelRange = function(te, start, end) {
2050
2109
  var range = te.createTextRange();
2051
2110
  range.collapse(true);
2052
2111
  var endrange = range.duplicate();