ace-rails-ap 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ace/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/ace/ace.js +993 -613
  4. data/vendor/assets/javascripts/ace/ext-chromevox.js +3 -4
  5. data/vendor/assets/javascripts/ace/ext-elastic_tabstops_lite.js +5 -6
  6. data/vendor/assets/javascripts/ace/ext-emmet.js +50 -21
  7. data/vendor/assets/javascripts/ace/ext-language_tools.js +21 -19
  8. data/vendor/assets/javascripts/ace/ext-modelist.js +11 -6
  9. data/vendor/assets/javascripts/ace/ext-old_ie.js +12 -5
  10. data/vendor/assets/javascripts/ace/ext-searchbox.js +12 -5
  11. data/vendor/assets/javascripts/ace/ext-settings_menu.js +14 -7
  12. data/vendor/assets/javascripts/ace/ext-static_highlight.js +5 -5
  13. data/vendor/assets/javascripts/ace/ext-statusbar.js +14 -12
  14. data/vendor/assets/javascripts/ace/ext-textarea.js +1 -2
  15. data/vendor/assets/javascripts/ace/ext-themelist.js +2 -0
  16. data/vendor/assets/javascripts/ace/ext-whitespace.js +17 -13
  17. data/vendor/assets/javascripts/ace/keybinding-emacs.js +76 -78
  18. data/vendor/assets/javascripts/ace/keybinding-vim.js +221 -80
  19. data/vendor/assets/javascripts/ace/mode-abc.js +2 -3
  20. data/vendor/assets/javascripts/ace/mode-actionscript.js +2 -3
  21. data/vendor/assets/javascripts/ace/mode-apache_conf.js +2 -3
  22. data/vendor/assets/javascripts/ace/mode-applescript.js +2 -3
  23. data/vendor/assets/javascripts/ace/mode-autohotkey.js +2 -3
  24. data/vendor/assets/javascripts/ace/mode-batchfile.js +2 -3
  25. data/vendor/assets/javascripts/ace/mode-c_cpp.js +8 -5
  26. data/vendor/assets/javascripts/ace/mode-coffee.js +1 -1
  27. data/vendor/assets/javascripts/ace/mode-coldfusion.js +533 -139
  28. data/vendor/assets/javascripts/ace/mode-csharp.js +4 -5
  29. data/vendor/assets/javascripts/ace/mode-css.js +185 -6
  30. data/vendor/assets/javascripts/ace/mode-curly.js +495 -138
  31. data/vendor/assets/javascripts/ace/mode-d.js +2 -3
  32. data/vendor/assets/javascripts/ace/mode-dart.js +8 -5
  33. data/vendor/assets/javascripts/ace/mode-django.js +495 -138
  34. data/vendor/assets/javascripts/ace/mode-dockerfile.js +59 -14
  35. data/vendor/assets/javascripts/ace/mode-dot.js +2 -3
  36. data/vendor/assets/javascripts/ace/mode-ejs.js +497 -152
  37. data/vendor/assets/javascripts/ace/mode-elm.js +6 -4
  38. data/vendor/assets/javascripts/ace/mode-erlang.js +3 -4
  39. data/vendor/assets/javascripts/ace/mode-forth.js +3 -4
  40. data/vendor/assets/javascripts/ace/mode-ftl.js +145 -17
  41. data/vendor/assets/javascripts/ace/mode-gherkin.js +58 -25
  42. data/vendor/assets/javascripts/ace/mode-glsl.js +8 -5
  43. data/vendor/assets/javascripts/ace/mode-golang.js +36 -25
  44. data/vendor/assets/javascripts/ace/mode-groovy.js +145 -17
  45. data/vendor/assets/javascripts/ace/mode-handlebars.js +496 -140
  46. data/vendor/assets/javascripts/ace/mode-haskell.js +3 -4
  47. data/vendor/assets/javascripts/ace/mode-haxe.js +4 -5
  48. data/vendor/assets/javascripts/ace/mode-html.js +495 -138
  49. data/vendor/assets/javascripts/ace/mode-html_elixir.js +3372 -0
  50. data/vendor/assets/javascripts/ace/mode-html_ruby.js +495 -138
  51. data/vendor/assets/javascripts/ace/mode-ini.js +1 -1
  52. data/vendor/assets/javascripts/ace/mode-io.js +2 -3
  53. data/vendor/assets/javascripts/ace/mode-jack.js +4 -5
  54. data/vendor/assets/javascripts/ace/mode-jade.js +155 -25
  55. data/vendor/assets/javascripts/ace/mode-java.js +145 -17
  56. data/vendor/assets/javascripts/ace/mode-javascript.js +145 -17
  57. data/vendor/assets/javascripts/ace/mode-json.js +4 -5
  58. data/vendor/assets/javascripts/ace/mode-jsoniq.js +4 -5
  59. data/vendor/assets/javascripts/ace/mode-jsp.js +150 -23
  60. data/vendor/assets/javascripts/ace/mode-jsx.js +4 -5
  61. data/vendor/assets/javascripts/ace/mode-julia.js +2 -3
  62. data/vendor/assets/javascripts/ace/mode-less.js +5 -6
  63. data/vendor/assets/javascripts/ace/mode-liquid.js +145 -17
  64. data/vendor/assets/javascripts/ace/mode-logiql.js +2 -2
  65. data/vendor/assets/javascripts/ace/mode-lsl.js +8 -10
  66. data/vendor/assets/javascripts/ace/mode-lua.js +2 -2
  67. data/vendor/assets/javascripts/ace/mode-luapage.js +497 -140
  68. data/vendor/assets/javascripts/ace/mode-makefile.js +54 -8
  69. data/vendor/assets/javascripts/ace/mode-markdown.js +497 -139
  70. data/vendor/assets/javascripts/ace/mode-mask.js +150 -22
  71. data/vendor/assets/javascripts/ace/mode-maze.js +283 -0
  72. data/vendor/assets/javascripts/ace/mode-mel.js +4 -5
  73. data/vendor/assets/javascripts/ace/mode-mushcode.js +0 -1
  74. data/vendor/assets/javascripts/ace/mode-mysql.js +1 -1
  75. data/vendor/assets/javascripts/ace/mode-nix.js +8 -5
  76. data/vendor/assets/javascripts/ace/mode-objectivec.js +6 -3
  77. data/vendor/assets/javascripts/ace/mode-perl.js +4 -5
  78. data/vendor/assets/javascripts/ace/mode-pgsql.js +141 -12
  79. data/vendor/assets/javascripts/ace/mode-php.js +9872 -143
  80. data/vendor/assets/javascripts/ace/mode-powershell.js +4 -5
  81. data/vendor/assets/javascripts/ace/mode-praat.js +18 -14
  82. data/vendor/assets/javascripts/ace/mode-prolog.js +2 -3
  83. data/vendor/assets/javascripts/ace/mode-protobuf.js +8 -5
  84. data/vendor/assets/javascripts/ace/mode-rhtml.js +495 -138
  85. data/vendor/assets/javascripts/ace/mode-ruby.js +2 -2
  86. data/vendor/assets/javascripts/ace/mode-rust.js +32 -39
  87. data/vendor/assets/javascripts/ace/mode-scad.js +4 -5
  88. data/vendor/assets/javascripts/ace/mode-scala.js +158 -21
  89. data/vendor/assets/javascripts/ace/mode-scheme.js +118 -1
  90. data/vendor/assets/javascripts/ace/mode-scss.js +4 -5
  91. data/vendor/assets/javascripts/ace/mode-sh.js +58 -13
  92. data/vendor/assets/javascripts/ace/mode-sjs.js +145 -17
  93. data/vendor/assets/javascripts/ace/mode-smarty.js +495 -138
  94. data/vendor/assets/javascripts/ace/mode-soy_template.js +496 -140
  95. data/vendor/assets/javascripts/ace/mode-sql.js +12 -4
  96. data/vendor/assets/javascripts/ace/mode-sqlserver.js +437 -0
  97. data/vendor/assets/javascripts/ace/mode-svg.js +147 -20
  98. data/vendor/assets/javascripts/ace/mode-swift.js +738 -0
  99. data/vendor/assets/javascripts/ace/mode-swig.js +1099 -0
  100. data/vendor/assets/javascripts/ace/mode-tcl.js +2 -3
  101. data/vendor/assets/javascripts/ace/mode-tex.js +1 -0
  102. data/vendor/assets/javascripts/ace/mode-toml.js +4 -0
  103. data/vendor/assets/javascripts/ace/mode-twig.js +495 -138
  104. data/vendor/assets/javascripts/ace/mode-typescript.js +147 -19
  105. data/vendor/assets/javascripts/ace/mode-vala.js +4 -5
  106. data/vendor/assets/javascripts/ace/mode-vbscript.js +26 -13
  107. data/vendor/assets/javascripts/ace/mode-velocity.js +495 -138
  108. data/vendor/assets/javascripts/ace/mode-verilog.js +8 -0
  109. data/vendor/assets/javascripts/ace/mode-xml.js +2 -3
  110. data/vendor/assets/javascripts/ace/mode-xquery.js +4 -5
  111. data/vendor/assets/javascripts/ace/snippets/actionscript.js +5 -0
  112. data/vendor/assets/javascripts/ace/snippets/html_elixir.js +7 -0
  113. data/vendor/assets/javascripts/ace/snippets/java.js +6 -0
  114. data/vendor/assets/javascripts/ace/snippets/javascript.js +13 -0
  115. data/vendor/assets/javascripts/ace/snippets/lsl.js +166 -0
  116. data/vendor/assets/javascripts/ace/snippets/maze.js +16 -0
  117. data/vendor/assets/javascripts/ace/snippets/php.js +105 -4
  118. data/vendor/assets/javascripts/ace/snippets/sqlserver.js +76 -0
  119. data/vendor/assets/javascripts/ace/snippets/swift.js +7 -0
  120. data/vendor/assets/javascripts/ace/snippets/swig.js +7 -0
  121. data/vendor/assets/javascripts/ace/theme-clouds.js +0 -1
  122. data/vendor/assets/javascripts/ace/theme-clouds_midnight.js +0 -1
  123. data/vendor/assets/javascripts/ace/theme-cobalt.js +3 -3
  124. data/vendor/assets/javascripts/ace/theme-dawn.js +0 -1
  125. data/vendor/assets/javascripts/ace/theme-github.js +0 -1
  126. data/vendor/assets/javascripts/ace/theme-idle_fingers.js +0 -1
  127. data/vendor/assets/javascripts/ace/theme-iplastic.js +121 -0
  128. data/vendor/assets/javascripts/ace/theme-katzenmilch.js +1 -2
  129. data/vendor/assets/javascripts/ace/theme-kr_theme.js +0 -1
  130. data/vendor/assets/javascripts/ace/theme-kuroir.js +0 -1
  131. data/vendor/assets/javascripts/ace/theme-merbivore.js +0 -1
  132. data/vendor/assets/javascripts/ace/theme-merbivore_soft.js +0 -1
  133. data/vendor/assets/javascripts/ace/theme-mono_industrial.js +0 -1
  134. data/vendor/assets/javascripts/ace/theme-monokai.js +0 -1
  135. data/vendor/assets/javascripts/ace/theme-pastel_on_dark.js +0 -1
  136. data/vendor/assets/javascripts/ace/theme-solarized_dark.js +0 -1
  137. data/vendor/assets/javascripts/ace/theme-solarized_light.js +0 -1
  138. data/vendor/assets/javascripts/ace/theme-sqlserver.js +138 -0
  139. data/vendor/assets/javascripts/ace/theme-terminal.js +0 -1
  140. data/vendor/assets/javascripts/ace/theme-textmate.js +0 -1
  141. data/vendor/assets/javascripts/ace/theme-tomorrow.js +0 -1
  142. data/vendor/assets/javascripts/ace/theme-tomorrow_night.js +0 -1
  143. data/vendor/assets/javascripts/ace/theme-tomorrow_night_blue.js +0 -1
  144. data/vendor/assets/javascripts/ace/theme-tomorrow_night_bright.js +0 -1
  145. data/vendor/assets/javascripts/ace/theme-tomorrow_night_eighties.js +0 -1
  146. data/vendor/assets/javascripts/ace/theme-twilight.js +0 -1
  147. data/vendor/assets/javascripts/ace/theme-vibrant_ink.js +0 -1
  148. data/vendor/assets/javascripts/ace/theme-xcode.js +0 -1
  149. data/vendor/assets/javascripts/ace/worker-coffee.js +576 -6015
  150. data/vendor/assets/javascripts/ace/worker-css.js +529 -449
  151. data/vendor/assets/javascripts/ace/worker-html.js +528 -448
  152. data/vendor/assets/javascripts/ace/worker-javascript.js +8719 -7656
  153. data/vendor/assets/javascripts/ace/worker-json.js +530 -450
  154. data/vendor/assets/javascripts/ace/worker-lua.js +530 -450
  155. data/vendor/assets/javascripts/ace/worker-php.js +530 -450
  156. data/vendor/assets/javascripts/ace/worker-xml.js +530 -450
  157. data/vendor/assets/javascripts/ace/worker-xquery.js +529 -449
  158. metadata +14 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be8935634992bbd9473e1842eb231a30d0d31244
4
- data.tar.gz: 6736d38668d527d593d81110945c289bab4c2a83
3
+ metadata.gz: 28dce068cc2132409a6445f5fb148232533f89de
4
+ data.tar.gz: 632ed3cae729c07467d21eb223e2c02359ecc4ca
5
5
  SHA512:
6
- metadata.gz: b30649b31cbffb384a578c925eda11599fd18f02c14e8b7aa7c9fee00e73e8950d3540cd031f39973e90ad13a8a0940790e53187317d0e55dba21bd7be610009
7
- data.tar.gz: b6eb56d79356dd04295a7015c0e4f5240389c6ded75452a8755e3f06c3e19c42e317e319d77a3ea43d682f7562755bbaab2ad3658ff535fbbbc2c3b3ee111aed
6
+ metadata.gz: 4429069a802d350b6efaec8608a1f0657f26c5cfc91a7aec7e90293225f1074973198c636bacbac67171ede01c1a6ae3892f08ee4b9f0387b67d73d713a99892
7
+ data.tar.gz: fadb7628da20b7602623eba1b5bea2578f3f8cd05ae01178fd5cb4f9c3fc8c6ad9fd4ce6d569b7fb782b65b7c7cb9a87207941b52ee36580486e0d910d71954f
@@ -1,5 +1,5 @@
1
1
  module Ace
2
2
  module Rails
3
- VERSION = "4.0.0"
3
+ VERSION = "4.0.1"
4
4
  end
5
5
  end
@@ -960,7 +960,7 @@ exports.getDocumentHead = function(doc) {
960
960
  if (!doc)
961
961
  doc = document;
962
962
  return doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement;
963
- }
963
+ };
964
964
 
965
965
  exports.createElement = function(tag, ns) {
966
966
  return document.createElementNS ?
@@ -999,7 +999,7 @@ exports.toggleCssClass = function(el, name) {
999
999
  add = false;
1000
1000
  classes.splice(index, 1);
1001
1001
  }
1002
- if(add)
1002
+ if (add)
1003
1003
  classes.push(name);
1004
1004
 
1005
1005
  el.className = classes.join(" ");
@@ -1035,16 +1035,16 @@ exports.importCssString = function importCssString(cssText, id, doc) {
1035
1035
 
1036
1036
  var style;
1037
1037
 
1038
+ if (id)
1039
+ cssText += "\n/*# sourceURL=ace/css/" + id + " */";
1040
+
1038
1041
  if (doc.createStyleSheet) {
1039
1042
  style = doc.createStyleSheet();
1040
1043
  style.cssText = cssText;
1041
1044
  if (id)
1042
1045
  style.owningElement.id = id;
1043
1046
  } else {
1044
- style = doc.createElementNS
1045
- ? doc.createElementNS(XHTML_NS, "style")
1046
- : doc.createElement("style");
1047
-
1047
+ style = exports.createElement("style");
1048
1048
  style.appendChild(doc.createTextNode(cssText));
1049
1049
  if (id)
1050
1050
  style.id = id;
@@ -1081,42 +1081,6 @@ exports.getInnerHeight = function(element) {
1081
1081
  );
1082
1082
  };
1083
1083
 
1084
-
1085
- if (typeof document == "undefined")
1086
- return;
1087
-
1088
- if (window.pageYOffset !== undefined) {
1089
- exports.getPageScrollTop = function() {
1090
- return window.pageYOffset;
1091
- };
1092
-
1093
- exports.getPageScrollLeft = function() {
1094
- return window.pageXOffset;
1095
- };
1096
- }
1097
- else {
1098
- exports.getPageScrollTop = function() {
1099
- return document.body.scrollTop;
1100
- };
1101
-
1102
- exports.getPageScrollLeft = function() {
1103
- return document.body.scrollLeft;
1104
- };
1105
- }
1106
-
1107
- if (window.getComputedStyle)
1108
- exports.computedStyle = function(element, style) {
1109
- if (style)
1110
- return (window.getComputedStyle(element, "") || {})[style] || "";
1111
- return window.getComputedStyle(element, "") || {};
1112
- };
1113
- else
1114
- exports.computedStyle = function(element, style) {
1115
- if (style)
1116
- return element.currentStyle[style];
1117
- return element.currentStyle;
1118
- };
1119
-
1120
1084
  exports.scrollbarWidth = function(document) {
1121
1085
  var inner = exports.createElement("ace_inner");
1122
1086
  inner.style.width = "100%";
@@ -1153,6 +1117,43 @@ exports.scrollbarWidth = function(document) {
1153
1117
 
1154
1118
  return noScrollbar-withScrollbar;
1155
1119
  };
1120
+
1121
+ if (typeof document == "undefined") {
1122
+ exports.importCssString = function() {};
1123
+ return;
1124
+ }
1125
+
1126
+ if (window.pageYOffset !== undefined) {
1127
+ exports.getPageScrollTop = function() {
1128
+ return window.pageYOffset;
1129
+ };
1130
+
1131
+ exports.getPageScrollLeft = function() {
1132
+ return window.pageXOffset;
1133
+ };
1134
+ }
1135
+ else {
1136
+ exports.getPageScrollTop = function() {
1137
+ return document.body.scrollTop;
1138
+ };
1139
+
1140
+ exports.getPageScrollLeft = function() {
1141
+ return document.body.scrollLeft;
1142
+ };
1143
+ }
1144
+
1145
+ if (window.getComputedStyle)
1146
+ exports.computedStyle = function(element, style) {
1147
+ if (style)
1148
+ return (window.getComputedStyle(element, "") || {})[style] || "";
1149
+ return window.getComputedStyle(element, "") || {};
1150
+ };
1151
+ else
1152
+ exports.computedStyle = function(element, style) {
1153
+ if (style)
1154
+ return element.currentStyle[style];
1155
+ return element.currentStyle;
1156
+ };
1156
1157
  exports.setInnerHtml = function(el, innerHtml) {
1157
1158
  var element = el.cloneNode(false);//document.createElement("div");
1158
1159
  element.innerHTML = innerHtml;
@@ -1283,7 +1284,7 @@ var Keys = (function() {
1283
1284
  80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
1284
1285
  87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
1285
1286
  186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`',
1286
- 219: '[', 220: '\\',221: ']', 222: '\''
1287
+ 219: '[', 220: '\\',221: ']', 222: "'", 111: '/', 106: '*'
1287
1288
  }
1288
1289
  };
1289
1290
  var name, i;
@@ -1381,6 +1382,9 @@ define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/use
1381
1382
  var keys = require("./keys");
1382
1383
  var useragent = require("./useragent");
1383
1384
 
1385
+ var pressedKeys = null;
1386
+ var ts = 0;
1387
+
1384
1388
  exports.addListener = function(elem, type, callback) {
1385
1389
  if (elem.addEventListener) {
1386
1390
  return elem.addEventListener(type, callback, false);
@@ -1451,6 +1455,29 @@ exports.capture = function(el, eventHandler, releaseCaptureHandler) {
1451
1455
  return onMouseUp;
1452
1456
  };
1453
1457
 
1458
+ exports.addTouchMoveListener = function (el, callback) {
1459
+ if ("ontouchmove" in el) {
1460
+ var startx, starty;
1461
+ exports.addListener(el, "touchstart", function (e) {
1462
+ var touchObj = e.changedTouches[0];
1463
+ startx = touchObj.clientX;
1464
+ starty = touchObj.clientY;
1465
+ });
1466
+ exports.addListener(el, "touchmove", function (e) {
1467
+ var factor = 1,
1468
+ touchObj = e.changedTouches[0];
1469
+
1470
+ e.wheelX = -(touchObj.clientX - startx) / factor;
1471
+ e.wheelY = -(touchObj.clientY - starty) / factor;
1472
+
1473
+ startx = touchObj.clientX;
1474
+ starty = touchObj.clientY;
1475
+
1476
+ callback(e);
1477
+ });
1478
+ }
1479
+ };
1480
+
1454
1481
  exports.addMouseWheelListener = function(el, callback) {
1455
1482
  if ("onmousewheel" in el) {
1456
1483
  exports.addListener(el, "mousewheel", function(e) {
@@ -1566,7 +1593,7 @@ function normalizeCommandKeys(callback, e, keyCode) {
1566
1593
  var hashId = getModifierHash(e);
1567
1594
 
1568
1595
  if (!useragent.isMac && pressedKeys) {
1569
- if (pressedKeys[91] || pressedKeys[92])
1596
+ if (pressedKeys.OSKey)
1570
1597
  hashId |= 8;
1571
1598
  if (pressedKeys.altGr) {
1572
1599
  if ((3 & hashId) != 3)
@@ -1580,7 +1607,7 @@ function normalizeCommandKeys(callback, e, keyCode) {
1580
1607
  if (pressedKeys[keyCode] == 1)
1581
1608
  ts = e.timeStamp;
1582
1609
  } else if (keyCode === 18 && hashId === 3 && location === 2) {
1583
- var dt = e.timestamp - ts;
1610
+ var dt = e.timeStamp - ts;
1584
1611
  if (dt < 50)
1585
1612
  pressedKeys.altGr = true;
1586
1613
  }
@@ -1591,7 +1618,7 @@ function normalizeCommandKeys(callback, e, keyCode) {
1591
1618
  keyCode = -1;
1592
1619
  }
1593
1620
 
1594
- if (hashId & 8 && (keyCode === 91 || keyCode === 93)) {
1621
+ if (hashId & 8 && (keyCode === 91 || keyCode === 92)) {
1595
1622
  keyCode = -1;
1596
1623
  }
1597
1624
 
@@ -1618,8 +1645,7 @@ function normalizeCommandKeys(callback, e, keyCode) {
1618
1645
  return callback(e, hashId, keyCode);
1619
1646
  }
1620
1647
 
1621
- var pressedKeys = null;
1622
- var ts = 0;
1648
+
1623
1649
  exports.addCommandKeyListener = function(el, callback) {
1624
1650
  var addListener = exports.addListener;
1625
1651
  if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) {
@@ -1634,8 +1660,18 @@ exports.addCommandKeyListener = function(el, callback) {
1634
1660
  var lastDefaultPrevented = null;
1635
1661
 
1636
1662
  addListener(el, "keydown", function(e) {
1637
- pressedKeys[e.keyCode] = (pressedKeys[e.keyCode] || 0) + 1;
1638
- var result = normalizeCommandKeys(callback, e, e.keyCode);
1663
+ var keyCode = e.keyCode;
1664
+ pressedKeys[keyCode] = (pressedKeys[keyCode] || 0) + 1;
1665
+ if (keyCode == 91 || keyCode == 92) {
1666
+ pressedKeys.OSKey = true;
1667
+ } else if (pressedKeys.OSKey) {
1668
+ if (e.timeStamp - pressedKeys.lastT > 200 && pressedKeys.count == 1)
1669
+ resetPressedKeys();
1670
+ }
1671
+ if (pressedKeys[keyCode] == 1)
1672
+ pressedKeys.count++;
1673
+ pressedKeys.lastT = e.timeStamp;
1674
+ var result = normalizeCommandKeys(callback, e, keyCode);
1639
1675
  lastDefaultPrevented = e.defaultPrevented;
1640
1676
  return result;
1641
1677
  });
@@ -1648,19 +1684,31 @@ exports.addCommandKeyListener = function(el, callback) {
1648
1684
  });
1649
1685
 
1650
1686
  addListener(el, "keyup", function(e) {
1651
- pressedKeys[e.keyCode] = null;
1687
+ var keyCode = e.keyCode;
1688
+ if (!pressedKeys[keyCode]) {
1689
+ resetPressedKeys();
1690
+ } else {
1691
+ pressedKeys.count = Math.max(pressedKeys.count - 1, 0);
1692
+ }
1693
+ if (keyCode == 91 || keyCode == 92) {
1694
+ pressedKeys.OSKey = false;
1695
+ }
1696
+ pressedKeys[keyCode] = null;
1652
1697
  });
1653
1698
 
1654
1699
  if (!pressedKeys) {
1655
- pressedKeys = Object.create(null);
1656
- addListener(window, "focus", function(e) {
1657
- pressedKeys = Object.create(null);
1658
- });
1700
+ resetPressedKeys();
1701
+ addListener(window, "focus", resetPressedKeys);
1659
1702
  }
1660
1703
  }
1661
1704
  };
1705
+ function resetPressedKeys() {
1706
+ pressedKeys = Object.create(null);
1707
+ pressedKeys.count = 0;
1708
+ pressedKeys.lastT = 0;
1709
+ }
1662
1710
 
1663
- if (window.postMessage && !useragent.isOldIE) {
1711
+ if (typeof window == "object" && window.postMessage && !useragent.isOldIE) {
1664
1712
  var postMessageId = 1;
1665
1713
  exports.nextTick = function(callback, win) {
1666
1714
  win = win || window;
@@ -1677,11 +1725,11 @@ if (window.postMessage && !useragent.isOldIE) {
1677
1725
  }
1678
1726
 
1679
1727
 
1680
- exports.nextFrame = window.requestAnimationFrame ||
1681
- window.mozRequestAnimationFrame ||
1682
- window.webkitRequestAnimationFrame ||
1683
- window.msRequestAnimationFrame ||
1684
- window.oRequestAnimationFrame;
1728
+ exports.nextFrame = typeof window == "object" && (window.requestAnimationFrame
1729
+ || window.mozRequestAnimationFrame
1730
+ || window.webkitRequestAnimationFrame
1731
+ || window.msRequestAnimationFrame
1732
+ || window.oRequestAnimationFrame);
1685
1733
 
1686
1734
  if (exports.nextFrame)
1687
1735
  exports.nextFrame = exports.nextFrame.bind(window);
@@ -1744,20 +1792,24 @@ exports.copyArray = function(array){
1744
1792
  return copy;
1745
1793
  };
1746
1794
 
1747
- exports.deepCopy = function (obj) {
1795
+ exports.deepCopy = function deepCopy(obj) {
1748
1796
  if (typeof obj !== "object" || !obj)
1749
1797
  return obj;
1798
+ var copy;
1799
+ if (Array.isArray(obj)) {
1800
+ copy = [];
1801
+ for (var key = 0; key < obj.length; key++) {
1802
+ copy[key] = deepCopy(obj[key]);
1803
+ }
1804
+ return copy;
1805
+ }
1750
1806
  var cons = obj.constructor;
1751
1807
  if (cons === RegExp)
1752
1808
  return obj;
1753
1809
 
1754
- var copy = cons();
1810
+ copy = cons();
1755
1811
  for (var key in obj) {
1756
- if (typeof obj[key] === "object") {
1757
- copy[key] = exports.deepCopy(obj[key]);
1758
- } else {
1759
- copy[key] = obj[key];
1760
- }
1812
+ copy[key] = deepCopy(obj[key]);
1761
1813
  }
1762
1814
  return copy;
1763
1815
  };
@@ -1923,14 +1975,19 @@ var TextInput = function(parentNode, host) {
1923
1975
  });
1924
1976
  this.focus = function() {
1925
1977
  if (tempStyle) return text.focus();
1978
+ var top = text.style.top;
1926
1979
  text.style.position = "fixed";
1927
1980
  text.style.top = "-1000px";
1928
1981
  text.focus();
1929
1982
  setTimeout(function() {
1930
1983
  text.style.position = "";
1984
+ if (text.style.top == "-1000px")
1985
+ text.style.top = top;
1931
1986
  }, 0);
1932
1987
  };
1933
- this.blur = function() { text.blur(); };
1988
+ this.blur = function() {
1989
+ text.blur();
1990
+ };
1934
1991
  this.isFocused = function() {
1935
1992
  return isFocused;
1936
1993
  };
@@ -2135,7 +2192,7 @@ var TextInput = function(parentNode, host) {
2135
2192
  var data = handleClipboardData(e);
2136
2193
  if (typeof data == "string") {
2137
2194
  if (data)
2138
- host.onPaste(data);
2195
+ host.onPaste(data, e);
2139
2196
  if (useragent.isIE)
2140
2197
  setTimeout(resetSelection);
2141
2198
  event.preventDefault(e);
@@ -2301,7 +2358,7 @@ var TextInput = function(parentNode, host) {
2301
2358
  this.onContextMenuClose = onContextMenuClose;
2302
2359
  var closeTimeout;
2303
2360
  function onContextMenuClose() {
2304
- clearTimeout(closeTimeout)
2361
+ clearTimeout(closeTimeout);
2305
2362
  closeTimeout = setTimeout(function () {
2306
2363
  if (tempStyle) {
2307
2364
  text.style.cssText = tempStyle;
@@ -2343,6 +2400,7 @@ function DefaultHandlers(mouseHandler) {
2343
2400
  editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(mouseHandler));
2344
2401
  editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler));
2345
2402
  editor.setDefaultHandler("mousewheel", this.onMouseWheel.bind(mouseHandler));
2403
+ editor.setDefaultHandler("touchmove", this.onTouchMove.bind(mouseHandler));
2346
2404
 
2347
2405
  var exports = ["select", "startSelect", "selectEnd", "selectAllEnd", "selectByWordsEnd",
2348
2406
  "selectByLinesEnd", "dragWait", "dragWaitEnd", "focusWait"];
@@ -2544,6 +2602,19 @@ function DefaultHandlers(mouseHandler) {
2544
2602
  return ev.stop();
2545
2603
  }
2546
2604
  };
2605
+
2606
+ this.onTouchMove = function (ev) {
2607
+ var t = ev.domEvent.timeStamp;
2608
+ var dt = t - (this.$lastScrollTime || 0);
2609
+
2610
+ var editor = this.editor;
2611
+ var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
2612
+ if (isScrolable || dt < 200) {
2613
+ this.$lastScrollTime = t;
2614
+ editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
2615
+ return ev.stop();
2616
+ }
2617
+ };
2547
2618
 
2548
2619
  }).call(DefaultHandlers.prototype);
2549
2620
 
@@ -2698,7 +2769,7 @@ function GutterHandler(mouseHandler) {
2698
2769
  if (mouseHandler.$tooltipFollowsMouse) {
2699
2770
  moveTooltip(mouseEvent);
2700
2771
  } else {
2701
- var gutterElement = gutter.$cells[editor.session.documentToScreenRow(row, 0)].element;
2772
+ var gutterElement = mouseEvent.domEvent.target;
2702
2773
  var rect = gutterElement.getBoundingClientRect();
2703
2774
  var style = tooltip.getElement().style;
2704
2775
  style.left = rect.right + "px";
@@ -3538,7 +3609,7 @@ var AppConfig = require("./lib/app_config").AppConfig;
3538
3609
  module.exports = exports = new AppConfig();
3539
3610
 
3540
3611
  var global = (function() {
3541
- return this;
3612
+ return this || typeof window != "undefined" && window;
3542
3613
  })();
3543
3614
 
3544
3615
  var options = {
@@ -3715,6 +3786,8 @@ var MouseHandler = function(editor) {
3715
3786
  if (!document.hasFocus || !document.hasFocus())
3716
3787
  window.focus();
3717
3788
  editor.focus();
3789
+ if (!editor.isFocused())
3790
+ window.focus();
3718
3791
  };
3719
3792
 
3720
3793
  var mouseTarget = editor.renderer.getMouseEventTarget();
@@ -3730,6 +3803,7 @@ var MouseHandler = function(editor) {
3730
3803
  }
3731
3804
  }
3732
3805
  event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
3806
+ event.addTouchMoveListener(editor.container, this.onTouchMove.bind(this, "touchmove"));
3733
3807
 
3734
3808
  var gutterEl = editor.renderer.$gutter;
3735
3809
  event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"));
@@ -3781,6 +3855,14 @@ var MouseHandler = function(editor) {
3781
3855
 
3782
3856
  this.editor._emit(name, mouseEvent);
3783
3857
  };
3858
+
3859
+ this.onTouchMove = function (name, e) {
3860
+ var mouseEvent = new MouseEvent(e, this.editor);
3861
+ mouseEvent.speed = 1;//this.$scrollSpeed * 2;
3862
+ mouseEvent.wheelX = e.wheelX;
3863
+ mouseEvent.wheelY = e.wheelY;
3864
+ this.editor._emit(name, mouseEvent);
3865
+ };
3784
3866
 
3785
3867
  this.setState = function(state) {
3786
3868
  this.state = state;
@@ -4007,7 +4089,7 @@ var KeyBinding = function(editor) {
4007
4089
  if (toExecute.command == "null") {
4008
4090
  success = true;
4009
4091
  } else {
4010
- success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
4092
+ success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
4011
4093
  }
4012
4094
  if (success && e && hashId != -1 &&
4013
4095
  toExecute.passEvent != true && toExecute.command.passEvent != true
@@ -4017,6 +4099,15 @@ var KeyBinding = function(editor) {
4017
4099
  if (success)
4018
4100
  break;
4019
4101
  }
4102
+
4103
+ if (!success && hashId == -1) {
4104
+ toExecute = {command: "insertstring"};
4105
+ success = commands.exec("insertstring", this.$editor, keyString);
4106
+ }
4107
+
4108
+ if (success)
4109
+ this.$editor._signal("keyboardActivity", toExecute);
4110
+
4020
4111
  return success;
4021
4112
  };
4022
4113
 
@@ -4026,9 +4117,7 @@ var KeyBinding = function(editor) {
4026
4117
  };
4027
4118
 
4028
4119
  this.onTextInput = function(text) {
4029
- var success = this.$callKeyboardHandlers(-1, text);
4030
- if (!success)
4031
- this.$editor.commands.exec("insertstring", this.$editor, text);
4120
+ this.$callKeyboardHandlers(-1, text);
4032
4121
  };
4033
4122
 
4034
4123
  }).call(KeyBinding.prototype);
@@ -4852,7 +4941,7 @@ var Selection = function(session) {
4852
4941
  this.toSingleRange(data[0]);
4853
4942
  for (var i = data.length; i--; ) {
4854
4943
  var r = Range.fromPoints(data[i].start, data[i].end);
4855
- if (data.isBackwards)
4944
+ if (data[i].isBackwards)
4856
4945
  r.cursor = r.start;
4857
4946
  this.addRange(r, true);
4858
4947
  }
@@ -5048,6 +5137,9 @@ var Tokenizer = function(rules) {
5048
5137
  if (lastCapture.end != null && /^\)*$/.test(src.substr(lastCapture.end)))
5049
5138
  src = src.substring(0, lastCapture.start) + src.substr(lastCapture.end);
5050
5139
  }
5140
+ if (src.charAt(0) != "^") src = "^" + src;
5141
+ if (src.charAt(src.length - 1) != "$") src += "$";
5142
+
5051
5143
  return new RegExp(src, (flag||"").replace("g", ""));
5052
5144
  };
5053
5145
  this.getLineTokens = function(line, startState) {
@@ -5220,13 +5312,12 @@ var TextHighlightRules = function() {
5220
5312
  for (var i = 0; i < state.length; i++) {
5221
5313
  var rule = state[i];
5222
5314
  if (rule.next || rule.onMatch) {
5223
- if (typeof rule.next != "string") {
5224
- if (rule.nextState && rule.nextState.indexOf(prefix) !== 0)
5225
- rule.nextState = prefix + rule.nextState;
5226
- } else {
5315
+ if (typeof rule.next == "string") {
5227
5316
  if (rule.next.indexOf(prefix) !== 0)
5228
5317
  rule.next = prefix + rule.next;
5229
5318
  }
5319
+ if (rule.nextState && rule.nextState.indexOf(prefix) !== 0)
5320
+ rule.nextState = prefix + rule.nextState;
5230
5321
  }
5231
5322
  }
5232
5323
  this.$rules[prefix + key] = state;
@@ -5567,6 +5658,9 @@ var TokenIterator = function(session, initialRow, initialColumn) {
5567
5658
 
5568
5659
  return column;
5569
5660
  };
5661
+ this.getCurrentTokenPosition = function() {
5662
+ return {row: this.$row, column: this.getCurrentTokenColumn()};
5663
+ };
5570
5664
 
5571
5665
  }).call(TokenIterator.prototype);
5572
5666
 
@@ -5926,6 +6020,71 @@ var Mode = function() {
5926
6020
  exports.Mode = Mode;
5927
6021
  });
5928
6022
 
6023
+ define("ace/apply_delta",["require","exports","module"], function(require, exports, module) {
6024
+ "use strict";
6025
+
6026
+ function throwDeltaError(delta, errorText){
6027
+ console.log("Invalid Delta:", delta);
6028
+ throw "Invalid Delta: " + errorText;
6029
+ }
6030
+
6031
+ function positionInDocument(docLines, position) {
6032
+ return position.row >= 0 && position.row < docLines.length &&
6033
+ position.column >= 0 && position.column <= docLines[position.row].length;
6034
+ }
6035
+
6036
+ function validateDelta(docLines, delta) {
6037
+ if (delta.action != "insert" && delta.action != "remove")
6038
+ throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
6039
+ if (!(delta.lines instanceof Array))
6040
+ throwDeltaError(delta, "delta.lines must be an Array");
6041
+ if (!delta.start || !delta.end)
6042
+ throwDeltaError(delta, "delta.start/end must be an present");
6043
+ var start = delta.start;
6044
+ if (!positionInDocument(docLines, delta.start))
6045
+ throwDeltaError(delta, "delta.start must be contained in document");
6046
+ var end = delta.end;
6047
+ if (delta.action == "remove" && !positionInDocument(docLines, end))
6048
+ throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
6049
+ var numRangeRows = end.row - start.row;
6050
+ var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
6051
+ if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
6052
+ throwDeltaError(delta, "delta.range must match delta lines");
6053
+ }
6054
+
6055
+ exports.applyDelta = function(docLines, delta, doNotValidate) {
6056
+
6057
+ var row = delta.start.row;
6058
+ var startColumn = delta.start.column;
6059
+ var line = docLines[row] || "";
6060
+ switch (delta.action) {
6061
+ case "insert":
6062
+ var lines = delta.lines;
6063
+ if (lines.length === 1) {
6064
+ docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
6065
+ } else {
6066
+ var args = [row, 1].concat(delta.lines);
6067
+ docLines.splice.apply(docLines, args);
6068
+ docLines[row] = line.substring(0, startColumn) + docLines[row];
6069
+ docLines[row + delta.lines.length - 1] += line.substring(startColumn);
6070
+ }
6071
+ break;
6072
+ case "remove":
6073
+ var endColumn = delta.end.column;
6074
+ var endRow = delta.end.row;
6075
+ if (row === endRow) {
6076
+ docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
6077
+ } else {
6078
+ docLines.splice(
6079
+ row, endRow - row + 1,
6080
+ line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
6081
+ );
6082
+ }
6083
+ break;
6084
+ }
6085
+ }
6086
+ });
6087
+
5929
6088
  define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
5930
6089
  "use strict";
5931
6090
 
@@ -5952,70 +6111,46 @@ var Anchor = exports.Anchor = function(doc, row, column) {
5952
6111
  return this.document;
5953
6112
  };
5954
6113
  this.$insertRight = false;
5955
- this.onChange = function(e) {
5956
- var delta = e.data;
5957
- var range = delta.range;
5958
-
5959
- if (range.start.row == range.end.row && range.start.row != this.row)
5960
- return;
5961
-
5962
- if (range.start.row > this.row)
6114
+ this.onChange = function(delta) {
6115
+ if (delta.start.row == delta.end.row && delta.start.row != this.row)
5963
6116
  return;
5964
6117
 
5965
- if (range.start.row == this.row && range.start.column > this.column)
6118
+ if (delta.start.row > this.row)
5966
6119
  return;
5967
-
5968
- var row = this.row;
5969
- var column = this.column;
5970
- var start = range.start;
5971
- var end = range.end;
5972
-
5973
- if (delta.action === "insertText") {
5974
- if (start.row === row && start.column <= column) {
5975
- if (start.column === column && this.$insertRight) {
5976
- } else if (start.row === end.row) {
5977
- column += end.column - start.column;
5978
- } else {
5979
- column -= start.column;
5980
- row += end.row - start.row;
5981
- }
5982
- } else if (start.row !== end.row && start.row < row) {
5983
- row += end.row - start.row;
5984
- }
5985
- } else if (delta.action === "insertLines") {
5986
- if (start.row === row && column === 0 && this.$insertRight) {
5987
- }
5988
- else if (start.row <= row) {
5989
- row += end.row - start.row;
5990
- }
5991
- } else if (delta.action === "removeText") {
5992
- if (start.row === row && start.column < column) {
5993
- if (end.column >= column)
5994
- column = start.column;
5995
- else
5996
- column = Math.max(0, column - (end.column - start.column));
5997
-
5998
- } else if (start.row !== end.row && start.row < row) {
5999
- if (end.row === row)
6000
- column = Math.max(0, column - end.column) + start.column;
6001
- row -= (end.row - start.row);
6002
- } else if (end.row === row) {
6003
- row -= end.row - start.row;
6004
- column = Math.max(0, column - end.column) + start.column;
6005
- }
6006
- } else if (delta.action == "removeLines") {
6007
- if (start.row <= row) {
6008
- if (end.row <= row)
6009
- row -= end.row - start.row;
6010
- else {
6011
- row = start.row;
6012
- column = 0;
6013
- }
6014
- }
6015
- }
6016
-
6017
- this.setPosition(row, column, true);
6120
+
6121
+ var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
6122
+ this.setPosition(point.row, point.column, true);
6018
6123
  };
6124
+
6125
+ function $pointsInOrder(point1, point2, equalPointsInOrder) {
6126
+ var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
6127
+ return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
6128
+ }
6129
+
6130
+ function $getTransformedPoint(delta, point, moveIfEqual) {
6131
+ var deltaIsInsert = delta.action == "insert";
6132
+ var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
6133
+ var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
6134
+ var deltaStart = delta.start;
6135
+ var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
6136
+ if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
6137
+ return {
6138
+ row: point.row,
6139
+ column: point.column
6140
+ };
6141
+ }
6142
+ if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
6143
+ return {
6144
+ row: point.row + deltaRowShift,
6145
+ column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
6146
+ };
6147
+ }
6148
+
6149
+ return {
6150
+ row: deltaStart.row,
6151
+ column: deltaStart.column
6152
+ };
6153
+ }
6019
6154
  this.setPosition = function(row, column, noClip) {
6020
6155
  var pos;
6021
6156
  if (noClip) {
@@ -6075,22 +6210,23 @@ var Anchor = exports.Anchor = function(doc, row, column) {
6075
6210
 
6076
6211
  });
6077
6212
 
6078
- define("ace/document",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module) {
6213
+ define("ace/document",["require","exports","module","ace/lib/oop","ace/apply_delta","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module) {
6079
6214
  "use strict";
6080
6215
 
6081
6216
  var oop = require("./lib/oop");
6217
+ var applyDelta = require("./apply_delta").applyDelta;
6082
6218
  var EventEmitter = require("./lib/event_emitter").EventEmitter;
6083
6219
  var Range = require("./range").Range;
6084
6220
  var Anchor = require("./anchor").Anchor;
6085
6221
 
6086
- var Document = function(text) {
6087
- this.$lines = [];
6088
- if (text.length === 0) {
6222
+ var Document = function(textOrLines) {
6223
+ this.$lines = [""];
6224
+ if (textOrLines.length === 0) {
6089
6225
  this.$lines = [""];
6090
- } else if (Array.isArray(text)) {
6091
- this._insertLines(0, text);
6226
+ } else if (Array.isArray(textOrLines)) {
6227
+ this.insertMergedLines({row: 0, column: 0}, textOrLines);
6092
6228
  } else {
6093
- this.insert({row: 0, column:0}, text);
6229
+ this.insert({row: 0, column:0}, textOrLines);
6094
6230
  }
6095
6231
  };
6096
6232
 
@@ -6098,9 +6234,9 @@ var Document = function(text) {
6098
6234
 
6099
6235
  oop.implement(this, EventEmitter);
6100
6236
  this.setValue = function(text) {
6101
- var len = this.getLength();
6102
- this.remove(new Range(0, 0, len, this.getLine(len-1).length));
6103
- this.insert({row: 0, column:0}, text);
6237
+ var len = this.getLength() - 1;
6238
+ this.remove(new Range(0, 0, len, this.getLine(len).length));
6239
+ this.insert({row: 0, column: 0}, text);
6104
6240
  };
6105
6241
  this.getValue = function() {
6106
6242
  return this.getAllLines().join(this.getNewLineCharacter());
@@ -6108,14 +6244,15 @@ var Document = function(text) {
6108
6244
  this.createAnchor = function(row, column) {
6109
6245
  return new Anchor(this, row, column);
6110
6246
  };
6111
- if ("aaa".split(/a/).length === 0)
6247
+ if ("aaa".split(/a/).length === 0) {
6112
6248
  this.$split = function(text) {
6113
6249
  return text.replace(/\r\n|\r/g, "\n").split("\n");
6114
6250
  };
6115
- else
6251
+ } else {
6116
6252
  this.$split = function(text) {
6117
6253
  return text.split(/\r\n|\r|\n/);
6118
6254
  };
6255
+ }
6119
6256
 
6120
6257
 
6121
6258
  this.$detectNewLine = function(text) {
@@ -6162,251 +6299,246 @@ var Document = function(text) {
6162
6299
  return this.$lines.length;
6163
6300
  };
6164
6301
  this.getTextRange = function(range) {
6165
- if (range.start.row == range.end.row) {
6166
- return this.getLine(range.start.row)
6167
- .substring(range.start.column, range.end.column);
6302
+ return this.getLinesForRange(range).join(this.getNewLineCharacter());
6303
+ };
6304
+ this.getLinesForRange = function(range) {
6305
+ var lines;
6306
+ if (range.start.row === range.end.row) {
6307
+ lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
6308
+ } else {
6309
+ lines = this.getLines(range.start.row, range.end.row);
6310
+ lines[0] = (lines[0] || "").substring(range.start.column);
6311
+ var l = lines.length - 1;
6312
+ if (range.end.row - range.start.row == l)
6313
+ lines[l] = lines[l].substring(0, range.end.column);
6168
6314
  }
6169
- var lines = this.getLines(range.start.row, range.end.row);
6170
- lines[0] = (lines[0] || "").substring(range.start.column);
6171
- var l = lines.length - 1;
6172
- if (range.end.row - range.start.row == l)
6173
- lines[l] = lines[l].substring(0, range.end.column);
6174
- return lines.join(this.getNewLineCharacter());
6315
+ return lines;
6175
6316
  };
6176
-
6177
- this.$clipPosition = function(position) {
6178
- var length = this.getLength();
6179
- if (position.row >= length) {
6180
- position.row = Math.max(0, length - 1);
6181
- position.column = this.getLine(length-1).length;
6182
- } else if (position.row < 0)
6183
- position.row = 0;
6184
- return position;
6317
+ this.insertLines = function(row, lines) {
6318
+ console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
6319
+ return this.insertFullLines(row, lines);
6320
+ };
6321
+ this.removeLines = function(firstRow, lastRow) {
6322
+ console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
6323
+ return this.removeFullLines(firstRow, lastRow);
6324
+ };
6325
+ this.insertNewLine = function(position) {
6326
+ console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, [\'\', \'\']) instead.");
6327
+ return this.insertMergedLines(position, ["", ""]);
6185
6328
  };
6186
6329
  this.insert = function(position, text) {
6187
- if (!text || text.length === 0)
6188
- return position;
6189
-
6190
- position = this.$clipPosition(position);
6191
6330
  if (this.getLength() <= 1)
6192
6331
  this.$detectNewLine(text);
6193
-
6194
- var lines = this.$split(text);
6195
- var firstLine = lines.splice(0, 1)[0];
6196
- var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
6197
-
6198
- position = this.insertInLine(position, firstLine);
6199
- if (lastLine !== null) {
6200
- position = this.insertNewLine(position); // terminate first line
6201
- position = this._insertLines(position.row, lines);
6202
- position = this.insertInLine(position, lastLine || "");
6332
+
6333
+ return this.insertMergedLines(position, this.$split(text));
6334
+ };
6335
+ this.insertInLine = function(position, text) {
6336
+ var start = this.clippedPos(position.row, position.column);
6337
+ var end = this.pos(position.row, position.column + text.length);
6338
+
6339
+ this.applyDelta({
6340
+ start: start,
6341
+ end: end,
6342
+ action: "insert",
6343
+ lines: [text]
6344
+ }, true);
6345
+
6346
+ return this.clonePos(end);
6347
+ };
6348
+
6349
+ this.clippedPos = function(row, column) {
6350
+ var length = this.getLength();
6351
+ if (row === undefined) {
6352
+ row = length;
6353
+ } else if (row < 0) {
6354
+ row = 0;
6355
+ } else if (row >= length) {
6356
+ row = length - 1;
6357
+ column = undefined;
6203
6358
  }
6204
- return position;
6359
+ var line = this.getLine(row);
6360
+ if (column == undefined)
6361
+ column = line.length;
6362
+ column = Math.min(Math.max(column, 0), line.length);
6363
+ return {row: row, column: column};
6205
6364
  };
6206
- this.insertLines = function(row, lines) {
6207
- if (row >= this.getLength())
6208
- return this.insert({row: row, column: 0}, "\n" + lines.join("\n"));
6209
- return this._insertLines(Math.max(row, 0), lines);
6210
- };
6211
- this._insertLines = function(row, lines) {
6212
- if (lines.length == 0)
6213
- return {row: row, column: 0};
6214
- while (lines.length > 20000) {
6215
- var end = this._insertLines(row, lines.slice(0, 20000));
6216
- lines = lines.slice(20000);
6217
- row = end.row;
6218
- }
6219
-
6220
- var args = [row, 0];
6221
- args.push.apply(args, lines);
6222
- this.$lines.splice.apply(this.$lines, args);
6223
-
6224
- var range = new Range(row, 0, row + lines.length, 0);
6225
- var delta = {
6226
- action: "insertLines",
6227
- range: range,
6228
- lines: lines
6229
- };
6230
- this._signal("change", { data: delta });
6231
- return range.end;
6365
+
6366
+ this.clonePos = function(pos) {
6367
+ return {row: pos.row, column: pos.column};
6232
6368
  };
6233
- this.insertNewLine = function(position) {
6234
- position = this.$clipPosition(position);
6235
- var line = this.$lines[position.row] || "";
6236
-
6237
- this.$lines[position.row] = line.substring(0, position.column);
6238
- this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
6239
-
6240
- var end = {
6241
- row : position.row + 1,
6242
- column : 0
6243
- };
6244
-
6245
- var delta = {
6246
- action: "insertText",
6247
- range: Range.fromPoints(position, end),
6248
- text: this.getNewLineCharacter()
6249
- };
6250
- this._signal("change", { data: delta });
6251
-
6252
- return end;
6369
+
6370
+ this.pos = function(row, column) {
6371
+ return {row: row, column: column};
6253
6372
  };
6254
- this.insertInLine = function(position, text) {
6255
- if (text.length == 0)
6256
- return position;
6257
-
6258
- var line = this.$lines[position.row] || "";
6259
-
6260
- this.$lines[position.row] = line.substring(0, position.column) + text
6261
- + line.substring(position.column);
6262
-
6373
+
6374
+ this.$clipPosition = function(position) {
6375
+ var length = this.getLength();
6376
+ if (position.row >= length) {
6377
+ position.row = Math.max(0, length - 1);
6378
+ position.column = this.getLine(length - 1).length;
6379
+ } else {
6380
+ position.row = Math.max(0, position.row);
6381
+ position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
6382
+ }
6383
+ return position;
6384
+ };
6385
+ this.insertFullLines = function(row, lines) {
6386
+ row = Math.min(Math.max(row, 0), this.getLength());
6387
+ var column = 0;
6388
+ if (row < this.getLength()) {
6389
+ lines = lines.concat([""]);
6390
+ column = 0;
6391
+ } else {
6392
+ lines = [""].concat(lines);
6393
+ row--;
6394
+ column = this.$lines[row].length;
6395
+ }
6396
+ this.insertMergedLines({row: row, column: column}, lines);
6397
+ };
6398
+ this.insertMergedLines = function(position, lines) {
6399
+ var start = this.clippedPos(position.row, position.column);
6263
6400
  var end = {
6264
- row : position.row,
6265
- column : position.column + text.length
6401
+ row: start.row + lines.length - 1,
6402
+ column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
6266
6403
  };
6267
-
6268
- var delta = {
6269
- action: "insertText",
6270
- range: Range.fromPoints(position, end),
6271
- text: text
6272
- };
6273
- this._signal("change", { data: delta });
6274
-
6275
- return end;
6404
+
6405
+ this.applyDelta({
6406
+ start: start,
6407
+ end: end,
6408
+ action: "insert",
6409
+ lines: lines
6410
+ });
6411
+
6412
+ return this.clonePos(end);
6276
6413
  };
6277
6414
  this.remove = function(range) {
6278
- if (!(range instanceof Range))
6279
- range = Range.fromPoints(range.start, range.end);
6280
- range.start = this.$clipPosition(range.start);
6281
- range.end = this.$clipPosition(range.end);
6282
-
6283
- if (range.isEmpty())
6284
- return range.start;
6285
-
6286
- var firstRow = range.start.row;
6287
- var lastRow = range.end.row;
6288
-
6289
- if (range.isMultiLine()) {
6290
- var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
6291
- var lastFullRow = lastRow - 1;
6292
-
6293
- if (range.end.column > 0)
6294
- this.removeInLine(lastRow, 0, range.end.column);
6295
-
6296
- if (lastFullRow >= firstFullRow)
6297
- this._removeLines(firstFullRow, lastFullRow);
6298
-
6299
- if (firstFullRow != firstRow) {
6300
- this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
6301
- this.removeNewLine(range.start.row);
6302
- }
6303
- }
6304
- else {
6305
- this.removeInLine(firstRow, range.start.column, range.end.column);
6306
- }
6307
- return range.start;
6415
+ var start = this.clippedPos(range.start.row, range.start.column);
6416
+ var end = this.clippedPos(range.end.row, range.end.column);
6417
+ this.applyDelta({
6418
+ start: start,
6419
+ end: end,
6420
+ action: "remove",
6421
+ lines: this.getLinesForRange({start: start, end: end})
6422
+ });
6423
+ return this.clonePos(start);
6308
6424
  };
6309
6425
  this.removeInLine = function(row, startColumn, endColumn) {
6310
- if (startColumn == endColumn)
6311
- return;
6312
-
6313
- var range = new Range(row, startColumn, row, endColumn);
6314
- var line = this.getLine(row);
6315
- var removed = line.substring(startColumn, endColumn);
6316
- var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
6317
- this.$lines.splice(row, 1, newLine);
6318
-
6319
- var delta = {
6320
- action: "removeText",
6321
- range: range,
6322
- text: removed
6323
- };
6324
- this._signal("change", { data: delta });
6325
- return range.start;
6326
- };
6327
- this.removeLines = function(firstRow, lastRow) {
6328
- if (firstRow < 0 || lastRow >= this.getLength())
6329
- return this.remove(new Range(firstRow, 0, lastRow + 1, 0));
6330
- return this._removeLines(firstRow, lastRow);
6331
- };
6332
-
6333
- this._removeLines = function(firstRow, lastRow) {
6334
- var range = new Range(firstRow, 0, lastRow + 1, 0);
6335
- var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
6336
-
6337
- var delta = {
6338
- action: "removeLines",
6339
- range: range,
6340
- nl: this.getNewLineCharacter(),
6341
- lines: removed
6342
- };
6343
- this._signal("change", { data: delta });
6344
- return removed;
6426
+ var start = this.clippedPos(row, startColumn);
6427
+ var end = this.clippedPos(row, endColumn);
6428
+
6429
+ this.applyDelta({
6430
+ start: start,
6431
+ end: end,
6432
+ action: "remove",
6433
+ lines: this.getLinesForRange({start: start, end: end})
6434
+ }, true);
6435
+
6436
+ return this.clonePos(start);
6437
+ };
6438
+ this.removeFullLines = function(firstRow, lastRow) {
6439
+ firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
6440
+ lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
6441
+ var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
6442
+ var deleteLastNewLine = lastRow < this.getLength() - 1;
6443
+ var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
6444
+ var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
6445
+ var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
6446
+ var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
6447
+ var range = new Range(startRow, startCol, endRow, endCol);
6448
+ var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
6449
+
6450
+ this.applyDelta({
6451
+ start: range.start,
6452
+ end: range.end,
6453
+ action: "remove",
6454
+ lines: this.getLinesForRange(range)
6455
+ });
6456
+ return deletedLines;
6345
6457
  };
6346
6458
  this.removeNewLine = function(row) {
6347
- var firstLine = this.getLine(row);
6348
- var secondLine = this.getLine(row+1);
6349
-
6350
- var range = new Range(row, firstLine.length, row+1, 0);
6351
- var line = firstLine + secondLine;
6352
-
6353
- this.$lines.splice(row, 2, line);
6354
-
6355
- var delta = {
6356
- action: "removeText",
6357
- range: range,
6358
- text: this.getNewLineCharacter()
6359
- };
6360
- this._signal("change", { data: delta });
6459
+ if (row < this.getLength() - 1 && row >= 0) {
6460
+ this.applyDelta({
6461
+ start: this.pos(row, this.getLine(row).length),
6462
+ end: this.pos(row + 1, 0),
6463
+ action: "remove",
6464
+ lines: ["", ""]
6465
+ });
6466
+ }
6361
6467
  };
6362
6468
  this.replace = function(range, text) {
6363
6469
  if (!(range instanceof Range))
6364
6470
  range = Range.fromPoints(range.start, range.end);
6365
- if (text.length == 0 && range.isEmpty())
6471
+ if (text.length === 0 && range.isEmpty())
6366
6472
  return range.start;
6367
6473
  if (text == this.getTextRange(range))
6368
6474
  return range.end;
6369
6475
 
6370
6476
  this.remove(range);
6477
+ var end;
6371
6478
  if (text) {
6372
- var end = this.insert(range.start, text);
6479
+ end = this.insert(range.start, text);
6373
6480
  }
6374
6481
  else {
6375
6482
  end = range.start;
6376
6483
  }
6377
-
6484
+
6378
6485
  return end;
6379
6486
  };
6380
6487
  this.applyDeltas = function(deltas) {
6381
6488
  for (var i=0; i<deltas.length; i++) {
6382
- var delta = deltas[i];
6383
- var range = Range.fromPoints(delta.range.start, delta.range.end);
6384
-
6385
- if (delta.action == "insertLines")
6386
- this.insertLines(range.start.row, delta.lines);
6387
- else if (delta.action == "insertText")
6388
- this.insert(range.start, delta.text);
6389
- else if (delta.action == "removeLines")
6390
- this._removeLines(range.start.row, range.end.row - 1);
6391
- else if (delta.action == "removeText")
6392
- this.remove(range);
6489
+ this.applyDelta(deltas[i]);
6393
6490
  }
6394
6491
  };
6395
6492
  this.revertDeltas = function(deltas) {
6396
6493
  for (var i=deltas.length-1; i>=0; i--) {
6397
- var delta = deltas[i];
6398
-
6399
- var range = Range.fromPoints(delta.range.start, delta.range.end);
6400
-
6401
- if (delta.action == "insertLines")
6402
- this._removeLines(range.start.row, range.end.row - 1);
6403
- else if (delta.action == "insertText")
6404
- this.remove(range);
6405
- else if (delta.action == "removeLines")
6406
- this._insertLines(range.start.row, delta.lines);
6407
- else if (delta.action == "removeText")
6408
- this.insert(range.start, delta.text);
6494
+ this.revertDelta(deltas[i]);
6495
+ }
6496
+ };
6497
+ this.applyDelta = function(delta, doNotValidate) {
6498
+ var isInsert = delta.action == "insert";
6499
+ if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
6500
+ : !Range.comparePoints(delta.start, delta.end)) {
6501
+ return;
6409
6502
  }
6503
+
6504
+ if (isInsert && delta.lines.length > 20000)
6505
+ this.$splitAndapplyLargeDelta(delta, 20000);
6506
+ applyDelta(this.$lines, delta, doNotValidate);
6507
+ this._signal("change", delta);
6508
+ };
6509
+
6510
+ this.$splitAndapplyLargeDelta = function(delta, MAX) {
6511
+ var lines = delta.lines;
6512
+ var l = lines.length;
6513
+ var row = delta.start.row;
6514
+ var column = delta.start.column;
6515
+ var from = 0, to = 0;
6516
+ do {
6517
+ from = to;
6518
+ to += MAX - 1;
6519
+ var chunk = lines.slice(from, to);
6520
+ if (to > l) {
6521
+ delta.lines = chunk;
6522
+ delta.start.row = row + from;
6523
+ delta.start.column = column;
6524
+ break;
6525
+ }
6526
+ chunk.push("");
6527
+ this.applyDelta({
6528
+ start: this.pos(row + from, column),
6529
+ end: this.pos(row + to, column = 0),
6530
+ action: delta.action,
6531
+ lines: chunk
6532
+ }, true);
6533
+ } while(true);
6534
+ };
6535
+ this.revertDelta = function(delta) {
6536
+ this.applyDelta({
6537
+ start: this.clonePos(delta.start),
6538
+ end: this.clonePos(delta.end),
6539
+ action: (delta.action == "insert" ? "remove" : "insert"),
6540
+ lines: delta.lines.slice()
6541
+ });
6410
6542
  };
6411
6543
  this.indexToPosition = function(index, startRow) {
6412
6544
  var lines = this.$lines || this.getAllLines();
@@ -6457,11 +6589,10 @@ var BackgroundTokenizer = function(tokenizer, editor) {
6457
6589
  var endLine = -1;
6458
6590
  var doc = self.doc;
6459
6591
 
6592
+ var startLine = currentLine;
6460
6593
  while (self.lines[currentLine])
6461
6594
  currentLine++;
6462
-
6463
- var startLine = currentLine;
6464
-
6595
+
6465
6596
  var len = doc.getLength();
6466
6597
  var processedLines = 0;
6467
6598
  self.running = false;
@@ -6523,13 +6654,12 @@ var BackgroundTokenizer = function(tokenizer, editor) {
6523
6654
  }
6524
6655
 
6525
6656
  this.$updateOnChange = function(delta) {
6526
- var range = delta.range;
6527
- var startRow = range.start.row;
6528
- var len = range.end.row - startRow;
6657
+ var startRow = delta.start.row;
6658
+ var len = delta.end.row - startRow;
6529
6659
 
6530
6660
  if (len === 0) {
6531
6661
  this.lines[startRow] = null;
6532
- } else if (delta.action == "removeText" || delta.action == "removeLines") {
6662
+ } else if (delta.action == "remove") {
6533
6663
  this.lines.splice(startRow, len + 1, null);
6534
6664
  this.states.splice(startRow, len + 1, null);
6535
6665
  } else {
@@ -7001,14 +7131,13 @@ var RangeList = function() {
7001
7131
  this.session = null;
7002
7132
  };
7003
7133
 
7004
- this.$onChange = function(e) {
7005
- var changeRange = e.data.range;
7006
- if (e.data.action[0] == "i"){
7007
- var start = changeRange.start;
7008
- var end = changeRange.end;
7134
+ this.$onChange = function(delta) {
7135
+ if (delta.action == "insert"){
7136
+ var start = delta.start;
7137
+ var end = delta.end;
7009
7138
  } else {
7010
- var end = changeRange.start;
7011
- var start = changeRange.end;
7139
+ var end = delta.start;
7140
+ var start = delta.end;
7012
7141
  }
7013
7142
  var startRow = start.row;
7014
7143
  var endRow = end.row;
@@ -7238,7 +7367,7 @@ function Folding() {
7238
7367
  var folds = this.getFoldsInRange(ranges);
7239
7368
  }
7240
7369
  return folds;
7241
- }
7370
+ };
7242
7371
  this.getAllFolds = function() {
7243
7372
  var folds = [];
7244
7373
  var foldLines = this.$foldData;
@@ -7323,15 +7452,15 @@ function Folding() {
7323
7452
  end = foldLine.end.row,
7324
7453
  start = foldLine.start.row;
7325
7454
  if (end >= last) {
7326
- if(start < last) {
7327
- if(start >= first)
7455
+ if (start < last) {
7456
+ if (start >= first)
7328
7457
  rowCount -= last-start;
7329
7458
  else
7330
- rowCount = 0;//in one fold
7459
+ rowCount = 0; // in one fold
7331
7460
  }
7332
7461
  break;
7333
- } else if(end >= first){
7334
- if (start >= first) //fold inside range
7462
+ } else if (end >= first){
7463
+ if (start >= first) // fold inside range
7335
7464
  rowCount -= end-start;
7336
7465
  else
7337
7466
  rowCount -= end-first+1;
@@ -7416,7 +7545,7 @@ function Folding() {
7416
7545
  else
7417
7546
  this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row);
7418
7547
  this.$modified = true;
7419
- this._emit("changeFold", { data: fold, action: "add" });
7548
+ this._signal("changeFold", { data: fold, action: "add" });
7420
7549
 
7421
7550
  return fold;
7422
7551
  };
@@ -7465,7 +7594,7 @@ function Folding() {
7465
7594
  this.$updateRowLengthCache(startRow, endRow);
7466
7595
  }
7467
7596
  this.$modified = true;
7468
- this._emit("changeFold", { data: fold, action: "remove" });
7597
+ this._signal("changeFold", { data: fold, action: "remove" });
7469
7598
  };
7470
7599
 
7471
7600
  this.removeFolds = function(folds) {
@@ -7644,7 +7773,7 @@ function Folding() {
7644
7773
  var placeholder = "...";
7645
7774
  if (!range.isMultiLine()) {
7646
7775
  placeholder = this.getTextRange(range);
7647
- if(placeholder.length < 4)
7776
+ if (placeholder.length < 4)
7648
7777
  return;
7649
7778
  placeholder = placeholder.trim().substring(0, 2) + "..";
7650
7779
  }
@@ -7661,7 +7790,7 @@ function Folding() {
7661
7790
  if (dir != 1) {
7662
7791
  do {
7663
7792
  token = iterator.stepBackward();
7664
- } while(token && re.test(token.type));
7793
+ } while (token && re.test(token.type));
7665
7794
  iterator.stepForward();
7666
7795
  }
7667
7796
 
@@ -7673,7 +7802,7 @@ function Folding() {
7673
7802
  if (dir != -1) {
7674
7803
  do {
7675
7804
  token = iterator.stepForward();
7676
- } while(token && re.test(token.type));
7805
+ } while (token && re.test(token.type));
7677
7806
  token = iterator.stepBackward();
7678
7807
  } else
7679
7808
  token = iterator.getCurrentToken();
@@ -7742,7 +7871,7 @@ function Folding() {
7742
7871
 
7743
7872
  this.off('change', this.$updateFoldWidgets);
7744
7873
  this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
7745
- this._emit("changeAnnotation");
7874
+ this._signal("changeAnnotation");
7746
7875
 
7747
7876
  if (!foldMode || this.$foldStyle == "manual") {
7748
7877
  this.foldWidgets = null;
@@ -7784,7 +7913,7 @@ function Folding() {
7784
7913
  range: i !== -1 && range,
7785
7914
  firstRange: firstRange
7786
7915
  };
7787
- }
7916
+ };
7788
7917
 
7789
7918
  this.onFoldWidgetClick = function(row, e) {
7790
7919
  e = e.domEvent;
@@ -7796,7 +7925,7 @@ function Folding() {
7796
7925
 
7797
7926
  var range = this.$toggleFoldWidget(row, options);
7798
7927
  if (!range) {
7799
- var el = (e.target || e.srcElement)
7928
+ var el = (e.target || e.srcElement);
7800
7929
  if (el && /ace_fold-widget/.test(el.className))
7801
7930
  el.className += " ace_invalid";
7802
7931
  }
@@ -7871,15 +8000,13 @@ function Folding() {
7871
8000
  }
7872
8001
  };
7873
8002
 
7874
- this.updateFoldWidgets = function(e) {
7875
- var delta = e.data;
7876
- var range = delta.range;
7877
- var firstRow = range.start.row;
7878
- var len = range.end.row - firstRow;
8003
+ this.updateFoldWidgets = function(delta) {
8004
+ var firstRow = delta.start.row;
8005
+ var len = delta.end.row - firstRow;
7879
8006
 
7880
8007
  if (len === 0) {
7881
8008
  this.foldWidgets[firstRow] = null;
7882
- } else if (delta.action == "removeText" || delta.action == "removeLines") {
8009
+ } else if (delta.action == 'remove') {
7883
8010
  this.foldWidgets.splice(firstRow, len + 1, null);
7884
8011
  } else {
7885
8012
  var args = Array(len + 1);
@@ -7893,7 +8020,7 @@ function Folding() {
7893
8020
  if (this.foldWidgets.length > rows.first)
7894
8021
  this.foldWidgets.splice(rows.first, this.foldWidgets.length);
7895
8022
  }
7896
- }
8023
+ };
7897
8024
  }
7898
8025
 
7899
8026
  exports.Folding = Folding;
@@ -7989,7 +8116,7 @@ function BracketMatch() {
7989
8116
  typeRe = new RegExp(
7990
8117
  "(\\.?" +
7991
8118
  token.type.replace(".", "\\.").replace("rparen", ".paren")
7992
- .replace(/\b(?:end|start|begin)\b/, "")
8119
+ .replace(/\b(?:end)\b/, "(?:start|begin|end)")
7993
8120
  + ")+"
7994
8121
  );
7995
8122
  }
@@ -8041,7 +8168,7 @@ function BracketMatch() {
8041
8168
  typeRe = new RegExp(
8042
8169
  "(\\.?" +
8043
8170
  token.type.replace(".", "\\.").replace("lparen", ".paren")
8044
- .replace(/\b(?:end|start|begin)\b/, "")
8171
+ .replace(/\b(?:start|begin)\b/, "(?:start|begin|end)")
8045
8172
  + ")+"
8046
8173
  );
8047
8174
  }
@@ -8107,7 +8234,7 @@ var EditSession = function(text, mode) {
8107
8234
  this.$foldData = [];
8108
8235
  this.$foldData.toString = function() {
8109
8236
  return this.join("\n");
8110
- }
8237
+ };
8111
8238
  this.on("changeFold", this.onChangeFold.bind(this));
8112
8239
  this.$onChange = this.onChange.bind(this);
8113
8240
 
@@ -8188,13 +8315,12 @@ var EditSession = function(text, mode) {
8188
8315
  this.$resetRowCache(fold.start.row);
8189
8316
  };
8190
8317
 
8191
- this.onChange = function(e) {
8192
- var delta = e.data;
8318
+ this.onChange = function(delta) {
8193
8319
  this.$modified = true;
8194
8320
 
8195
- this.$resetRowCache(delta.range.start.row);
8321
+ this.$resetRowCache(delta.start.row);
8196
8322
 
8197
- var removedFolds = this.$updateInternalDataOnChange(e);
8323
+ var removedFolds = this.$updateInternalDataOnChange(delta);
8198
8324
  if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
8199
8325
  this.$deltasDoc.push(delta);
8200
8326
  if (removedFolds && removedFolds.length != 0) {
@@ -8208,7 +8334,7 @@ var EditSession = function(text, mode) {
8208
8334
  }
8209
8335
 
8210
8336
  this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
8211
- this._signal("change", e);
8337
+ this._signal("change", delta);
8212
8338
  };
8213
8339
  this.setValue = function(text) {
8214
8340
  this.doc.setValue(text);
@@ -8724,6 +8850,9 @@ var EditSession = function(text, mode) {
8724
8850
  this.remove = function(range) {
8725
8851
  return this.doc.remove(range);
8726
8852
  };
8853
+ this.removeFullLines = function(firstRow, lastRow){
8854
+ return this.doc.removeFullLines(firstRow, lastRow);
8855
+ };
8727
8856
  this.undoChanges = function(deltas, dontSelect) {
8728
8857
  if (!deltas.length)
8729
8858
  return;
@@ -8776,39 +8905,36 @@ var EditSession = function(text, mode) {
8776
8905
 
8777
8906
  this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
8778
8907
  function isInsert(delta) {
8779
- var insert =
8780
- delta.action === "insertText" || delta.action === "insertLines";
8781
- return isUndo ? !insert : insert;
8908
+ return isUndo ? delta.action !== "insert" : delta.action === "insert";
8782
8909
  }
8783
8910
 
8784
8911
  var delta = deltas[0];
8785
8912
  var range, point;
8786
8913
  var lastDeltaIsInsert = false;
8787
8914
  if (isInsert(delta)) {
8788
- range = Range.fromPoints(delta.range.start, delta.range.end);
8915
+ range = Range.fromPoints(delta.start, delta.end);
8789
8916
  lastDeltaIsInsert = true;
8790
8917
  } else {
8791
- range = Range.fromPoints(delta.range.start, delta.range.start);
8918
+ range = Range.fromPoints(delta.start, delta.start);
8792
8919
  lastDeltaIsInsert = false;
8793
8920
  }
8794
8921
 
8795
8922
  for (var i = 1; i < deltas.length; i++) {
8796
8923
  delta = deltas[i];
8797
8924
  if (isInsert(delta)) {
8798
- point = delta.range.start;
8925
+ point = delta.start;
8799
8926
  if (range.compare(point.row, point.column) == -1) {
8800
- range.setStart(delta.range.start);
8927
+ range.setStart(point);
8801
8928
  }
8802
- point = delta.range.end;
8929
+ point = delta.end;
8803
8930
  if (range.compare(point.row, point.column) == 1) {
8804
- range.setEnd(delta.range.end);
8931
+ range.setEnd(point);
8805
8932
  }
8806
8933
  lastDeltaIsInsert = true;
8807
8934
  } else {
8808
- point = delta.range.start;
8935
+ point = delta.start;
8809
8936
  if (range.compare(point.row, point.column) == -1) {
8810
- range =
8811
- Range.fromPoints(delta.range.start, delta.range.start);
8937
+ range = Range.fromPoints(delta.start, delta.start);
8812
8938
  }
8813
8939
  lastDeltaIsInsert = false;
8814
8940
  }
@@ -8876,7 +9002,7 @@ var EditSession = function(text, mode) {
8876
9002
  this.indentRows = function(startRow, endRow, indentString) {
8877
9003
  indentString = indentString.replace(/\t/g, this.getTabString());
8878
9004
  for (var row=startRow; row<=endRow; row++)
8879
- this.insert({row: row, column:0}, indentString);
9005
+ this.doc.insertInLine({row: row, column: 0}, indentString);
8880
9006
  };
8881
9007
  this.outdentRows = function (range) {
8882
9008
  var rowRange = range.collapseRows();
@@ -8926,11 +9052,11 @@ var EditSession = function(text, mode) {
8926
9052
  x.end.row += diff;
8927
9053
  return x;
8928
9054
  });
8929
-
9055
+
8930
9056
  var lines = dir == 0
8931
9057
  ? this.doc.getLines(firstRow, lastRow)
8932
- : this.doc.removeLines(firstRow, lastRow);
8933
- this.doc.insertLines(firstRow+diff, lines);
9058
+ : this.doc.removeFullLines(firstRow, lastRow);
9059
+ this.doc.insertFullLines(firstRow+diff, lines);
8934
9060
  folds.length && this.addFolds(folds);
8935
9061
  return diff;
8936
9062
  };
@@ -9072,34 +9198,23 @@ var EditSession = function(text, mode) {
9072
9198
  };
9073
9199
  };
9074
9200
 
9075
- this.$updateInternalDataOnChange = function(e) {
9201
+ this.$updateInternalDataOnChange = function(delta) {
9076
9202
  var useWrapMode = this.$useWrapMode;
9077
- var len;
9078
- var action = e.data.action;
9079
- var firstRow = e.data.range.start.row;
9080
- var lastRow = e.data.range.end.row;
9081
- var start = e.data.range.start;
9082
- var end = e.data.range.end;
9203
+ var action = delta.action;
9204
+ var start = delta.start;
9205
+ var end = delta.end;
9206
+ var firstRow = start.row;
9207
+ var lastRow = end.row;
9208
+ var len = lastRow - firstRow;
9083
9209
  var removedFolds = null;
9084
-
9085
- if (action.indexOf("Lines") != -1) {
9086
- if (action == "insertLines") {
9087
- lastRow = firstRow + (e.data.lines.length);
9088
- } else {
9089
- lastRow = firstRow;
9090
- }
9091
- len = e.data.lines ? e.data.lines.length : lastRow - firstRow;
9092
- } else {
9093
- len = lastRow - firstRow;
9094
- }
9095
-
9210
+
9096
9211
  this.$updating = true;
9097
9212
  if (len != 0) {
9098
- if (action.indexOf("remove") != -1) {
9213
+ if (action === "remove") {
9099
9214
  this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
9100
9215
 
9101
9216
  var foldLines = this.$foldData;
9102
- removedFolds = this.getFoldsInRange(e.data.range);
9217
+ removedFolds = this.getFoldsInRange(delta);
9103
9218
  this.removeFolds(removedFolds);
9104
9219
 
9105
9220
  var foldLine = this.getFoldLine(end.row);
@@ -9156,9 +9271,9 @@ var EditSession = function(text, mode) {
9156
9271
  }
9157
9272
  }
9158
9273
  } else {
9159
- len = Math.abs(e.data.range.start.column - e.data.range.end.column);
9160
- if (action.indexOf("remove") != -1) {
9161
- removedFolds = this.getFoldsInRange(e.data.range);
9274
+ len = Math.abs(delta.start.column - delta.end.column);
9275
+ if (action === "remove") {
9276
+ removedFolds = this.getFoldsInRange(delta);
9162
9277
  this.removeFolds(removedFolds);
9163
9278
 
9164
9279
  len = -len;
@@ -9240,7 +9355,7 @@ var EditSession = function(text, mode) {
9240
9355
  TAB_SPACE = 12;
9241
9356
 
9242
9357
 
9243
- this.$computeWrapSplits = function(tokens, wrapLimit) {
9358
+ this.$computeWrapSplits = function(tokens, wrapLimit, tabSize) {
9244
9359
  if (tokens.length == 0) {
9245
9360
  return [];
9246
9361
  }
@@ -9251,6 +9366,31 @@ var EditSession = function(text, mode) {
9251
9366
 
9252
9367
  var isCode = this.$wrapAsCode;
9253
9368
 
9369
+ var indentedSoftWrap = this.$indentedSoftWrap;
9370
+ var maxIndent = wrapLimit <= Math.max(2 * tabSize, 8)
9371
+ || indentedSoftWrap === false ? 0 : Math.floor(wrapLimit / 2);
9372
+
9373
+ function getWrapIndent() {
9374
+ var indentation = 0;
9375
+ if (maxIndent === 0)
9376
+ return indentation;
9377
+ if (indentedSoftWrap) {
9378
+ for (var i = 0; i < tokens.length; i++) {
9379
+ var token = tokens[i];
9380
+ if (token == SPACE)
9381
+ indentation += 1;
9382
+ else if (token == TAB)
9383
+ indentation += tabSize;
9384
+ else if (token == TAB_SPACE)
9385
+ continue;
9386
+ else
9387
+ break;
9388
+ }
9389
+ }
9390
+ if (isCode && indentedSoftWrap !== false)
9391
+ indentation += tabSize;
9392
+ return Math.min(indentation, maxIndent);
9393
+ }
9254
9394
  function addSplit(screenPos) {
9255
9395
  var displayed = tokens.slice(lastSplit, screenPos);
9256
9396
  var len = displayed.length;
@@ -9262,13 +9402,17 @@ var EditSession = function(text, mode) {
9262
9402
  len -= 1;
9263
9403
  });
9264
9404
 
9405
+ if (!splits.length) {
9406
+ indent = getWrapIndent();
9407
+ splits.indent = indent;
9408
+ }
9265
9409
  lastDocSplit += len;
9266
9410
  splits.push(lastDocSplit);
9267
9411
  lastSplit = screenPos;
9268
9412
  }
9269
-
9270
- while (displayLength - lastSplit > wrapLimit) {
9271
- var split = lastSplit + wrapLimit;
9413
+ var indent = 0;
9414
+ while (displayLength - lastSplit > wrapLimit - indent) {
9415
+ var split = lastSplit + wrapLimit - indent;
9272
9416
  if (tokens[split - 1] >= SPACE && tokens[split] >= SPACE) {
9273
9417
  addSplit(split);
9274
9418
  continue;
@@ -9295,7 +9439,7 @@ var EditSession = function(text, mode) {
9295
9439
  addSplit(split);
9296
9440
  continue;
9297
9441
  }
9298
- var minSplit = Math.max(split - (isCode ? 10 : wrapLimit-(wrapLimit>>2)), lastSplit - 1);
9442
+ var minSplit = Math.max(split - (wrapLimit -(wrapLimit>>2)), lastSplit - 1);
9299
9443
  while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
9300
9444
  split --;
9301
9445
  }
@@ -9318,7 +9462,7 @@ var EditSession = function(text, mode) {
9318
9462
  split = lastSplit + wrapLimit;
9319
9463
  if (tokens[split] == CHAR_EXT)
9320
9464
  split--;
9321
- addSplit(split);
9465
+ addSplit(split - indent);
9322
9466
  }
9323
9467
  return splits;
9324
9468
  };
@@ -9394,6 +9538,16 @@ var EditSession = function(text, mode) {
9394
9538
  return this.$wrapData[row].length + 1;
9395
9539
  }
9396
9540
  };
9541
+
9542
+ this.getRowWrapIndent = function(screenRow) {
9543
+ if (this.$useWrapMode) {
9544
+ var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
9545
+ var splits = this.$wrapData[pos.row];
9546
+ return splits.length && splits[0] < pos.column ? splits.indent : 0;
9547
+ } else {
9548
+ return 0;
9549
+ }
9550
+ }
9397
9551
  this.getScreenLastRowColumn = function(screenRow) {
9398
9552
  var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
9399
9553
  return this.documentToScreenColumn(pos.row, pos.column);
@@ -9484,20 +9638,21 @@ var EditSession = function(text, mode) {
9484
9638
  line = this.getLine(docRow);
9485
9639
  foldLine = null;
9486
9640
  }
9487
-
9641
+ var wrapIndent = 0;
9488
9642
  if (this.$useWrapMode) {
9489
9643
  var splits = this.$wrapData[docRow];
9490
9644
  if (splits) {
9491
9645
  var splitIndex = Math.floor(screenRow - row);
9492
9646
  column = splits[splitIndex];
9493
9647
  if(splitIndex > 0 && splits.length) {
9648
+ wrapIndent = splits.indent;
9494
9649
  docColumn = splits[splitIndex - 1] || splits[splits.length - 1];
9495
9650
  line = line.substring(docColumn);
9496
9651
  }
9497
9652
  }
9498
9653
  }
9499
9654
 
9500
- docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
9655
+ docColumn += this.$getStringScreenWidth(line, screenColumn - wrapIndent)[1];
9501
9656
  if (this.$useWrapMode && docColumn >= column)
9502
9657
  docColumn = column - 1;
9503
9658
 
@@ -9569,6 +9724,7 @@ var EditSession = function(text, mode) {
9569
9724
  textLine = this.getLine(docRow).substring(0, docColumn);
9570
9725
  foldStartRow = docRow;
9571
9726
  }
9727
+ var wrapIndent = 0;
9572
9728
  if (this.$useWrapMode) {
9573
9729
  var wrapRow = this.$wrapData[foldStartRow];
9574
9730
  if (wrapRow) {
@@ -9580,12 +9736,13 @@ var EditSession = function(text, mode) {
9580
9736
  textLine = textLine.substring(
9581
9737
  wrapRow[screenRowOffset - 1] || 0, textLine.length
9582
9738
  );
9739
+ wrapIndent = screenRowOffset > 0 ? wrapRow.indent : 0;
9583
9740
  }
9584
9741
  }
9585
9742
 
9586
9743
  return {
9587
9744
  row: screenRow,
9588
- column: this.$getStringScreenWidth(textLine)[0]
9745
+ column: wrapIndent + this.$getStringScreenWidth(textLine)[0]
9589
9746
  };
9590
9747
  };
9591
9748
  this.documentToScreenColumn = function(row, docColumn) {
@@ -9627,6 +9784,29 @@ var EditSession = function(text, mode) {
9627
9784
  return screenRows;
9628
9785
  };
9629
9786
  this.$setFontMetrics = function(fm) {
9787
+ if (!this.$enableVarChar) return;
9788
+ this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
9789
+ if (maxScreenColumn === 0)
9790
+ return [0, 0];
9791
+ if (!maxScreenColumn)
9792
+ maxScreenColumn = Infinity;
9793
+ screenColumn = screenColumn || 0;
9794
+
9795
+ var c, column;
9796
+ for (column = 0; column < str.length; column++) {
9797
+ c = str.charAt(column);
9798
+ if (c === "\t") {
9799
+ screenColumn += this.getScreenTabSize(screenColumn);
9800
+ } else {
9801
+ screenColumn += fm.getCharacterWidth(c);
9802
+ }
9803
+ if (screenColumn > maxScreenColumn) {
9804
+ break;
9805
+ }
9806
+ }
9807
+
9808
+ return [screenColumn, column];
9809
+ };
9630
9810
  };
9631
9811
 
9632
9812
  this.destroy = function() {
@@ -9730,6 +9910,7 @@ config.defineOptions(EditSession.prototype, "session", {
9730
9910
  },
9731
9911
  initialValue: "auto"
9732
9912
  },
9913
+ indentedSoftWrap: { initialValue: true },
9733
9914
  firstLineNumber: {
9734
9915
  set: function() {this._signal("changeBreakpoint");},
9735
9916
  initialValue: 1
@@ -10135,9 +10316,12 @@ MultiHashHandler.prototype = HashHandler.prototype;
10135
10316
  }
10136
10317
  };
10137
10318
 
10138
- this.bindKey = function(key, command, asDefault) {
10139
- if (typeof key == "object")
10319
+ this.bindKey = function(key, command, position) {
10320
+ if (typeof key == "object") {
10321
+ if (position == undefined)
10322
+ position = key.position;
10140
10323
  key = key[this.platform];
10324
+ }
10141
10325
  if (!key)
10142
10326
  return;
10143
10327
  if (typeof command == "function")
@@ -10158,11 +10342,15 @@ MultiHashHandler.prototype = HashHandler.prototype;
10158
10342
  }
10159
10343
  var binding = this.parseKeys(keyPart);
10160
10344
  var id = KEY_MODS[binding.hashId] + binding.key;
10161
- this._addCommandToBinding(chain + id, command, asDefault);
10345
+ this._addCommandToBinding(chain + id, command, position);
10162
10346
  }, this);
10163
10347
  };
10164
10348
 
10165
- this._addCommandToBinding = function(keyId, command, asDefault) {
10349
+ function getPosition(command) {
10350
+ return typeof command == "object" && command.bindKey
10351
+ && command.bindKey.position || 0;
10352
+ }
10353
+ this._addCommandToBinding = function(keyId, command, position) {
10166
10354
  var ckb = this.commandKeyBinding, i;
10167
10355
  if (!command) {
10168
10356
  delete ckb[keyId];
@@ -10174,11 +10362,21 @@ MultiHashHandler.prototype = HashHandler.prototype;
10174
10362
  } else if ((i = ckb[keyId].indexOf(command)) != -1) {
10175
10363
  ckb[keyId].splice(i, 1);
10176
10364
  }
10177
-
10178
- if (asDefault || command.isDefault)
10179
- ckb[keyId].unshift(command);
10180
- else
10181
- ckb[keyId].push(command);
10365
+
10366
+ if (typeof position != "number") {
10367
+ if (position || command.isDefault)
10368
+ position = -100;
10369
+ else
10370
+ position = getPosition(command);
10371
+ }
10372
+ var commands = ckb[keyId];
10373
+ for (i = 0; i < commands.length; i++) {
10374
+ var other = commands[i];
10375
+ var otherPos = getPosition(other);
10376
+ if (otherPos > position)
10377
+ break;
10378
+ }
10379
+ commands.splice(i, 0, command);
10182
10380
  }
10183
10381
  };
10184
10382
 
@@ -10250,6 +10448,7 @@ MultiHashHandler.prototype = HashHandler.prototype;
10250
10448
  };
10251
10449
 
10252
10450
  this.handleKeyboard = function(data, hashId, keyString, keyCode) {
10451
+ if (keyCode < 0) return;
10253
10452
  var key = KEY_MODS[hashId] + keyString;
10254
10453
  var command = this.commandKeyBinding[key];
10255
10454
  if (data.$keyChain) {
@@ -10264,10 +10463,18 @@ MultiHashHandler.prototype = HashHandler.prototype;
10264
10463
  }
10265
10464
  }
10266
10465
 
10267
- if (data.$keyChain && keyCode > 0)
10268
- data.$keyChain = "";
10466
+ if (data.$keyChain) {
10467
+ if ((!hashId || hashId == 4) && keyString.length == 1)
10468
+ data.$keyChain = data.$keyChain.slice(0, -key.length - 1); // wait for input
10469
+ else if (hashId == -1 || keyCode > 0)
10470
+ data.$keyChain = ""; // reset keyChain
10471
+ }
10269
10472
  return {command: command};
10270
10473
  };
10474
+
10475
+ this.getStatusText = function(editor, data) {
10476
+ return data.$keyChain || "";
10477
+ };
10271
10478
 
10272
10479
  }).call(HashHandler.prototype);
10273
10480
 
@@ -10772,6 +10979,11 @@ exports.commands = [{
10772
10979
  exec: function() {},
10773
10980
  passEvent: true,
10774
10981
  readOnly: true
10982
+ }, {
10983
+ name: "copy",
10984
+ exec: function(editor) {
10985
+ },
10986
+ readOnly: true
10775
10987
  },
10776
10988
  {
10777
10989
  name: "cut",
@@ -10786,6 +10998,12 @@ exports.commands = [{
10786
10998
  },
10787
10999
  scrollIntoView: "cursor",
10788
11000
  multiSelectAction: "forEach"
11001
+ }, {
11002
+ name: "paste",
11003
+ exec: function(editor, args) {
11004
+ editor.$handlePaste(args);
11005
+ },
11006
+ scrollIntoView: "cursor"
10789
11007
  }, {
10790
11008
  name: "removeline",
10791
11009
  bindKey: bindKey("Ctrl-D", "Command-D"),
@@ -11177,8 +11395,11 @@ var Editor = function(renderer, session) {
11177
11395
  var command = this.curOp.command;
11178
11396
  if (command.name && this.$blockScrolling > 0)
11179
11397
  this.$blockScrolling--;
11180
- if (command && command.scrollIntoView) {
11181
- switch (command.scrollIntoView) {
11398
+ var scrollIntoView = command && command.scrollIntoView;
11399
+ if (scrollIntoView) {
11400
+ switch (scrollIntoView) {
11401
+ case "center-animate":
11402
+ scrollIntoView = "animate";
11182
11403
  case "center":
11183
11404
  this.renderer.scrollCursorIntoView(null, 0.5);
11184
11405
  break;
@@ -11196,7 +11417,7 @@ var Editor = function(renderer, session) {
11196
11417
  default:
11197
11418
  break;
11198
11419
  }
11199
- if (command.scrollIntoView == "animate")
11420
+ if (scrollIntoView == "animate")
11200
11421
  this.renderer.animateScrolling(this.curOp.scrollTop);
11201
11422
  }
11202
11423
 
@@ -11260,6 +11481,8 @@ var Editor = function(renderer, session) {
11260
11481
  this.setSession = function(session) {
11261
11482
  if (this.session == session)
11262
11483
  return;
11484
+ if (this.curOp) this.endOperation();
11485
+ this.curOp = {};
11263
11486
 
11264
11487
  var oldSession = this.session;
11265
11488
  if (oldSession) {
@@ -11359,6 +11582,8 @@ var Editor = function(renderer, session) {
11359
11582
  oldSession: oldSession
11360
11583
  });
11361
11584
 
11585
+ this.curOp = null;
11586
+
11362
11587
  oldSession && oldSession._signal("changeEditor", {oldEditor: this});
11363
11588
  session && session._signal("changeEditor", {editor: this});
11364
11589
  };
@@ -11543,18 +11768,12 @@ var Editor = function(renderer, session) {
11543
11768
  this.$cursorChange = function() {
11544
11769
  this.renderer.updateCursor();
11545
11770
  };
11546
- this.onDocumentChange = function(e) {
11547
- var delta = e.data;
11548
- var range = delta.range;
11549
- var lastRow;
11771
+ this.onDocumentChange = function(delta) {
11772
+ var wrap = this.session.$useWrapMode;
11773
+ var lastRow = (delta.start.row == delta.end.row ? delta.end.row : Infinity);
11774
+ this.renderer.updateLines(delta.start.row, lastRow, wrap);
11550
11775
 
11551
- if (range.start.row == range.end.row && delta.action != "insertLines" && delta.action != "removeLines")
11552
- lastRow = range.end.row;
11553
- else
11554
- lastRow = Infinity;
11555
- this.renderer.updateLines(range.start.row, lastRow, this.session.$useWrapMode);
11556
-
11557
- this._signal("change", e);
11776
+ this._signal("change", delta);
11558
11777
  this.$cursorChange();
11559
11778
  this.$updateHighlightActiveLine();
11560
11779
  };
@@ -11719,13 +11938,16 @@ var Editor = function(renderer, session) {
11719
11938
  this.onCut = function() {
11720
11939
  this.commands.exec("cut", this);
11721
11940
  };
11722
- this.onPaste = function(text) {
11723
- if (this.$readOnly)
11724
- return;
11725
-
11726
- var e = {text: text};
11941
+ this.onPaste = function(text, event) {
11942
+ var e = {text: text, event: event};
11943
+ this.commands.exec("paste", this, e);
11944
+ };
11945
+
11946
+ this.$handlePaste = function(e) {
11947
+ if (typeof e == "string")
11948
+ e = {text: e};
11727
11949
  this._signal("paste", e);
11728
- text = e.text;
11950
+ var text = e.text;
11729
11951
  if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
11730
11952
  this.insert(text);
11731
11953
  } else {
@@ -11743,7 +11965,6 @@ var Editor = function(renderer, session) {
11743
11965
  this.session.insert(range.start, lines[i]);
11744
11966
  }
11745
11967
  }
11746
- this.renderer.scrollCursorIntoView();
11747
11968
  };
11748
11969
 
11749
11970
  this.execCommand = function(command, args) {
@@ -12186,15 +12407,7 @@ var Editor = function(renderer, session) {
12186
12407
  };
12187
12408
  this.removeLines = function() {
12188
12409
  var rows = this.$getSelectedRows();
12189
- var range;
12190
- if (rows.first === 0 || rows.last+1 < this.session.getLength())
12191
- range = new Range(rows.first, 0, rows.last+1, 0);
12192
- else
12193
- range = new Range(
12194
- rows.first-1, this.session.getLine(rows.first-1).length,
12195
- rows.last, this.session.getLine(rows.last).length
12196
- );
12197
- this.session.remove(range);
12410
+ this.session.removeFullLines(rows.first, rows.last);
12198
12411
  this.clearSelection();
12199
12412
  };
12200
12413
 
@@ -12901,6 +13114,7 @@ config.defineOptions(Editor.prototype, "editor", {
12901
13114
  useSoftTabs: "session",
12902
13115
  tabSize: "session",
12903
13116
  wrap: "session",
13117
+ indentedSoftWrap: "session",
12904
13118
  foldStyle: "session",
12905
13119
  mode: "session"
12906
13120
  });
@@ -12916,42 +13130,39 @@ var UndoManager = function() {
12916
13130
 
12917
13131
  (function() {
12918
13132
  this.execute = function(options) {
12919
- var deltas = options.args[0];
13133
+ var deltaSets = options.args[0];
12920
13134
  this.$doc = options.args[1];
12921
13135
  if (options.merge && this.hasUndo()){
12922
13136
  this.dirtyCounter--;
12923
- deltas = this.$undoStack.pop().concat(deltas);
13137
+ deltaSets = this.$undoStack.pop().concat(deltaSets);
12924
13138
  }
12925
- this.$undoStack.push(deltas);
13139
+ this.$undoStack.push(deltaSets);
12926
13140
  this.$redoStack = [];
12927
-
12928
13141
  if (this.dirtyCounter < 0) {
12929
13142
  this.dirtyCounter = NaN;
12930
13143
  }
12931
13144
  this.dirtyCounter++;
12932
13145
  };
12933
13146
  this.undo = function(dontSelect) {
12934
- var deltas = this.$undoStack.pop();
13147
+ var deltaSets = this.$undoStack.pop();
12935
13148
  var undoSelectionRange = null;
12936
- if (deltas) {
12937
- undoSelectionRange =
12938
- this.$doc.undoChanges(deltas, dontSelect);
12939
- this.$redoStack.push(deltas);
13149
+ if (deltaSets) {
13150
+ undoSelectionRange = this.$doc.undoChanges(deltaSets, dontSelect);
13151
+ this.$redoStack.push(deltaSets);
12940
13152
  this.dirtyCounter--;
12941
13153
  }
12942
13154
 
12943
13155
  return undoSelectionRange;
12944
13156
  };
12945
13157
  this.redo = function(dontSelect) {
12946
- var deltas = this.$redoStack.pop();
13158
+ var deltaSets = this.$redoStack.pop();
12947
13159
  var redoSelectionRange = null;
12948
- if (deltas) {
13160
+ if (deltaSets) {
12949
13161
  redoSelectionRange =
12950
- this.$doc.redoChanges(deltas, dontSelect);
12951
- this.$undoStack.push(deltas);
13162
+ this.$doc.redoChanges(this.$deserializeDeltas(deltaSets), dontSelect);
13163
+ this.$undoStack.push(deltaSets);
12952
13164
  this.dirtyCounter++;
12953
13165
  }
12954
-
12955
13166
  return redoSelectionRange;
12956
13167
  };
12957
13168
  this.reset = function() {
@@ -12971,7 +13182,48 @@ var UndoManager = function() {
12971
13182
  this.isClean = function() {
12972
13183
  return this.dirtyCounter === 0;
12973
13184
  };
12974
-
13185
+ this.$serializeDeltas = function(deltaSets) {
13186
+ return cloneDeltaSetsObj(deltaSets, $serializeDelta);
13187
+ };
13188
+ this.$deserializeDeltas = function(deltaSets) {
13189
+ return cloneDeltaSetsObj(deltaSets, $deserializeDelta);
13190
+ };
13191
+
13192
+ function $serializeDelta(delta){
13193
+ return {
13194
+ action: delta.action,
13195
+ start: delta.start,
13196
+ end: delta.end,
13197
+ lines: delta.lines.length == 1 ? null : delta.lines,
13198
+ text: delta.lines.length == 1 ? delta.lines[0] : null,
13199
+ };
13200
+ }
13201
+
13202
+ function $deserializeDelta(delta) {
13203
+ return {
13204
+ action: delta.action,
13205
+ start: delta.start,
13206
+ end: delta.end,
13207
+ lines: delta.lines || [delta.text]
13208
+ };
13209
+ }
13210
+
13211
+ function cloneDeltaSetsObj(deltaSets_old, fnGetModifiedDelta) {
13212
+ var deltaSets_new = new Array(deltaSets_old.length);
13213
+ for (var i = 0; i < deltaSets_old.length; i++) {
13214
+ var deltaSet_old = deltaSets_old[i];
13215
+ var deltaSet_new = { group: deltaSet_old.group, deltas: new Array(deltaSet_old.length)};
13216
+
13217
+ for (var j = 0; j < deltaSet_old.deltas.length; j++) {
13218
+ var delta_old = deltaSet_old.deltas[j];
13219
+ deltaSet_new.deltas[j] = fnGetModifiedDelta(delta_old);
13220
+ }
13221
+
13222
+ deltaSets_new[i] = deltaSet_new;
13223
+ }
13224
+ return deltaSets_new;
13225
+ }
13226
+
12975
13227
  }).call(UndoManager.prototype);
12976
13228
 
12977
13229
  exports.UndoManager = UndoManager;
@@ -13048,15 +13300,13 @@ var Gutter = function(parentEl) {
13048
13300
  }
13049
13301
  };
13050
13302
 
13051
- this.$updateAnnotations = function (e) {
13303
+ this.$updateAnnotations = function (delta) {
13052
13304
  if (!this.$annotations.length)
13053
13305
  return;
13054
- var delta = e.data;
13055
- var range = delta.range;
13056
- var firstRow = range.start.row;
13057
- var len = range.end.row - firstRow;
13306
+ var firstRow = delta.start.row;
13307
+ var len = delta.end.row - firstRow;
13058
13308
  if (len === 0) {
13059
- } else if (delta.action == "removeText" || delta.action == "removeLines") {
13309
+ } else if (delta.action == 'remove') {
13060
13310
  this.$annotations.splice(firstRow, len + 1, null);
13061
13311
  } else {
13062
13312
  var args = new Array(len + 1);
@@ -13294,7 +13544,7 @@ var Marker = function(parentEl) {
13294
13544
  else
13295
13545
  this.drawMultiLineMarker(html, range, marker.clazz, config);
13296
13546
  } else {
13297
- this.drawSingleLineMarker(html, range, marker.clazz + " ace_start", config);
13547
+ this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config);
13298
13548
  }
13299
13549
  }
13300
13550
  this.element.innerHTML = html.join("");
@@ -13303,23 +13553,30 @@ var Marker = function(parentEl) {
13303
13553
  this.$getTop = function(row, layerConfig) {
13304
13554
  return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
13305
13555
  };
13306
- this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
13307
- var row = range.start.row;
13308
-
13309
- var lineRange = new Range(
13310
- row, range.start.column,
13311
- row, this.session.getScreenLastRowColumn(row)
13312
- );
13313
- this.drawSingleLineMarker(stringBuilder, lineRange, clazz + " ace_start", layerConfig, 1, extraStyle);
13314
- row = range.end.row;
13315
- lineRange = new Range(row, 0, row, range.end.column);
13316
- this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 0, extraStyle);
13317
13556
 
13318
- for (row = range.start.row + 1; row < range.end.row; row++) {
13319
- lineRange.start.row = row;
13320
- lineRange.end.row = row;
13321
- lineRange.end.column = this.session.getScreenLastRowColumn(row);
13322
- this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 1, extraStyle);
13557
+ function getBorderClass(tl, tr, br, bl) {
13558
+ return (tl ? 1 : 0) | (tr ? 2 : 0) | (br ? 4 : 0) | (bl ? 8 : 0);
13559
+ }
13560
+ this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
13561
+ var session = this.session;
13562
+ var start = range.start.row;
13563
+ var end = range.end.row;
13564
+ var row = start;
13565
+ var prev = 0;
13566
+ var curr = 0;
13567
+ var next = session.getScreenLastRowColumn(row);
13568
+ var lineRange = new Range(row, range.start.column, row, curr);
13569
+ for (; row <= end; row++) {
13570
+ lineRange.start.row = lineRange.end.row = row;
13571
+ lineRange.start.column = row == start ? range.start.column : session.getRowWrapIndent(row);
13572
+ lineRange.end.column = next;
13573
+ prev = curr;
13574
+ curr = next;
13575
+ next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column;
13576
+ this.drawSingleLineMarker(stringBuilder, lineRange,
13577
+ clazz + (row == start ? " ace_start" : "") + " ace_br"
13578
+ + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end),
13579
+ layerConfig, row == end ? 0 : 1, extraStyle);
13323
13580
  }
13324
13581
  };
13325
13582
  this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
@@ -13330,7 +13587,7 @@ var Marker = function(parentEl) {
13330
13587
  extraStyle = extraStyle || "";
13331
13588
 
13332
13589
  stringBuilder.push(
13333
- "<div class='", clazz, " ace_start' style='",
13590
+ "<div class='", clazz, " ace_br1 ace_start' style='",
13334
13591
  "height:", height, "px;",
13335
13592
  "right:0;",
13336
13593
  "top:", top, "px;",
@@ -13340,19 +13597,21 @@ var Marker = function(parentEl) {
13340
13597
  var width = range.end.column * config.characterWidth;
13341
13598
 
13342
13599
  stringBuilder.push(
13343
- "<div class='", clazz, "' style='",
13600
+ "<div class='", clazz, " ace_br12' style='",
13344
13601
  "height:", height, "px;",
13345
13602
  "width:", width, "px;",
13346
13603
  "top:", top, "px;",
13347
13604
  "left:", padding, "px;", extraStyle, "'></div>"
13348
13605
  );
13349
13606
  height = (range.end.row - range.start.row - 1) * config.lineHeight;
13350
- if (height < 0)
13607
+ if (height <= 0)
13351
13608
  return;
13352
13609
  top = this.$getTop(range.start.row + 1, config);
13610
+
13611
+ var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8);
13353
13612
 
13354
13613
  stringBuilder.push(
13355
- "<div class='", clazz, "' style='",
13614
+ "<div class='", clazz, (radiusClass ? " ace_br" + radiusClass : ""), "' style='",
13356
13615
  "height:", height, "px;",
13357
13616
  "right:0;",
13358
13617
  "top:", top, "px;",
@@ -13431,7 +13690,7 @@ var Text = function(parentEl) {
13431
13690
  this.EOL_CHAR_LF = "\xAC";
13432
13691
  this.EOL_CHAR_CRLF = "\xa4";
13433
13692
  this.EOL_CHAR = this.EOL_CHAR_LF;
13434
- this.TAB_CHAR = "\u2192"; //"\u21E5";
13693
+ this.TAB_CHAR = "\u2014"; //"\u21E5";
13435
13694
  this.SPACE_CHAR = "\xB7";
13436
13695
  this.$padding = 0;
13437
13696
 
@@ -13507,8 +13766,7 @@ var Text = function(parentEl) {
13507
13766
  for (var i = 1; i < tabSize + 1; i++) {
13508
13767
  if (this.showInvisibles) {
13509
13768
  tabStr.push("<span class='ace_invisible ace_invisible_tab'>"
13510
- + this.TAB_CHAR
13511
- + lang.stringRepeat(" ", i - 1)
13769
+ + lang.stringRepeat(this.TAB_CHAR, i)
13512
13770
  + "</span>");
13513
13771
  } else {
13514
13772
  tabStr.push(lang.stringRepeat(" ", i));
@@ -13524,7 +13782,7 @@ var Text = function(parentEl) {
13524
13782
  spaceClass = " ace_invisible_space";
13525
13783
  tabClass = " ace_invisible_tab";
13526
13784
  var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
13527
- var tabContent = this.TAB_CHAR + lang.stringRepeat(" ", this.tabSize - 1);
13785
+ var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize);
13528
13786
  } else{
13529
13787
  var spaceContent = lang.stringRepeat(" ", this.tabSize);
13530
13788
  var tabContent = spaceContent;
@@ -13695,7 +13953,7 @@ var Text = function(parentEl) {
13695
13953
 
13696
13954
  this.$renderToken = function(stringBuilder, screenColumn, token, value) {
13697
13955
  var self = this;
13698
- var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g;
13956
+ var replaceReg = /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g;
13699
13957
  var replaceFunc = function(c, a, b, tabIdx, idx4) {
13700
13958
  if (a) {
13701
13959
  return self.showInvisibles
@@ -13705,6 +13963,8 @@ var Text = function(parentEl) {
13705
13963
  return "&#38;";
13706
13964
  } else if (c == "<") {
13707
13965
  return "&#60;";
13966
+ } else if (c == ">") {
13967
+ return "&#62;";
13708
13968
  } else if (c == "\t") {
13709
13969
  var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
13710
13970
  screenColumn += tabSize - 1;
@@ -13792,6 +14052,8 @@ var Text = function(parentEl) {
13792
14052
  );
13793
14053
  }
13794
14054
 
14055
+ stringBuilder.push(lang.stringRepeat("\xa0", splits.indent));
14056
+
13795
14057
  split ++;
13796
14058
  screenColumn = 0;
13797
14059
  splitChars = splits[split] || Number.MAX_VALUE;
@@ -13942,15 +14204,15 @@ define("ace/layer/cursor",["require","exports","module","ace/lib/dom"], function
13942
14204
  "use strict";
13943
14205
 
13944
14206
  var dom = require("../lib/dom");
13945
- var IE8;
14207
+ var isIE8;
13946
14208
 
13947
14209
  var Cursor = function(parentEl) {
13948
14210
  this.element = dom.createElement("div");
13949
14211
  this.element.className = "ace_layer ace_cursor-layer";
13950
14212
  parentEl.appendChild(this.element);
13951
14213
 
13952
- if (IE8 === undefined)
13953
- IE8 = "opacity" in this.element;
14214
+ if (isIE8 === undefined)
14215
+ isIE8 = !("opacity" in this.element.style);
13954
14216
 
13955
14217
  this.isVisible = false;
13956
14218
  this.isBlinking = true;
@@ -13960,7 +14222,9 @@ var Cursor = function(parentEl) {
13960
14222
  this.cursors = [];
13961
14223
  this.cursor = this.addCursor();
13962
14224
  dom.addCssClass(this.element, "ace_hidden-cursors");
13963
- this.$updateCursors = this.$updateVisibility.bind(this);
14225
+ this.$updateCursors = (isIE8
14226
+ ? this.$updateVisibility
14227
+ : this.$updateOpacity).bind(this);
13964
14228
  };
13965
14229
 
13966
14230
  (function() {
@@ -14001,13 +14265,11 @@ var Cursor = function(parentEl) {
14001
14265
  };
14002
14266
 
14003
14267
  this.setSmoothBlinking = function(smoothBlinking) {
14004
- if (smoothBlinking != this.smoothBlinking && !IE8) {
14268
+ if (smoothBlinking != this.smoothBlinking && !isIE8) {
14005
14269
  this.smoothBlinking = smoothBlinking;
14006
14270
  dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking);
14007
14271
  this.$updateCursors(true);
14008
- this.$updateCursors = (smoothBlinking
14009
- ? this.$updateOpacity
14010
- : this.$updateVisibility).bind(this);
14272
+ this.$updateCursors = (this.$updateOpacity).bind(this);
14011
14273
  this.restartTimer();
14012
14274
  }
14013
14275
  };
@@ -14399,9 +14661,9 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
14399
14661
  this.setPolling = function(val) {
14400
14662
  if (val) {
14401
14663
  this.$pollSizeChanges();
14402
- } else {
14403
- if (this.$pollSizeChangesTimer)
14404
- this.$pollSizeChangesTimer;
14664
+ } else if (this.$pollSizeChangesTimer) {
14665
+ clearInterval(this.$pollSizeChangesTimer);
14666
+ this.$pollSizeChangesTimer = 0;
14405
14667
  }
14406
14668
  };
14407
14669
 
@@ -14599,6 +14861,7 @@ text-indent: -1em;\
14599
14861
  -moz-user-select: text;\
14600
14862
  -webkit-user-select: text;\
14601
14863
  user-select: text;\
14864
+ white-space: pre!important;\
14602
14865
  }\
14603
14866
  .ace_text-input.ace_composition {\
14604
14867
  background: inherit;\
@@ -14642,7 +14905,8 @@ position: absolute;\
14642
14905
  -moz-box-sizing: border-box;\
14643
14906
  -webkit-box-sizing: border-box;\
14644
14907
  box-sizing: border-box;\
14645
- border-left: 2px solid\
14908
+ border-left: 2px solid;\
14909
+ transform: translatez(0);\
14646
14910
  }\
14647
14911
  .ace_slim-cursors .ace_cursor {\
14648
14912
  border-left-width: 1px;\
@@ -14823,6 +15087,21 @@ background-color: rgba(255, 255, 0,0.2);\
14823
15087
  position: absolute;\
14824
15088
  z-index: 8;\
14825
15089
  }\
15090
+ .ace_br1 {border-top-left-radius : 3px;}\
15091
+ .ace_br2 {border-top-right-radius : 3px;}\
15092
+ .ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}\
15093
+ .ace_br4 {border-bottom-right-radius: 3px;}\
15094
+ .ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}\
15095
+ .ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}\
15096
+ .ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}\
15097
+ .ace_br8 {border-bottom-left-radius : 3px;}\
15098
+ .ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}\
15099
+ .ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}\
15100
+ .ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}\
15101
+ .ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
15102
+ .ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
15103
+ .ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
15104
+ .ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
14826
15105
  ";
14827
15106
 
14828
15107
  dom.importCssString(editorCss, "ace_editor.css");
@@ -15235,7 +15514,7 @@ var VirtualRenderer = function(container, theme) {
15235
15514
  return this.container;
15236
15515
  };
15237
15516
  this.getMouseEventTarget = function() {
15238
- return this.content;
15517
+ return this.scroller;
15239
15518
  };
15240
15519
  this.getTextAreaContainer = function() {
15241
15520
  return this.container;
@@ -15464,6 +15743,8 @@ var VirtualRenderer = function(container, theme) {
15464
15743
  (this.$minLines||1) * this.lineHeight,
15465
15744
  Math.min(maxHeight, height)
15466
15745
  ) + this.scrollMargin.v + (this.$extraHeight || 0);
15746
+ if (this.$horizScroll)
15747
+ desiredHeight += this.scrollBarH.getHeight();
15467
15748
  var vScroll = height > maxHeight;
15468
15749
 
15469
15750
  if (desiredHeight != this.desiredHeight ||
@@ -15483,9 +15764,6 @@ var VirtualRenderer = function(container, theme) {
15483
15764
  };
15484
15765
 
15485
15766
  this.$computeLayerConfig = function() {
15486
- if (this.$maxLines && this.lineHeight > 1)
15487
- this.$autosize();
15488
-
15489
15767
  var session = this.session;
15490
15768
  var size = this.$size;
15491
15769
 
@@ -15493,9 +15771,6 @@ var VirtualRenderer = function(container, theme) {
15493
15771
  var screenLines = this.session.getScreenLength();
15494
15772
  var maxHeight = screenLines * this.lineHeight;
15495
15773
 
15496
- var offset = this.scrollTop % this.lineHeight;
15497
- var minHeight = size.scrollerHeight + this.lineHeight;
15498
-
15499
15774
  var longestLine = this.$getLongestLine();
15500
15775
 
15501
15776
  var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
@@ -15506,21 +15781,28 @@ var VirtualRenderer = function(container, theme) {
15506
15781
  this.$horizScroll = horizScroll;
15507
15782
  this.scrollBarH.setVisible(horizScroll);
15508
15783
  }
15784
+ var vScrollBefore = this.$vScroll; // autosize can change vscroll value in which case we need to update longestLine
15785
+ if (this.$maxLines && this.lineHeight > 1)
15786
+ this.$autosize();
15787
+
15788
+ var offset = this.scrollTop % this.lineHeight;
15789
+ var minHeight = size.scrollerHeight + this.lineHeight;
15509
15790
 
15510
15791
  var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd
15511
15792
  ? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
15512
15793
  : 0;
15513
15794
  maxHeight += scrollPastEnd;
15514
15795
 
15515
- this.session.setScrollTop(Math.max(-this.scrollMargin.top,
15516
- Math.min(this.scrollTop, maxHeight - size.scrollerHeight + this.scrollMargin.bottom)));
15796
+ var sm = this.scrollMargin;
15797
+ this.session.setScrollTop(Math.max(-sm.top,
15798
+ Math.min(this.scrollTop, maxHeight - size.scrollerHeight + sm.bottom)));
15517
15799
 
15518
- this.session.setScrollLeft(Math.max(-this.scrollMargin.left, Math.min(this.scrollLeft,
15519
- longestLine + 2 * this.$padding - size.scrollerWidth + this.scrollMargin.right)));
15800
+ this.session.setScrollLeft(Math.max(-sm.left, Math.min(this.scrollLeft,
15801
+ longestLine + 2 * this.$padding - size.scrollerWidth + sm.right)));
15520
15802
 
15521
15803
  var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
15522
- size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop);
15523
- var vScrollChanged = this.$vScroll !== vScroll;
15804
+ size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop > sm.top);
15805
+ var vScrollChanged = vScrollBefore !== vScroll;
15524
15806
  if (vScrollChanged) {
15525
15807
  this.$vScroll = vScroll;
15526
15808
  this.scrollBarV.setVisible(vScroll);
@@ -16204,19 +16486,22 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
16204
16486
  doc.on("change", this.changeListener);
16205
16487
  };
16206
16488
 
16207
- this.changeListener = function(e) {
16489
+ this.changeListener = function(delta) {
16208
16490
  if (!this.deltaQueue) {
16209
- this.deltaQueue = [e.data];
16491
+ this.deltaQueue = [];
16210
16492
  setTimeout(this.$sendDeltaQueue, 0);
16211
- } else
16212
- this.deltaQueue.push(e.data);
16493
+ }
16494
+ if (delta.action == "insert")
16495
+ this.deltaQueue.push(delta.start, delta.lines);
16496
+ else
16497
+ this.deltaQueue.push(delta.start, delta.end);
16213
16498
  };
16214
16499
 
16215
16500
  this.$sendDeltaQueue = function() {
16216
16501
  var q = this.deltaQueue;
16217
16502
  if (!q) return;
16218
16503
  this.deltaQueue = null;
16219
- if (q.length > 20 && q.length > this.$doc.getLength() >> 1) {
16504
+ if (q.length > 50 && q.length > this.$doc.getLength() >> 1) {
16220
16505
  this.call("setValue", [this.$doc.getValue()]);
16221
16506
  } else
16222
16507
  this.emit("change", {data: q});
@@ -16372,28 +16657,27 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
16372
16657
  this.session.removeMarker(this.others[i].markerId);
16373
16658
  }
16374
16659
  };
16375
- this.onUpdate = function(event) {
16376
- var delta = event.data;
16377
- var range = delta.range;
16660
+ this.onUpdate = function(delta) {
16661
+ var range = delta;
16378
16662
  if(range.start.row !== range.end.row) return;
16379
16663
  if(range.start.row !== this.pos.row) return;
16380
16664
  if (this.$updating) return;
16381
16665
  this.$updating = true;
16382
- var lengthDiff = delta.action === "insertText" ? range.end.column - range.start.column : range.start.column - range.end.column;
16666
+ var lengthDiff = delta.action === "insert" ? range.end.column - range.start.column : range.start.column - range.end.column;
16383
16667
 
16384
16668
  if(range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1) {
16385
16669
  var distanceFromStart = range.start.column - this.pos.column;
16386
16670
  this.length += lengthDiff;
16387
16671
  if(!this.session.$fromUndo) {
16388
- if(delta.action === "insertText") {
16672
+ if(delta.action === 'insert') {
16389
16673
  for (var i = this.others.length - 1; i >= 0; i--) {
16390
16674
  var otherPos = this.others[i];
16391
16675
  var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
16392
16676
  if(otherPos.row === range.start.row && range.start.column < otherPos.column)
16393
16677
  newPos.column += lengthDiff;
16394
- this.doc.insert(newPos, delta.text);
16678
+ this.doc.insertMergedLines(newPos, delta.lines);
16395
16679
  }
16396
- } else if(delta.action === "removeText") {
16680
+ } else if(delta.action === 'remove') {
16397
16681
  for (var i = this.others.length - 1; i >= 0; i--) {
16398
16682
  var otherPos = this.others[i];
16399
16683
  var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
@@ -16402,7 +16686,7 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
16402
16686
  this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff));
16403
16687
  }
16404
16688
  }
16405
- if(range.start.column === this.pos.column && delta.action === "insertText") {
16689
+ if(range.start.column === this.pos.column && delta.action === 'insert') {
16406
16690
  setTimeout(function() {
16407
16691
  this.pos.setPosition(this.pos.row, this.pos.column - lengthDiff);
16408
16692
  for (var i = 0; i < this.others.length; i++) {
@@ -16414,7 +16698,7 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
16414
16698
  }
16415
16699
  }.bind(this), 0);
16416
16700
  }
16417
- else if(range.start.column === this.pos.column && delta.action === "removeText") {
16701
+ else if(range.start.column === this.pos.column && delta.action === 'remove') {
16418
16702
  setTimeout(function() {
16419
16703
  for (var i = 0; i < this.others.length; i++) {
16420
16704
  var other = this.others[i];
@@ -16526,15 +16810,15 @@ function onMouseDown(e) {
16526
16810
  var selectionMode;
16527
16811
  if (editor.$mouseHandler.$enableJumpToDef) {
16528
16812
  if (ctrl && alt || accel && alt)
16529
- selectionMode = "add";
16530
- else if (alt)
16813
+ selectionMode = shift ? "block" : "add";
16814
+ else if (alt && editor.$blockSelectEnabled)
16531
16815
  selectionMode = "block";
16532
16816
  } else {
16533
16817
  if (accel && !alt) {
16534
16818
  selectionMode = "add";
16535
16819
  if (!isMultiSelect && shift)
16536
16820
  return;
16537
- } else if (alt) {
16821
+ } else if (alt && editor.$blockSelectEnabled) {
16538
16822
  selectionMode = "block";
16539
16823
  }
16540
16824
  }
@@ -16560,7 +16844,7 @@ function onMouseDown(e) {
16560
16844
 
16561
16845
  if (shift) {
16562
16846
  oldRange = null;
16563
- range = selection.ranges[0];
16847
+ range = selection.ranges[0] || range;
16564
16848
  editor.removeSelectionMarker(range);
16565
16849
  }
16566
16850
  editor.once("mouseup", function() {
@@ -16659,54 +16943,54 @@ exports.defaultCommands = [{
16659
16943
  exec: function(editor) { editor.selectMoreLines(-1); },
16660
16944
  bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
16661
16945
  scrollIntoView: "cursor",
16662
- readonly: true
16946
+ readOnly: true
16663
16947
  }, {
16664
16948
  name: "addCursorBelow",
16665
16949
  exec: function(editor) { editor.selectMoreLines(1); },
16666
16950
  bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
16667
16951
  scrollIntoView: "cursor",
16668
- readonly: true
16952
+ readOnly: true
16669
16953
  }, {
16670
16954
  name: "addCursorAboveSkipCurrent",
16671
16955
  exec: function(editor) { editor.selectMoreLines(-1, true); },
16672
16956
  bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
16673
16957
  scrollIntoView: "cursor",
16674
- readonly: true
16958
+ readOnly: true
16675
16959
  }, {
16676
16960
  name: "addCursorBelowSkipCurrent",
16677
16961
  exec: function(editor) { editor.selectMoreLines(1, true); },
16678
16962
  bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
16679
16963
  scrollIntoView: "cursor",
16680
- readonly: true
16964
+ readOnly: true
16681
16965
  }, {
16682
16966
  name: "selectMoreBefore",
16683
16967
  exec: function(editor) { editor.selectMore(-1); },
16684
16968
  bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
16685
16969
  scrollIntoView: "cursor",
16686
- readonly: true
16970
+ readOnly: true
16687
16971
  }, {
16688
16972
  name: "selectMoreAfter",
16689
16973
  exec: function(editor) { editor.selectMore(1); },
16690
16974
  bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
16691
16975
  scrollIntoView: "cursor",
16692
- readonly: true
16976
+ readOnly: true
16693
16977
  }, {
16694
16978
  name: "selectNextBefore",
16695
16979
  exec: function(editor) { editor.selectMore(-1, true); },
16696
16980
  bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
16697
16981
  scrollIntoView: "cursor",
16698
- readonly: true
16982
+ readOnly: true
16699
16983
  }, {
16700
16984
  name: "selectNextAfter",
16701
16985
  exec: function(editor) { editor.selectMore(1, true); },
16702
16986
  bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
16703
16987
  scrollIntoView: "cursor",
16704
- readonly: true
16988
+ readOnly: true
16705
16989
  }, {
16706
16990
  name: "splitIntoLines",
16707
16991
  exec: function(editor) { editor.multiSelect.splitIntoLines(); },
16708
16992
  bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"},
16709
- readonly: true
16993
+ readOnly: true
16710
16994
  }, {
16711
16995
  name: "alignCursors",
16712
16996
  exec: function(editor) { editor.alignCursors(); },
@@ -16717,14 +17001,14 @@ exports.defaultCommands = [{
16717
17001
  exec: function(editor) { editor.findAll(); },
16718
17002
  bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
16719
17003
  scrollIntoView: "cursor",
16720
- readonly: true
17004
+ readOnly: true
16721
17005
  }];
16722
17006
  exports.multiSelectCommands = [{
16723
17007
  name: "singleSelection",
16724
17008
  bindKey: "esc",
16725
17009
  exec: function(editor) { editor.exitMultiSelectMode(); },
16726
17010
  scrollIntoView: "cursor",
16727
- readonly: true,
17011
+ readOnly: true,
16728
17012
  isAvailable: function(editor) {return editor && editor.inMultiSelectMode}
16729
17013
  }];
16730
17014
 
@@ -17326,9 +17610,9 @@ var Editor = require("./editor").Editor;
17326
17610
  if (fr < 0) fr = 0;
17327
17611
  if (lr >= max) lr = max - 1;
17328
17612
  }
17329
- var lines = this.session.doc.removeLines(fr, lr);
17613
+ var lines = this.session.removeFullLines(fr, lr);
17330
17614
  lines = this.$reAlignText(lines, guessRange);
17331
- this.session.doc.insert({row: fr, column: 0}, lines.join("\n") + "\n");
17615
+ this.session.insert({row: fr, column: 0}, lines.join("\n") + "\n");
17332
17616
  if (!guessRange) {
17333
17617
  range.start.column = 0;
17334
17618
  range.end.column = lines[lines.length - 1].length;
@@ -17489,7 +17773,8 @@ function addAltCursorListeners(editor){
17489
17773
  var el = editor.textInput.getElement();
17490
17774
  var altCursor = false;
17491
17775
  event.addListener(el, "keydown", function(e) {
17492
- if (e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey)) {
17776
+ var altDown = e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey);
17777
+ if (editor.$blockSelectEnabled && altDown) {
17493
17778
  if (!altCursor) {
17494
17779
  editor.renderer.setMouseCursor("crosshair");
17495
17780
  altCursor = true;
@@ -17525,6 +17810,12 @@ require("./config").defineOptions(Editor.prototype, "editor", {
17525
17810
  }
17526
17811
  },
17527
17812
  value: true
17813
+ },
17814
+ enableBlockSelect: {
17815
+ set: function(val) {
17816
+ this.$blockSelectEnabled = val;
17817
+ },
17818
+ value: true
17528
17819
  }
17529
17820
  });
17530
17821
 
@@ -17721,7 +18012,6 @@ background: rgb(181, 213, 255);\
17721
18012
  }\
17722
18013
  .ace-tm.ace_multiselect .ace_selection.ace_start {\
17723
18014
  box-shadow: 0 0 3px 0px white;\
17724
- border-radius: 2px;\
17725
18015
  }\
17726
18016
  .ace-tm .ace_marker-layer .ace_step {\
17727
18017
  background: rgb(252, 255, 0);\
@@ -17772,6 +18062,7 @@ function LineWidgets(session) {
17772
18062
  this.$onChangeEditor = this.$onChangeEditor.bind(this);
17773
18063
 
17774
18064
  this.session.on("change", this.updateOnChange);
18065
+ this.session.on("changeFold", this.updateOnFold);
17775
18066
  this.session.on("changeEditor", this.$onChangeEditor);
17776
18067
  }
17777
18068
 
@@ -17792,8 +18083,8 @@ function LineWidgets(session) {
17792
18083
  this.$getWidgetScreenLength = function() {
17793
18084
  var screenRows = 0;
17794
18085
  this.lineWidgets.forEach(function(w){
17795
- if (w && w.rowCount)
17796
- screenRows +=w.rowCount;
18086
+ if (w && w.rowCount && !w.hidden)
18087
+ screenRows += w.rowCount;
17797
18088
  });
17798
18089
  return screenRows;
17799
18090
  };
@@ -17837,17 +18128,41 @@ function LineWidgets(session) {
17837
18128
  });
17838
18129
  };
17839
18130
 
17840
- this.updateOnChange = function(e) {
18131
+ this.updateOnFold = function(e, session) {
18132
+ var lineWidgets = session.lineWidgets;
18133
+ if (!lineWidgets || !e.action)
18134
+ return;
18135
+ var fold = e.data;
18136
+ var start = fold.start.row;
18137
+ var end = fold.end.row;
18138
+ var hide = e.action == "add";
18139
+ for (var i = start + 1; i < end; i++) {
18140
+ if (lineWidgets[i])
18141
+ lineWidgets[i].hidden = hide;
18142
+ }
18143
+ if (lineWidgets[end]) {
18144
+ if (hide) {
18145
+ if (!lineWidgets[start])
18146
+ lineWidgets[start] = lineWidgets[end];
18147
+ else
18148
+ lineWidgets[end].hidden = hide;
18149
+ } else {
18150
+ if (lineWidgets[start] == lineWidgets[end])
18151
+ lineWidgets[start] = undefined;
18152
+ lineWidgets[end].hidden = hide;
18153
+ }
18154
+ }
18155
+ };
18156
+
18157
+ this.updateOnChange = function(delta) {
17841
18158
  var lineWidgets = this.session.lineWidgets;
17842
18159
  if (!lineWidgets) return;
17843
-
17844
- var delta = e.data;
17845
- var range = delta.range;
17846
- var startRow = range.start.row;
17847
- var len = range.end.row - startRow;
18160
+
18161
+ var startRow = delta.start.row;
18162
+ var len = delta.end.row - startRow;
17848
18163
 
17849
18164
  if (len === 0) {
17850
- } else if (delta.action == "removeText" || delta.action == "removeLines") {
18165
+ } else if (delta.action == 'remove') {
17851
18166
  var removed = lineWidgets.splice(startRow + 1, len);
17852
18167
  removed.forEach(function(w) {
17853
18168
  w && this.removeLineWidget(w);
@@ -17869,6 +18184,10 @@ function LineWidgets(session) {
17869
18184
  if (w) {
17870
18185
  noWidgets = false;
17871
18186
  w.row = i;
18187
+ while (w.$oldWidget) {
18188
+ w.$oldWidget.row = i;
18189
+ w = w.$oldWidget;
18190
+ }
17872
18191
  }
17873
18192
  });
17874
18193
  if (noWidgets)
@@ -17879,8 +18198,19 @@ function LineWidgets(session) {
17879
18198
  if (!this.session.lineWidgets)
17880
18199
  this.session.lineWidgets = new Array(this.session.getLength());
17881
18200
 
18201
+ var old = this.session.lineWidgets[w.row];
18202
+ if (old) {
18203
+ w.$oldWidget = old;
18204
+ if (old.el && old.el.parentNode) {
18205
+ old.el.parentNode.removeChild(old.el);
18206
+ old._inDocument = false;
18207
+ }
18208
+ }
18209
+
17882
18210
  this.session.lineWidgets[w.row] = w;
17883
18211
 
18212
+ w.session = this.session;
18213
+
17884
18214
  var renderer = this.editor.renderer;
17885
18215
  if (w.html && !w.el) {
17886
18216
  w.el = dom.createElement("div");
@@ -17900,29 +18230,67 @@ function LineWidgets(session) {
17900
18230
  if (!w.pixelHeight) {
17901
18231
  w.pixelHeight = w.el.offsetHeight;
17902
18232
  }
17903
- if (w.rowCount == null)
18233
+ if (w.rowCount == null) {
17904
18234
  w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight;
18235
+ }
17905
18236
 
18237
+ var fold = this.session.getFoldAt(w.row, 0);
18238
+ w.$fold = fold;
18239
+ if (fold) {
18240
+ var lineWidgets = this.session.lineWidgets;
18241
+ if (w.row == fold.end.row && !lineWidgets[fold.start.row])
18242
+ lineWidgets[fold.start.row] = w;
18243
+ else
18244
+ w.hidden = true;
18245
+ }
18246
+
17906
18247
  this.session._emit("changeFold", {data:{start:{row: w.row}}});
17907
18248
 
17908
18249
  this.$updateRows();
17909
18250
  this.renderWidgets(null, renderer);
18251
+ this.onWidgetChanged(w);
17910
18252
  return w;
17911
18253
  };
17912
18254
 
17913
18255
  this.removeLineWidget = function(w) {
17914
18256
  w._inDocument = false;
18257
+ w.session = null;
17915
18258
  if (w.el && w.el.parentNode)
17916
18259
  w.el.parentNode.removeChild(w.el);
17917
18260
  if (w.editor && w.editor.destroy) try {
17918
18261
  w.editor.destroy();
17919
18262
  } catch(e){}
17920
- if (this.session.lineWidgets)
17921
- this.session.lineWidgets[w.row] = undefined;
18263
+ if (this.session.lineWidgets) {
18264
+ var w1 = this.session.lineWidgets[w.row]
18265
+ if (w1 == w) {
18266
+ this.session.lineWidgets[w.row] = w.$oldWidget;
18267
+ if (w.$oldWidget)
18268
+ this.onWidgetChanged(w.$oldWidget);
18269
+ } else {
18270
+ while (w1) {
18271
+ if (w1.$oldWidget == w) {
18272
+ w1.$oldWidget = w.$oldWidget;
18273
+ break;
18274
+ }
18275
+ w1 = w1.$oldWidget;
18276
+ }
18277
+ }
18278
+ }
17922
18279
  this.session._emit("changeFold", {data:{start:{row: w.row}}});
17923
18280
  this.$updateRows();
17924
18281
  };
17925
18282
 
18283
+ this.getWidgetsAtRow = function(row) {
18284
+ var lineWidgets = this.session.lineWidgets;
18285
+ var w = lineWidgets && lineWidgets[row];
18286
+ var list = [];
18287
+ while (w) {
18288
+ list.push(w);
18289
+ w = w.$oldWidget;
18290
+ }
18291
+ return list;
18292
+ };
18293
+
17926
18294
  this.onWidgetChanged = function(w) {
17927
18295
  this.session._changedWidgets.push(w);
17928
18296
  this.editor && this.editor.renderer.updateFull();
@@ -17936,6 +18304,8 @@ function LineWidgets(session) {
17936
18304
  var min = Infinity;
17937
18305
  for (var i = 0; i < changedWidgets.length; i++) {
17938
18306
  var w = changedWidgets[i];
18307
+ if (!w || !w.el) continue;
18308
+ if (w.session != this.session) continue;
17939
18309
  if (!w._inDocument) {
17940
18310
  w._inDocument = true;
17941
18311
  renderer.container.appendChild(w.el);
@@ -17985,7 +18355,10 @@ function LineWidgets(session) {
17985
18355
  for (var i = first; i <= last; i++) {
17986
18356
  var w = lineWidgets[i];
17987
18357
  if (!w || !w.el) continue;
17988
-
18358
+ if (w.hidden) {
18359
+ w.el.style.top = -100 - (w.pixelHeight || 0) + "px";
18360
+ continue;
18361
+ }
17989
18362
  if (!w._inDocument) {
17990
18363
  w._inDocument = true;
17991
18364
  renderer.container.appendChild(w.el);
@@ -17999,7 +18372,11 @@ function LineWidgets(session) {
17999
18372
  if (!w.fixedWidth)
18000
18373
  left -= renderer.scrollLeft;
18001
18374
  w.el.style.left = left + "px";
18002
-
18375
+
18376
+ if (w.fullWidth && w.screenWidth) {
18377
+ w.el.style.minWidth = config.width + 2 * config.padding + "px";
18378
+ }
18379
+
18003
18380
  if (w.fixedWidth) {
18004
18381
  w.el.style.right = renderer.scrollBar.getWidth() + "px";
18005
18382
  } else {
@@ -18083,7 +18460,9 @@ exports.showErrorMarker = function(editor, dir) {
18083
18460
 
18084
18461
  var pos = editor.getCursorPosition();
18085
18462
  var row = pos.row;
18086
- var oldWidget = session.lineWidgets && session.lineWidgets[row];
18463
+ var oldWidget = session.widgetManager.getWidgetsAtRow(row).filter(function(w) {
18464
+ return w.type == "errorMarker";
18465
+ })[0];
18087
18466
  if (oldWidget) {
18088
18467
  oldWidget.destroy();
18089
18468
  } else {
@@ -18113,7 +18492,8 @@ exports.showErrorMarker = function(editor, dir) {
18113
18492
  row: pos.row,
18114
18493
  fixedWidth: true,
18115
18494
  coverGutter: true,
18116
- el: dom.createElement("div")
18495
+ el: dom.createElement("div"),
18496
+ type: "errorMarker"
18117
18497
  };
18118
18498
  var el = w.el.appendChild(dom.createElement("div"));
18119
18499
  var arrow = w.el.appendChild(dom.createElement("div"));
@@ -18237,7 +18617,7 @@ exports.edit = function(el) {
18237
18617
  value = oldNode.value;
18238
18618
  el = dom.createElement("pre");
18239
18619
  oldNode.parentNode.replaceChild(el, oldNode);
18240
- } else {
18620
+ } else if (el) {
18241
18621
  value = dom.getInnerText(el);
18242
18622
  el.innerHTML = '';
18243
18623
  }