ace-rails-ap 4.3 → 4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (249) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/ace-rails-ap.gemspec +0 -2
  4. data/lib/ace/rails/version.rb +1 -1
  5. data/vendor/assets/javascripts/ace/ace.js +659 -1137
  6. data/vendor/assets/javascripts/ace/ext-beautify.js +5 -2
  7. data/vendor/assets/javascripts/ace/ext-code_lens.js +238 -0
  8. data/vendor/assets/javascripts/ace/ext-emmet.js +36 -28
  9. data/vendor/assets/javascripts/ace/ext-language_tools.js +63 -48
  10. data/vendor/assets/javascripts/ace/ext-modelist.js +12 -6
  11. data/vendor/assets/javascripts/ace/ext-options.js +46 -19
  12. data/vendor/assets/javascripts/ace/ext-prompt.js +57 -38
  13. data/vendor/assets/javascripts/ace/ext-settings_menu.js +46 -19
  14. data/vendor/assets/javascripts/ace/ext-spellcheck.js +0 -1
  15. data/vendor/assets/javascripts/ace/ext-themelist.js +2 -1
  16. data/vendor/assets/javascripts/ace/keybinding-emacs.js +21 -22
  17. data/vendor/assets/javascripts/ace/keybinding-sublime.js +2 -5
  18. data/vendor/assets/javascripts/ace/keybinding-vim.js +45 -9
  19. data/vendor/assets/javascripts/ace/keybinding-vscode.js +262 -0
  20. data/vendor/assets/javascripts/ace/mode-abc.js +3 -0
  21. data/vendor/assets/javascripts/ace/mode-actionscript.js +1 -0
  22. data/vendor/assets/javascripts/ace/mode-alda.js +311 -0
  23. data/vendor/assets/javascripts/ace/mode-asl.js +17 -16
  24. data/vendor/assets/javascripts/ace/mode-c_cpp.js +1 -0
  25. data/vendor/assets/javascripts/ace/mode-clojure.js +1 -0
  26. data/vendor/assets/javascripts/ace/mode-coffee.js +1 -0
  27. data/vendor/assets/javascripts/ace/mode-coldfusion.js +3 -0
  28. data/vendor/assets/javascripts/ace/mode-csound_document.js +40 -5
  29. data/vendor/assets/javascripts/ace/mode-csound_orchestra.js +37 -5
  30. data/vendor/assets/javascripts/ace/mode-csound_score.js +1 -0
  31. data/vendor/assets/javascripts/ace/mode-css.js +1 -0
  32. data/vendor/assets/javascripts/ace/mode-curly.js +3 -0
  33. data/vendor/assets/javascripts/ace/mode-d.js +1 -1
  34. data/vendor/assets/javascripts/ace/mode-dart.js +2 -0
  35. data/vendor/assets/javascripts/ace/mode-diff.js +1 -0
  36. data/vendor/assets/javascripts/ace/mode-django.js +4 -0
  37. data/vendor/assets/javascripts/ace/mode-dockerfile.js +1 -0
  38. data/vendor/assets/javascripts/ace/mode-drools.js +1 -0
  39. data/vendor/assets/javascripts/ace/mode-edifact.js +1 -0
  40. data/vendor/assets/javascripts/ace/mode-ejs.js +673 -165
  41. data/vendor/assets/javascripts/ace/mode-erlang.js +1 -0
  42. data/vendor/assets/javascripts/ace/mode-fsl.js +1 -0
  43. data/vendor/assets/javascripts/ace/mode-glsl.js +1 -0
  44. data/vendor/assets/javascripts/ace/mode-gobstones.js +2 -0
  45. data/vendor/assets/javascripts/ace/mode-graphqlschema.js +1 -0
  46. data/vendor/assets/javascripts/ace/mode-groovy.js +1 -0
  47. data/vendor/assets/javascripts/ace/mode-haml.js +419 -104
  48. data/vendor/assets/javascripts/ace/mode-handlebars.js +3 -0
  49. data/vendor/assets/javascripts/ace/mode-haskell.js +1 -0
  50. data/vendor/assets/javascripts/ace/mode-html.js +3 -0
  51. data/vendor/assets/javascripts/ace/mode-html_elixir.js +3 -0
  52. data/vendor/assets/javascripts/ace/mode-html_ruby.js +673 -165
  53. data/vendor/assets/javascripts/ace/mode-io.js +1 -0
  54. data/vendor/assets/javascripts/ace/mode-java.js +2 -0
  55. data/vendor/assets/javascripts/ace/mode-javascript.js +1 -0
  56. data/vendor/assets/javascripts/ace/mode-json.js +3 -0
  57. data/vendor/assets/javascripts/ace/mode-json5.js +360 -0
  58. data/vendor/assets/javascripts/ace/mode-jsoniq.js +1 -0
  59. data/vendor/assets/javascripts/ace/mode-jsp.js +1 -0
  60. data/vendor/assets/javascripts/ace/mode-kotlin.js +2 -0
  61. data/vendor/assets/javascripts/ace/mode-liquid.js +4 -0
  62. data/vendor/assets/javascripts/ace/mode-lsl.js +1 -0
  63. data/vendor/assets/javascripts/ace/mode-lua.js +1 -0
  64. data/vendor/assets/javascripts/ace/mode-luapage.js +4 -0
  65. data/vendor/assets/javascripts/ace/mode-makefile.js +1 -0
  66. data/vendor/assets/javascripts/ace/mode-markdown.js +5 -0
  67. data/vendor/assets/javascripts/ace/mode-maze.js +1 -0
  68. data/vendor/assets/javascripts/ace/mode-mediawiki.js +592 -0
  69. data/vendor/assets/javascripts/ace/mode-nix.js +1 -0
  70. data/vendor/assets/javascripts/ace/mode-nsis.js +1 -1
  71. data/vendor/assets/javascripts/ace/mode-nunjucks.js +2698 -0
  72. data/vendor/assets/javascripts/ace/mode-perl.js +1 -0
  73. data/vendor/assets/javascripts/ace/mode-pgsql.js +2 -2
  74. data/vendor/assets/javascripts/ace/mode-php.js +4 -0
  75. data/vendor/assets/javascripts/ace/mode-php_laravel_blade.js +4 -0
  76. data/vendor/assets/javascripts/ace/mode-prisma.js +489 -0
  77. data/vendor/assets/javascripts/ace/mode-protobuf.js +1 -0
  78. data/vendor/assets/javascripts/ace/mode-puppet.js +5 -6
  79. data/vendor/assets/javascripts/ace/mode-python.js +3 -2
  80. data/vendor/assets/javascripts/ace/mode-qml.js +381 -0
  81. data/vendor/assets/javascripts/ace/mode-r.js +1 -0
  82. data/vendor/assets/javascripts/ace/mode-razor.js +4 -0
  83. data/vendor/assets/javascripts/ace/mode-rhtml.js +3 -0
  84. data/vendor/assets/javascripts/ace/mode-rst.js +1 -0
  85. data/vendor/assets/javascripts/ace/mode-ruby.js +670 -165
  86. data/vendor/assets/javascripts/ace/mode-rust.js +1 -1
  87. data/vendor/assets/javascripts/ace/mode-scala.js +1 -0
  88. data/vendor/assets/javascripts/ace/mode-sh.js +1 -0
  89. data/vendor/assets/javascripts/ace/mode-sjs.js +1 -0
  90. data/vendor/assets/javascripts/ace/mode-slim.js +708 -110
  91. data/vendor/assets/javascripts/ace/mode-smarty.js +3 -0
  92. data/vendor/assets/javascripts/ace/mode-snippets.js +1 -0
  93. data/vendor/assets/javascripts/ace/mode-soy_template.js +3 -0
  94. data/vendor/assets/javascripts/ace/mode-sql.js +1 -0
  95. data/vendor/assets/javascripts/ace/mode-sqlserver.js +2 -1
  96. data/vendor/assets/javascripts/ace/mode-svg.js +1 -0
  97. data/vendor/assets/javascripts/ace/mode-swift.js +6 -0
  98. data/vendor/assets/javascripts/ace/mode-tcl.js +1 -0
  99. data/vendor/assets/javascripts/ace/mode-terraform.js +10 -7
  100. data/vendor/assets/javascripts/ace/mode-tex.js +1 -0
  101. data/vendor/assets/javascripts/ace/mode-textile.js +1 -0
  102. data/vendor/assets/javascripts/ace/mode-tsx.js +1 -0
  103. data/vendor/assets/javascripts/ace/mode-twig.js +3 -0
  104. data/vendor/assets/javascripts/ace/mode-typescript.js +1 -0
  105. data/vendor/assets/javascripts/ace/mode-vala.js +1 -0
  106. data/vendor/assets/javascripts/ace/mode-vbscript.js +444 -15
  107. data/vendor/assets/javascripts/ace/mode-velocity.js +4 -0
  108. data/vendor/assets/javascripts/ace/mode-vhdl.js +5 -6
  109. data/vendor/assets/javascripts/ace/mode-visualforce.js +3 -0
  110. data/vendor/assets/javascripts/ace/mode-wollok.js +2 -0
  111. data/vendor/assets/javascripts/ace/mode-xquery.js +1 -0
  112. data/vendor/assets/javascripts/ace/snippets/abap.js +1 -6
  113. data/vendor/assets/javascripts/ace/snippets/ada.js +1 -6
  114. data/vendor/assets/javascripts/ace/snippets/alda.js +9 -0
  115. data/vendor/assets/javascripts/ace/snippets/apache_conf.js +1 -6
  116. data/vendor/assets/javascripts/ace/snippets/apex.js +1 -6
  117. data/vendor/assets/javascripts/ace/snippets/applescript.js +1 -6
  118. data/vendor/assets/javascripts/ace/snippets/aql.js +1 -6
  119. data/vendor/assets/javascripts/ace/snippets/asciidoc.js +1 -6
  120. data/vendor/assets/javascripts/ace/snippets/asl.js +1 -5
  121. data/vendor/assets/javascripts/ace/snippets/assembly_x86.js +1 -6
  122. data/vendor/assets/javascripts/ace/snippets/autohotkey.js +1 -6
  123. data/vendor/assets/javascripts/ace/snippets/batchfile.js +1 -6
  124. data/vendor/assets/javascripts/ace/snippets/c9search.js +1 -6
  125. data/vendor/assets/javascripts/ace/snippets/cirru.js +1 -6
  126. data/vendor/assets/javascripts/ace/snippets/cobol.js +1 -6
  127. data/vendor/assets/javascripts/ace/snippets/coldfusion.js +1 -6
  128. data/vendor/assets/javascripts/ace/snippets/crystal.js +1 -6
  129. data/vendor/assets/javascripts/ace/snippets/csharp.js +1 -6
  130. data/vendor/assets/javascripts/ace/snippets/csound_score.js +1 -6
  131. data/vendor/assets/javascripts/ace/snippets/csp.js +1 -6
  132. data/vendor/assets/javascripts/ace/snippets/curly.js +1 -6
  133. data/vendor/assets/javascripts/ace/snippets/d.js +1 -6
  134. data/vendor/assets/javascripts/ace/snippets/dockerfile.js +1 -6
  135. data/vendor/assets/javascripts/ace/snippets/dot.js +1 -6
  136. data/vendor/assets/javascripts/ace/snippets/eiffel.js +1 -6
  137. data/vendor/assets/javascripts/ace/snippets/ejs.js +1 -6
  138. data/vendor/assets/javascripts/ace/snippets/elixir.js +1 -6
  139. data/vendor/assets/javascripts/ace/snippets/elm.js +1 -6
  140. data/vendor/assets/javascripts/ace/snippets/forth.js +1 -6
  141. data/vendor/assets/javascripts/ace/snippets/fortran.js +1 -6
  142. data/vendor/assets/javascripts/ace/snippets/fsharp.js +1 -6
  143. data/vendor/assets/javascripts/ace/snippets/ftl.js +1 -6
  144. data/vendor/assets/javascripts/ace/snippets/gcode.js +1 -6
  145. data/vendor/assets/javascripts/ace/snippets/gherkin.js +1 -6
  146. data/vendor/assets/javascripts/ace/snippets/gitignore.js +1 -6
  147. data/vendor/assets/javascripts/ace/snippets/glsl.js +1 -6
  148. data/vendor/assets/javascripts/ace/snippets/golang.js +1 -6
  149. data/vendor/assets/javascripts/ace/snippets/groovy.js +1 -6
  150. data/vendor/assets/javascripts/ace/snippets/handlebars.js +1 -6
  151. data/vendor/assets/javascripts/ace/snippets/haskell_cabal.js +1 -6
  152. data/vendor/assets/javascripts/ace/snippets/haxe.js +1 -6
  153. data/vendor/assets/javascripts/ace/snippets/hjson.js +1 -6
  154. data/vendor/assets/javascripts/ace/snippets/html_elixir.js +1 -6
  155. data/vendor/assets/javascripts/ace/snippets/html_ruby.js +1 -6
  156. data/vendor/assets/javascripts/ace/snippets/ini.js +1 -6
  157. data/vendor/assets/javascripts/ace/snippets/jack.js +1 -6
  158. data/vendor/assets/javascripts/ace/snippets/jade.js +1 -6
  159. data/vendor/assets/javascripts/ace/snippets/json.js +1 -6
  160. data/vendor/assets/javascripts/ace/snippets/json5.js +9 -0
  161. data/vendor/assets/javascripts/ace/snippets/jssm.js +1 -6
  162. data/vendor/assets/javascripts/ace/snippets/jsx.js +1 -6
  163. data/vendor/assets/javascripts/ace/snippets/julia.js +1 -6
  164. data/vendor/assets/javascripts/ace/snippets/kotlin.js +1 -6
  165. data/vendor/assets/javascripts/ace/snippets/latex.js +1 -6
  166. data/vendor/assets/javascripts/ace/snippets/less.js +1 -6
  167. data/vendor/assets/javascripts/ace/snippets/lisp.js +1 -6
  168. data/vendor/assets/javascripts/ace/snippets/livescript.js +1 -6
  169. data/vendor/assets/javascripts/ace/snippets/logiql.js +1 -6
  170. data/vendor/assets/javascripts/ace/snippets/logtalk.js +1 -6
  171. data/vendor/assets/javascripts/ace/snippets/luapage.js +1 -6
  172. data/vendor/assets/javascripts/ace/snippets/lucene.js +1 -6
  173. data/vendor/assets/javascripts/ace/snippets/mask.js +1 -6
  174. data/vendor/assets/javascripts/ace/snippets/matlab.js +1 -6
  175. data/vendor/assets/javascripts/ace/snippets/mediawiki.js +9 -0
  176. data/vendor/assets/javascripts/ace/snippets/mel.js +1 -6
  177. data/vendor/assets/javascripts/ace/snippets/mixal.js +1 -6
  178. data/vendor/assets/javascripts/ace/snippets/mushcode.js +1 -6
  179. data/vendor/assets/javascripts/ace/snippets/mysql.js +1 -6
  180. data/vendor/assets/javascripts/ace/snippets/nginx.js +1 -6
  181. data/vendor/assets/javascripts/ace/snippets/nim.js +1 -6
  182. data/vendor/assets/javascripts/ace/snippets/nix.js +1 -6
  183. data/vendor/assets/javascripts/ace/snippets/nsis.js +1 -6
  184. data/vendor/assets/javascripts/ace/snippets/nunjucks.js +9 -0
  185. data/vendor/assets/javascripts/ace/snippets/objectivec.js +1 -6
  186. data/vendor/assets/javascripts/ace/snippets/ocaml.js +1 -6
  187. data/vendor/assets/javascripts/ace/snippets/pascal.js +1 -6
  188. data/vendor/assets/javascripts/ace/snippets/perl6.js +1 -6
  189. data/vendor/assets/javascripts/ace/snippets/pgsql.js +1 -6
  190. data/vendor/assets/javascripts/ace/snippets/php_laravel_blade.js +1 -6
  191. data/vendor/assets/javascripts/ace/snippets/pig.js +1 -6
  192. data/vendor/assets/javascripts/ace/snippets/plain_text.js +1 -6
  193. data/vendor/assets/javascripts/ace/snippets/powershell.js +1 -6
  194. data/vendor/assets/javascripts/ace/snippets/praat.js +1 -6
  195. data/vendor/assets/javascripts/ace/snippets/prisma.js +9 -0
  196. data/vendor/assets/javascripts/ace/snippets/prolog.js +1 -6
  197. data/vendor/assets/javascripts/ace/snippets/properties.js +1 -6
  198. data/vendor/assets/javascripts/ace/snippets/protobuf.js +1 -6
  199. data/vendor/assets/javascripts/ace/snippets/puppet.js +1 -6
  200. data/vendor/assets/javascripts/ace/snippets/qml.js +9 -0
  201. data/vendor/assets/javascripts/ace/snippets/rdoc.js +1 -6
  202. data/vendor/assets/javascripts/ace/snippets/red.js +1 -6
  203. data/vendor/assets/javascripts/ace/snippets/redshift.js +1 -6
  204. data/vendor/assets/javascripts/ace/snippets/rhtml.js +1 -6
  205. data/vendor/assets/javascripts/ace/snippets/rust.js +1 -6
  206. data/vendor/assets/javascripts/ace/snippets/sass.js +1 -6
  207. data/vendor/assets/javascripts/ace/snippets/scad.js +1 -6
  208. data/vendor/assets/javascripts/ace/snippets/scala.js +1 -6
  209. data/vendor/assets/javascripts/ace/snippets/scheme.js +1 -6
  210. data/vendor/assets/javascripts/ace/snippets/scss.js +1 -6
  211. data/vendor/assets/javascripts/ace/snippets/sjs.js +1 -6
  212. data/vendor/assets/javascripts/ace/snippets/slim.js +1 -6
  213. data/vendor/assets/javascripts/ace/snippets/smarty.js +1 -6
  214. data/vendor/assets/javascripts/ace/snippets/soy_template.js +1 -6
  215. data/vendor/assets/javascripts/ace/snippets/space.js +1 -6
  216. data/vendor/assets/javascripts/ace/snippets/sparql.js +1 -6
  217. data/vendor/assets/javascripts/ace/snippets/stylus.js +1 -6
  218. data/vendor/assets/javascripts/ace/snippets/svg.js +1 -6
  219. data/vendor/assets/javascripts/ace/snippets/swift.js +1 -6
  220. data/vendor/assets/javascripts/ace/snippets/terraform.js +1 -6
  221. data/vendor/assets/javascripts/ace/snippets/text.js +1 -6
  222. data/vendor/assets/javascripts/ace/snippets/toml.js +1 -6
  223. data/vendor/assets/javascripts/ace/snippets/tsx.js +1 -6
  224. data/vendor/assets/javascripts/ace/snippets/turtle.js +1 -6
  225. data/vendor/assets/javascripts/ace/snippets/twig.js +1 -6
  226. data/vendor/assets/javascripts/ace/snippets/typescript.js +1 -6
  227. data/vendor/assets/javascripts/ace/snippets/vbscript.js +1 -6
  228. data/vendor/assets/javascripts/ace/snippets/verilog.js +1 -6
  229. data/vendor/assets/javascripts/ace/snippets/vhdl.js +1 -6
  230. data/vendor/assets/javascripts/ace/snippets/visualforce.js +1 -6
  231. data/vendor/assets/javascripts/ace/snippets/xml.js +1 -6
  232. data/vendor/assets/javascripts/ace/snippets/yaml.js +1 -6
  233. data/vendor/assets/javascripts/ace/snippets/zeek.js +1 -6
  234. data/vendor/assets/javascripts/ace/theme-ambiance.js +3 -2
  235. data/vendor/assets/javascripts/ace/theme-chaos.js +1 -1
  236. data/vendor/assets/javascripts/ace/theme-nord_dark.js +102 -0
  237. data/vendor/assets/javascripts/ace/worker-base.js +1421 -0
  238. data/vendor/assets/javascripts/ace/worker-coffee.js +17 -703
  239. data/vendor/assets/javascripts/ace/worker-css.js +17 -703
  240. data/vendor/assets/javascripts/ace/worker-html.js +17 -703
  241. data/vendor/assets/javascripts/ace/worker-javascript.js +7833 -5352
  242. data/vendor/assets/javascripts/ace/worker-json.js +17 -703
  243. data/vendor/assets/javascripts/ace/worker-lua.js +17 -703
  244. data/vendor/assets/javascripts/ace/worker-php.js +857 -1475
  245. data/vendor/assets/javascripts/ace/worker-xml.js +26 -707
  246. data/vendor/assets/javascripts/ace/worker-xquery.js +17 -703
  247. metadata +18 -4
  248. data/vendor/assets/javascripts/ace/mode-bro.js +0 -334
  249. data/vendor/assets/javascripts/ace/snippets/bro.js +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77b42605762b0e7b692f3016aca72bff17969db1ea03ebf10db879e55903b42b
4
- data.tar.gz: 61e50b5abcfec5370aa3091f9badf12c049f44ee73589878fc47c1a318c5b579
3
+ metadata.gz: a341bb92a730f00a283479cace89e53c27f20b02d97f4fba54b0c95a62805355
4
+ data.tar.gz: 518d912707a42bc388f5740b7dd2a5b4499927231723e767507943f8c4968094
5
5
  SHA512:
6
- metadata.gz: 5e0ff1f0f98d38aef4aa50840ee8ec90db0e3d00c6ae255b652edd559fbc702cb10040ef61e90f7bb1979fc85500a37ee4cb9a87cd7f0ffcf47b1e032a7bc475
7
- data.tar.gz: 12e3168150cf86833e48877cd75fca02bbcc496cc2b638a44a4b7411126afb536ecf79c319847f9311e3dfffd5862224d168b6a8c2fc7e7df36ef2bb1af6f599
6
+ metadata.gz: acdd2f461c5eb9422473d9ad3cbc49aba9a818795a4577142a34c6494b46c0f6e4e40151036204b5fa2e130ca78cb6afe45a4bfeed4e72efa68c054ff7c10179
7
+ data.tar.gz: 9326218f4c54749b5a11b08760bb30b6c552ec14e2d0c6b6698beca186121a3c296a221d6832268c41eb9139662ab35d9dc386cdafa59261ced8a27015bf6139
data/Gemfile CHANGED
@@ -3,6 +3,6 @@ source "http://rubygems.org"
3
3
  # Specify your gem's dependencies in ace-rails-ap.gemspec
4
4
  gemspec
5
5
 
6
- gem "rack", "~> 1.6.11"
6
+ gem "rack", ">= 2.1.4"
7
7
  gem "sprockets"
8
- gem "i18n", "~> 0.6"
8
+ gem "i18n"
@@ -13,8 +13,6 @@ Gem::Specification.new do |s|
13
13
  s.description = %q{The Ajax.org Cloud9 Editor (Ace) for the Rails 3.1 asset pipeline.}
14
14
  s.license = "MIT"
15
15
 
16
- s.rubyforge_project = "ace-rails-ap"
17
-
18
16
  s.files = `git ls-files`.split("\n")
19
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -1,5 +1,5 @@
1
1
  module Ace
2
2
  module Rails
3
- VERSION = "4.3"
3
+ VERSION = "4.4"
4
4
  end
5
5
  end
@@ -173,781 +173,8 @@ exportAce(ACE_NAMESPACE);
173
173
 
174
174
  })();
175
175
 
176
- define("ace/lib/regexp",["require","exports","module"], function(require, exports, module) {
176
+ define("ace/lib/fixoldbrowsers",["require","exports","module"], function(require, exports, module) {
177
177
  "use strict";
178
-
179
- var real = {
180
- exec: RegExp.prototype.exec,
181
- test: RegExp.prototype.test,
182
- match: String.prototype.match,
183
- replace: String.prototype.replace,
184
- split: String.prototype.split
185
- },
186
- compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
187
- compliantLastIndexIncrement = function () {
188
- var x = /^/g;
189
- real.test.call(x, "");
190
- return !x.lastIndex;
191
- }();
192
-
193
- if (compliantLastIndexIncrement && compliantExecNpcg)
194
- return;
195
- RegExp.prototype.exec = function (str) {
196
- var match = real.exec.apply(this, arguments),
197
- name, r2;
198
- if ( typeof(str) == 'string' && match) {
199
- if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
200
- r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
201
- real.replace.call(str.slice(match.index), r2, function () {
202
- for (var i = 1; i < arguments.length - 2; i++) {
203
- if (arguments[i] === undefined)
204
- match[i] = undefined;
205
- }
206
- });
207
- }
208
- if (this._xregexp && this._xregexp.captureNames) {
209
- for (var i = 1; i < match.length; i++) {
210
- name = this._xregexp.captureNames[i - 1];
211
- if (name)
212
- match[name] = match[i];
213
- }
214
- }
215
- if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
216
- this.lastIndex--;
217
- }
218
- return match;
219
- };
220
- if (!compliantLastIndexIncrement) {
221
- RegExp.prototype.test = function (str) {
222
- var match = real.exec.call(this, str);
223
- if (match && this.global && !match[0].length && (this.lastIndex > match.index))
224
- this.lastIndex--;
225
- return !!match;
226
- };
227
- }
228
-
229
- function getNativeFlags (regex) {
230
- return (regex.global ? "g" : "") +
231
- (regex.ignoreCase ? "i" : "") +
232
- (regex.multiline ? "m" : "") +
233
- (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
234
- (regex.sticky ? "y" : "");
235
- }
236
-
237
- function indexOf (array, item, from) {
238
- if (Array.prototype.indexOf) // Use the native array method if available
239
- return array.indexOf(item, from);
240
- for (var i = from || 0; i < array.length; i++) {
241
- if (array[i] === item)
242
- return i;
243
- }
244
- return -1;
245
- }
246
-
247
- });
248
-
249
- define("ace/lib/es5-shim",["require","exports","module"], function(require, exports, module) {
250
-
251
- function Empty() {}
252
-
253
- if (!Function.prototype.bind) {
254
- Function.prototype.bind = function bind(that) { // .length is 1
255
- var target = this;
256
- if (typeof target != "function") {
257
- throw new TypeError("Function.prototype.bind called on incompatible " + target);
258
- }
259
- var args = slice.call(arguments, 1); // for normal call
260
- var bound = function () {
261
-
262
- if (this instanceof bound) {
263
-
264
- var result = target.apply(
265
- this,
266
- args.concat(slice.call(arguments))
267
- );
268
- if (Object(result) === result) {
269
- return result;
270
- }
271
- return this;
272
-
273
- } else {
274
- return target.apply(
275
- that,
276
- args.concat(slice.call(arguments))
277
- );
278
-
279
- }
280
-
281
- };
282
- if(target.prototype) {
283
- Empty.prototype = target.prototype;
284
- bound.prototype = new Empty();
285
- Empty.prototype = null;
286
- }
287
- return bound;
288
- };
289
- }
290
- var call = Function.prototype.call;
291
- var prototypeOfArray = Array.prototype;
292
- var prototypeOfObject = Object.prototype;
293
- var slice = prototypeOfArray.slice;
294
- var _toString = call.bind(prototypeOfObject.toString);
295
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
296
- var defineGetter;
297
- var defineSetter;
298
- var lookupGetter;
299
- var lookupSetter;
300
- var supportsAccessors;
301
- if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
302
- defineGetter = call.bind(prototypeOfObject.__defineGetter__);
303
- defineSetter = call.bind(prototypeOfObject.__defineSetter__);
304
- lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
305
- lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
306
- }
307
- if ([1,2].splice(0).length != 2) {
308
- if(function() { // test IE < 9 to splice bug - see issue #138
309
- function makeArray(l) {
310
- var a = new Array(l+2);
311
- a[0] = a[1] = 0;
312
- return a;
313
- }
314
- var array = [], lengthBefore;
315
-
316
- array.splice.apply(array, makeArray(20));
317
- array.splice.apply(array, makeArray(26));
318
-
319
- lengthBefore = array.length; //46
320
- array.splice(5, 0, "XXX"); // add one element
321
-
322
- lengthBefore + 1 == array.length
323
-
324
- if (lengthBefore + 1 == array.length) {
325
- return true;// has right splice implementation without bugs
326
- }
327
- }()) {//IE 6/7
328
- var array_splice = Array.prototype.splice;
329
- Array.prototype.splice = function(start, deleteCount) {
330
- if (!arguments.length) {
331
- return [];
332
- } else {
333
- return array_splice.apply(this, [
334
- start === void 0 ? 0 : start,
335
- deleteCount === void 0 ? (this.length - start) : deleteCount
336
- ].concat(slice.call(arguments, 2)))
337
- }
338
- };
339
- } else {//IE8
340
- Array.prototype.splice = function(pos, removeCount){
341
- var length = this.length;
342
- if (pos > 0) {
343
- if (pos > length)
344
- pos = length;
345
- } else if (pos == void 0) {
346
- pos = 0;
347
- } else if (pos < 0) {
348
- pos = Math.max(length + pos, 0);
349
- }
350
-
351
- if (!(pos+removeCount < length))
352
- removeCount = length - pos;
353
-
354
- var removed = this.slice(pos, pos+removeCount);
355
- var insert = slice.call(arguments, 2);
356
- var add = insert.length;
357
- if (pos === length) {
358
- if (add) {
359
- this.push.apply(this, insert);
360
- }
361
- } else {
362
- var remove = Math.min(removeCount, length - pos);
363
- var tailOldPos = pos + remove;
364
- var tailNewPos = tailOldPos + add - remove;
365
- var tailCount = length - tailOldPos;
366
- var lengthAfterRemove = length - remove;
367
-
368
- if (tailNewPos < tailOldPos) { // case A
369
- for (var i = 0; i < tailCount; ++i) {
370
- this[tailNewPos+i] = this[tailOldPos+i];
371
- }
372
- } else if (tailNewPos > tailOldPos) { // case B
373
- for (i = tailCount; i--; ) {
374
- this[tailNewPos+i] = this[tailOldPos+i];
375
- }
376
- } // else, add == remove (nothing to do)
377
-
378
- if (add && pos === lengthAfterRemove) {
379
- this.length = lengthAfterRemove; // truncate array
380
- this.push.apply(this, insert);
381
- } else {
382
- this.length = lengthAfterRemove + add; // reserves space
383
- for (i = 0; i < add; ++i) {
384
- this[pos+i] = insert[i];
385
- }
386
- }
387
- }
388
- return removed;
389
- };
390
- }
391
- }
392
- if (!Array.isArray) {
393
- Array.isArray = function isArray(obj) {
394
- return _toString(obj) == "[object Array]";
395
- };
396
- }
397
- var boxedString = Object("a"),
398
- splitString = boxedString[0] != "a" || !(0 in boxedString);
399
-
400
- if (!Array.prototype.forEach) {
401
- Array.prototype.forEach = function forEach(fun /*, thisp*/) {
402
- var object = toObject(this),
403
- self = splitString && _toString(this) == "[object String]" ?
404
- this.split("") :
405
- object,
406
- thisp = arguments[1],
407
- i = -1,
408
- length = self.length >>> 0;
409
- if (_toString(fun) != "[object Function]") {
410
- throw new TypeError(); // TODO message
411
- }
412
-
413
- while (++i < length) {
414
- if (i in self) {
415
- fun.call(thisp, self[i], i, object);
416
- }
417
- }
418
- };
419
- }
420
- if (!Array.prototype.map) {
421
- Array.prototype.map = function map(fun /*, thisp*/) {
422
- var object = toObject(this),
423
- self = splitString && _toString(this) == "[object String]" ?
424
- this.split("") :
425
- object,
426
- length = self.length >>> 0,
427
- result = Array(length),
428
- thisp = arguments[1];
429
- if (_toString(fun) != "[object Function]") {
430
- throw new TypeError(fun + " is not a function");
431
- }
432
-
433
- for (var i = 0; i < length; i++) {
434
- if (i in self)
435
- result[i] = fun.call(thisp, self[i], i, object);
436
- }
437
- return result;
438
- };
439
- }
440
- if (!Array.prototype.filter) {
441
- Array.prototype.filter = function filter(fun /*, thisp */) {
442
- var object = toObject(this),
443
- self = splitString && _toString(this) == "[object String]" ?
444
- this.split("") :
445
- object,
446
- length = self.length >>> 0,
447
- result = [],
448
- value,
449
- thisp = arguments[1];
450
- if (_toString(fun) != "[object Function]") {
451
- throw new TypeError(fun + " is not a function");
452
- }
453
-
454
- for (var i = 0; i < length; i++) {
455
- if (i in self) {
456
- value = self[i];
457
- if (fun.call(thisp, value, i, object)) {
458
- result.push(value);
459
- }
460
- }
461
- }
462
- return result;
463
- };
464
- }
465
- if (!Array.prototype.every) {
466
- Array.prototype.every = function every(fun /*, thisp */) {
467
- var object = toObject(this),
468
- self = splitString && _toString(this) == "[object String]" ?
469
- this.split("") :
470
- object,
471
- length = self.length >>> 0,
472
- thisp = arguments[1];
473
- if (_toString(fun) != "[object Function]") {
474
- throw new TypeError(fun + " is not a function");
475
- }
476
-
477
- for (var i = 0; i < length; i++) {
478
- if (i in self && !fun.call(thisp, self[i], i, object)) {
479
- return false;
480
- }
481
- }
482
- return true;
483
- };
484
- }
485
- if (!Array.prototype.some) {
486
- Array.prototype.some = function some(fun /*, thisp */) {
487
- var object = toObject(this),
488
- self = splitString && _toString(this) == "[object String]" ?
489
- this.split("") :
490
- object,
491
- length = self.length >>> 0,
492
- thisp = arguments[1];
493
- if (_toString(fun) != "[object Function]") {
494
- throw new TypeError(fun + " is not a function");
495
- }
496
-
497
- for (var i = 0; i < length; i++) {
498
- if (i in self && fun.call(thisp, self[i], i, object)) {
499
- return true;
500
- }
501
- }
502
- return false;
503
- };
504
- }
505
- if (!Array.prototype.reduce) {
506
- Array.prototype.reduce = function reduce(fun /*, initial*/) {
507
- var object = toObject(this),
508
- self = splitString && _toString(this) == "[object String]" ?
509
- this.split("") :
510
- object,
511
- length = self.length >>> 0;
512
- if (_toString(fun) != "[object Function]") {
513
- throw new TypeError(fun + " is not a function");
514
- }
515
- if (!length && arguments.length == 1) {
516
- throw new TypeError("reduce of empty array with no initial value");
517
- }
518
-
519
- var i = 0;
520
- var result;
521
- if (arguments.length >= 2) {
522
- result = arguments[1];
523
- } else {
524
- do {
525
- if (i in self) {
526
- result = self[i++];
527
- break;
528
- }
529
- if (++i >= length) {
530
- throw new TypeError("reduce of empty array with no initial value");
531
- }
532
- } while (true);
533
- }
534
-
535
- for (; i < length; i++) {
536
- if (i in self) {
537
- result = fun.call(void 0, result, self[i], i, object);
538
- }
539
- }
540
-
541
- return result;
542
- };
543
- }
544
- if (!Array.prototype.reduceRight) {
545
- Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
546
- var object = toObject(this),
547
- self = splitString && _toString(this) == "[object String]" ?
548
- this.split("") :
549
- object,
550
- length = self.length >>> 0;
551
- if (_toString(fun) != "[object Function]") {
552
- throw new TypeError(fun + " is not a function");
553
- }
554
- if (!length && arguments.length == 1) {
555
- throw new TypeError("reduceRight of empty array with no initial value");
556
- }
557
-
558
- var result, i = length - 1;
559
- if (arguments.length >= 2) {
560
- result = arguments[1];
561
- } else {
562
- do {
563
- if (i in self) {
564
- result = self[i--];
565
- break;
566
- }
567
- if (--i < 0) {
568
- throw new TypeError("reduceRight of empty array with no initial value");
569
- }
570
- } while (true);
571
- }
572
-
573
- do {
574
- if (i in this) {
575
- result = fun.call(void 0, result, self[i], i, object);
576
- }
577
- } while (i--);
578
-
579
- return result;
580
- };
581
- }
582
- if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
583
- Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
584
- var self = splitString && _toString(this) == "[object String]" ?
585
- this.split("") :
586
- toObject(this),
587
- length = self.length >>> 0;
588
-
589
- if (!length) {
590
- return -1;
591
- }
592
-
593
- var i = 0;
594
- if (arguments.length > 1) {
595
- i = toInteger(arguments[1]);
596
- }
597
- i = i >= 0 ? i : Math.max(0, length + i);
598
- for (; i < length; i++) {
599
- if (i in self && self[i] === sought) {
600
- return i;
601
- }
602
- }
603
- return -1;
604
- };
605
- }
606
- if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
607
- Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
608
- var self = splitString && _toString(this) == "[object String]" ?
609
- this.split("") :
610
- toObject(this),
611
- length = self.length >>> 0;
612
-
613
- if (!length) {
614
- return -1;
615
- }
616
- var i = length - 1;
617
- if (arguments.length > 1) {
618
- i = Math.min(i, toInteger(arguments[1]));
619
- }
620
- i = i >= 0 ? i : length - Math.abs(i);
621
- for (; i >= 0; i--) {
622
- if (i in self && sought === self[i]) {
623
- return i;
624
- }
625
- }
626
- return -1;
627
- };
628
- }
629
- if (!Object.getPrototypeOf) {
630
- Object.getPrototypeOf = function getPrototypeOf(object) {
631
- return object.__proto__ || (
632
- object.constructor ?
633
- object.constructor.prototype :
634
- prototypeOfObject
635
- );
636
- };
637
- }
638
- if (!Object.getOwnPropertyDescriptor) {
639
- var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
640
- "non-object: ";
641
- Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
642
- if ((typeof object != "object" && typeof object != "function") || object === null)
643
- throw new TypeError(ERR_NON_OBJECT + object);
644
- if (!owns(object, property))
645
- return;
646
-
647
- var descriptor, getter, setter;
648
- descriptor = { enumerable: true, configurable: true };
649
- if (supportsAccessors) {
650
- var prototype = object.__proto__;
651
- object.__proto__ = prototypeOfObject;
652
-
653
- var getter = lookupGetter(object, property);
654
- var setter = lookupSetter(object, property);
655
- object.__proto__ = prototype;
656
-
657
- if (getter || setter) {
658
- if (getter) descriptor.get = getter;
659
- if (setter) descriptor.set = setter;
660
- return descriptor;
661
- }
662
- }
663
- descriptor.value = object[property];
664
- return descriptor;
665
- };
666
- }
667
- if (!Object.getOwnPropertyNames) {
668
- Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
669
- return Object.keys(object);
670
- };
671
- }
672
- if (!Object.create) {
673
- var createEmpty;
674
- if (Object.prototype.__proto__ === null) {
675
- createEmpty = function () {
676
- return { "__proto__": null };
677
- };
678
- } else {
679
- createEmpty = function () {
680
- var empty = {};
681
- for (var i in empty)
682
- empty[i] = null;
683
- empty.constructor =
684
- empty.hasOwnProperty =
685
- empty.propertyIsEnumerable =
686
- empty.isPrototypeOf =
687
- empty.toLocaleString =
688
- empty.toString =
689
- empty.valueOf =
690
- empty.__proto__ = null;
691
- return empty;
692
- }
693
- }
694
-
695
- Object.create = function create(prototype, properties) {
696
- var object;
697
- if (prototype === null) {
698
- object = createEmpty();
699
- } else {
700
- if (typeof prototype != "object")
701
- throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
702
- var Type = function () {};
703
- Type.prototype = prototype;
704
- object = new Type();
705
- object.__proto__ = prototype;
706
- }
707
- if (properties !== void 0)
708
- Object.defineProperties(object, properties);
709
- return object;
710
- };
711
- }
712
-
713
- function doesDefinePropertyWork(object) {
714
- try {
715
- Object.defineProperty(object, "sentinel", {});
716
- return "sentinel" in object;
717
- } catch (exception) {
718
- }
719
- }
720
- if (Object.defineProperty) {
721
- var definePropertyWorksOnObject = doesDefinePropertyWork({});
722
- var definePropertyWorksOnDom = typeof document == "undefined" ||
723
- doesDefinePropertyWork(document.createElement("div"));
724
- if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
725
- var definePropertyFallback = Object.defineProperty;
726
- }
727
- }
728
-
729
- if (!Object.defineProperty || definePropertyFallback) {
730
- var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
731
- var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
732
- var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
733
- "on this javascript engine";
734
-
735
- Object.defineProperty = function defineProperty(object, property, descriptor) {
736
- if ((typeof object != "object" && typeof object != "function") || object === null)
737
- throw new TypeError(ERR_NON_OBJECT_TARGET + object);
738
- if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
739
- throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
740
- if (definePropertyFallback) {
741
- try {
742
- return definePropertyFallback.call(Object, object, property, descriptor);
743
- } catch (exception) {
744
- }
745
- }
746
- if (owns(descriptor, "value")) {
747
-
748
- if (supportsAccessors && (lookupGetter(object, property) ||
749
- lookupSetter(object, property)))
750
- {
751
- var prototype = object.__proto__;
752
- object.__proto__ = prototypeOfObject;
753
- delete object[property];
754
- object[property] = descriptor.value;
755
- object.__proto__ = prototype;
756
- } else {
757
- object[property] = descriptor.value;
758
- }
759
- } else {
760
- if (!supportsAccessors)
761
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
762
- if (owns(descriptor, "get"))
763
- defineGetter(object, property, descriptor.get);
764
- if (owns(descriptor, "set"))
765
- defineSetter(object, property, descriptor.set);
766
- }
767
-
768
- return object;
769
- };
770
- }
771
- if (!Object.defineProperties) {
772
- Object.defineProperties = function defineProperties(object, properties) {
773
- for (var property in properties) {
774
- if (owns(properties, property))
775
- Object.defineProperty(object, property, properties[property]);
776
- }
777
- return object;
778
- };
779
- }
780
- if (!Object.seal) {
781
- Object.seal = function seal(object) {
782
- return object;
783
- };
784
- }
785
- if (!Object.freeze) {
786
- Object.freeze = function freeze(object) {
787
- return object;
788
- };
789
- }
790
- try {
791
- Object.freeze(function () {});
792
- } catch (exception) {
793
- Object.freeze = (function freeze(freezeObject) {
794
- return function freeze(object) {
795
- if (typeof object == "function") {
796
- return object;
797
- } else {
798
- return freezeObject(object);
799
- }
800
- };
801
- })(Object.freeze);
802
- }
803
- if (!Object.preventExtensions) {
804
- Object.preventExtensions = function preventExtensions(object) {
805
- return object;
806
- };
807
- }
808
- if (!Object.isSealed) {
809
- Object.isSealed = function isSealed(object) {
810
- return false;
811
- };
812
- }
813
- if (!Object.isFrozen) {
814
- Object.isFrozen = function isFrozen(object) {
815
- return false;
816
- };
817
- }
818
- if (!Object.isExtensible) {
819
- Object.isExtensible = function isExtensible(object) {
820
- if (Object(object) === object) {
821
- throw new TypeError(); // TODO message
822
- }
823
- var name = '';
824
- while (owns(object, name)) {
825
- name += '?';
826
- }
827
- object[name] = true;
828
- var returnValue = owns(object, name);
829
- delete object[name];
830
- return returnValue;
831
- };
832
- }
833
- if (!Object.keys) {
834
- var hasDontEnumBug = true,
835
- dontEnums = [
836
- "toString",
837
- "toLocaleString",
838
- "valueOf",
839
- "hasOwnProperty",
840
- "isPrototypeOf",
841
- "propertyIsEnumerable",
842
- "constructor"
843
- ],
844
- dontEnumsLength = dontEnums.length;
845
-
846
- for (var key in {"toString": null}) {
847
- hasDontEnumBug = false;
848
- }
849
-
850
- Object.keys = function keys(object) {
851
-
852
- if (
853
- (typeof object != "object" && typeof object != "function") ||
854
- object === null
855
- ) {
856
- throw new TypeError("Object.keys called on a non-object");
857
- }
858
-
859
- var keys = [];
860
- for (var name in object) {
861
- if (owns(object, name)) {
862
- keys.push(name);
863
- }
864
- }
865
-
866
- if (hasDontEnumBug) {
867
- for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
868
- var dontEnum = dontEnums[i];
869
- if (owns(object, dontEnum)) {
870
- keys.push(dontEnum);
871
- }
872
- }
873
- }
874
- return keys;
875
- };
876
-
877
- }
878
- if (!Date.now) {
879
- Date.now = function now() {
880
- return new Date().getTime();
881
- };
882
- }
883
- var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003" +
884
- "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
885
- "\u2029\uFEFF";
886
- if (!String.prototype.trim) {
887
- ws = "[" + ws + "]";
888
- var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
889
- trimEndRegexp = new RegExp(ws + ws + "*$");
890
- String.prototype.trim = function trim() {
891
- return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
892
- };
893
- }
894
-
895
- function toInteger(n) {
896
- n = +n;
897
- if (n !== n) { // isNaN
898
- n = 0;
899
- } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
900
- n = (n > 0 || -1) * Math.floor(Math.abs(n));
901
- }
902
- return n;
903
- }
904
-
905
- function isPrimitive(input) {
906
- var type = typeof input;
907
- return (
908
- input === null ||
909
- type === "undefined" ||
910
- type === "boolean" ||
911
- type === "number" ||
912
- type === "string"
913
- );
914
- }
915
-
916
- function toPrimitive(input) {
917
- var val, valueOf, toString;
918
- if (isPrimitive(input)) {
919
- return input;
920
- }
921
- valueOf = input.valueOf;
922
- if (typeof valueOf === "function") {
923
- val = valueOf.call(input);
924
- if (isPrimitive(val)) {
925
- return val;
926
- }
927
- }
928
- toString = input.toString;
929
- if (typeof toString === "function") {
930
- val = toString.call(input);
931
- if (isPrimitive(val)) {
932
- return val;
933
- }
934
- }
935
- throw new TypeError();
936
- }
937
- var toObject = function (o) {
938
- if (o == null) { // this matches both null and undefined
939
- throw new TypeError("can't convert "+o+" to object");
940
- }
941
- return Object(o);
942
- };
943
-
944
- });
945
-
946
- define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/regexp","ace/lib/es5-shim"], function(require, exports, module) {
947
- "use strict";
948
-
949
- require("./regexp");
950
- require("./es5-shim");
951
178
  if (typeof Element != "undefined" && !Element.prototype.remove) {
952
179
  Object.defineProperty(Element.prototype, "remove", {
953
180
  enumerable: false,
@@ -1026,8 +253,11 @@ exports.buildDom = function buildDom(arr, parent, refs) {
1026
253
  return txt;
1027
254
  }
1028
255
 
1029
- if (!Array.isArray(arr))
256
+ if (!Array.isArray(arr)) {
257
+ if (arr && arr.appendChild && parent)
258
+ parent.appendChild(arr);
1030
259
  return arr;
260
+ }
1031
261
  if (typeof arr[0] != "string" || !arr[0]) {
1032
262
  var els = [];
1033
263
  for (var i = 0; i < arr.length; i++) {
@@ -1049,7 +279,7 @@ exports.buildDom = function buildDom(arr, parent, refs) {
1049
279
  var val = options[n];
1050
280
  if (n === "class") {
1051
281
  el.className = Array.isArray(val) ? val.join(" ") : val;
1052
- } else if (typeof val == "function" || n == "value") {
282
+ } else if (typeof val == "function" || n == "value" || n[0] == "$") {
1053
283
  el[n] = val;
1054
284
  } else if (n === "ref") {
1055
285
  if (refs) refs[val] = el;
@@ -1294,7 +524,8 @@ var Keys = (function() {
1294
524
 
1295
525
  KEY_MODS: {
1296
526
  "ctrl": 1, "alt": 2, "option" : 2, "shift": 4,
1297
- "super": 8, "meta": 8, "command": 8, "cmd": 8
527
+ "super": 8, "meta": 8, "command": 8, "cmd": 8,
528
+ "control": 1
1298
529
  },
1299
530
 
1300
531
  FUNCTION_KEYS : {
@@ -1404,26 +635,42 @@ var useragent = require("./useragent");
1404
635
  var pressedKeys = null;
1405
636
  var ts = 0;
1406
637
 
1407
- exports.addListener = function(elem, type, callback) {
1408
- if (elem.addEventListener) {
1409
- return elem.addEventListener(type, callback, false);
1410
- }
1411
- if (elem.attachEvent) {
1412
- var wrapper = function() {
1413
- callback.call(elem, window.event);
1414
- };
1415
- callback._wrapper = wrapper;
1416
- elem.attachEvent("on" + type, wrapper);
1417
- }
638
+ var activeListenerOptions;
639
+ function detectListenerOptionsSupport() {
640
+ activeListenerOptions = false;
641
+ try {
642
+ document.createComment("").addEventListener("test", function() {}, {
643
+ get passive() {
644
+ activeListenerOptions = {passive: false};
645
+ }
646
+ });
647
+ } catch(e) {}
648
+ }
649
+
650
+ function getListenerOptions() {
651
+ if (activeListenerOptions == undefined)
652
+ detectListenerOptionsSupport();
653
+ return activeListenerOptions;
654
+ }
655
+
656
+ function EventListener(elem, type, callback) {
657
+ this.elem = elem;
658
+ this.type = type;
659
+ this.callback = callback;
660
+ }
661
+ EventListener.prototype.destroy = function() {
662
+ removeListener(this.elem, this.type, this.callback);
663
+ this.elem = this.type = this.callback = undefined;
1418
664
  };
1419
665
 
1420
- exports.removeListener = function(elem, type, callback) {
1421
- if (elem.removeEventListener) {
1422
- return elem.removeEventListener(type, callback, false);
1423
- }
1424
- if (elem.detachEvent) {
1425
- elem.detachEvent("on" + type, callback._wrapper || callback);
1426
- }
666
+ var addListener = exports.addListener = function(elem, type, callback, destroyer) {
667
+ elem.addEventListener(type, callback, getListenerOptions());
668
+ if (destroyer)
669
+ destroyer.$toDestroy.push(new EventListener(elem, type, callback));
670
+ };
671
+
672
+ var removeListener = exports.removeListener = function(elem, type, callback) {
673
+ elem.removeEventListener(type, callback, getListenerOptions());
1427
674
  };
1428
675
  exports.stopEvent = function(e) {
1429
676
  exports.stopPropagation(e);
@@ -1434,49 +681,41 @@ exports.stopEvent = function(e) {
1434
681
  exports.stopPropagation = function(e) {
1435
682
  if (e.stopPropagation)
1436
683
  e.stopPropagation();
1437
- else
1438
- e.cancelBubble = true;
1439
684
  };
1440
685
 
1441
686
  exports.preventDefault = function(e) {
1442
687
  if (e.preventDefault)
1443
688
  e.preventDefault();
1444
- else
1445
- e.returnValue = false;
1446
689
  };
1447
690
  exports.getButton = function(e) {
1448
691
  if (e.type == "dblclick")
1449
692
  return 0;
1450
693
  if (e.type == "contextmenu" || (useragent.isMac && (e.ctrlKey && !e.altKey && !e.shiftKey)))
1451
694
  return 2;
1452
- if (e.preventDefault) {
1453
- return e.button;
1454
- }
1455
- else {
1456
- return {1:0, 2:2, 4:1}[e.button];
1457
- }
695
+ return e.button;
1458
696
  };
1459
697
 
1460
698
  exports.capture = function(el, eventHandler, releaseCaptureHandler) {
699
+ var ownerDocument = el && el.ownerDocument || document;
1461
700
  function onMouseUp(e) {
1462
701
  eventHandler && eventHandler(e);
1463
702
  releaseCaptureHandler && releaseCaptureHandler(e);
1464
703
 
1465
- exports.removeListener(document, "mousemove", eventHandler, true);
1466
- exports.removeListener(document, "mouseup", onMouseUp, true);
1467
- exports.removeListener(document, "dragstart", onMouseUp, true);
704
+ removeListener(ownerDocument, "mousemove", eventHandler);
705
+ removeListener(ownerDocument, "mouseup", onMouseUp);
706
+ removeListener(ownerDocument, "dragstart", onMouseUp);
1468
707
  }
1469
708
 
1470
- exports.addListener(document, "mousemove", eventHandler, true);
1471
- exports.addListener(document, "mouseup", onMouseUp, true);
1472
- exports.addListener(document, "dragstart", onMouseUp, true);
709
+ addListener(ownerDocument, "mousemove", eventHandler);
710
+ addListener(ownerDocument, "mouseup", onMouseUp);
711
+ addListener(ownerDocument, "dragstart", onMouseUp);
1473
712
 
1474
713
  return onMouseUp;
1475
714
  };
1476
715
 
1477
- exports.addMouseWheelListener = function(el, callback) {
716
+ exports.addMouseWheelListener = function(el, callback, destroyer) {
1478
717
  if ("onmousewheel" in el) {
1479
- exports.addListener(el, "mousewheel", function(e) {
718
+ addListener(el, "mousewheel", function(e) {
1480
719
  var factor = 8;
1481
720
  if (e.wheelDeltaX !== undefined) {
1482
721
  e.wheelX = -e.wheelDeltaX / factor;
@@ -1486,9 +725,9 @@ exports.addMouseWheelListener = function(el, callback) {
1486
725
  e.wheelY = -e.wheelDelta / factor;
1487
726
  }
1488
727
  callback(e);
1489
- });
728
+ }, destroyer);
1490
729
  } else if ("onwheel" in el) {
1491
- exports.addListener(el, "wheel", function(e) {
730
+ addListener(el, "wheel", function(e) {
1492
731
  var factor = 0.35;
1493
732
  switch (e.deltaMode) {
1494
733
  case e.DOM_DELTA_PIXEL:
@@ -1503,9 +742,9 @@ exports.addMouseWheelListener = function(el, callback) {
1503
742
  }
1504
743
 
1505
744
  callback(e);
1506
- });
745
+ }, destroyer);
1507
746
  } else {
1508
- exports.addListener(el, "DOMMouseScroll", function(e) {
747
+ addListener(el, "DOMMouseScroll", function(e) {
1509
748
  if (e.axis && e.axis == e.HORIZONTAL_AXIS) {
1510
749
  e.wheelX = (e.detail || 0) * 5;
1511
750
  e.wheelY = 0;
@@ -1514,11 +753,11 @@ exports.addMouseWheelListener = function(el, callback) {
1514
753
  e.wheelY = (e.detail || 0) * 5;
1515
754
  }
1516
755
  callback(e);
1517
- });
756
+ }, destroyer);
1518
757
  }
1519
758
  };
1520
759
 
1521
- exports.addMultiMouseDownListener = function(elements, timeouts, eventHandler, callbackName) {
760
+ exports.addMultiMouseDownListener = function(elements, timeouts, eventHandler, callbackName, destroyer) {
1522
761
  var clicks = 0;
1523
762
  var startX, startY, timer;
1524
763
  var eventNames = {
@@ -1560,30 +799,16 @@ exports.addMultiMouseDownListener = function(elements, timeouts, eventHandler, c
1560
799
  else if (clicks > 1)
1561
800
  return eventHandler[callbackName](eventNames[clicks], e);
1562
801
  }
1563
- function onDblclick(e) {
1564
- clicks = 2;
1565
- if (timer)
1566
- clearTimeout(timer);
1567
- timer = setTimeout(function() {timer = null;}, timeouts[clicks - 1] || 600);
1568
- eventHandler[callbackName]("mousedown", e);
1569
- eventHandler[callbackName](eventNames[clicks], e);
1570
- }
1571
802
  if (!Array.isArray(elements))
1572
803
  elements = [elements];
1573
804
  elements.forEach(function(el) {
1574
- exports.addListener(el, "mousedown", onMousedown);
1575
- if (useragent.isOldIE)
1576
- exports.addListener(el, "dblclick", onDblclick);
805
+ addListener(el, "mousedown", onMousedown, destroyer);
1577
806
  });
1578
807
  };
1579
808
 
1580
- var getModifierHash = useragent.isMac && useragent.isOpera && !("KeyboardEvent" in window)
1581
- ? function(e) {
1582
- return 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0);
1583
- }
1584
- : function(e) {
1585
- return 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
1586
- };
809
+ var getModifierHash = function(e) {
810
+ return 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
811
+ };
1587
812
 
1588
813
  exports.getModifierString = function(e) {
1589
814
  return keys.KEY_MODS[getModifierHash(e)];
@@ -1642,16 +867,15 @@ function normalizeCommandKeys(callback, e, keyCode) {
1642
867
  }
1643
868
 
1644
869
 
1645
- exports.addCommandKeyListener = function(el, callback) {
1646
- var addListener = exports.addListener;
870
+ exports.addCommandKeyListener = function(el, callback, destroyer) {
1647
871
  if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) {
1648
872
  var lastKeyDownKeyCode = null;
1649
873
  addListener(el, "keydown", function(e) {
1650
874
  lastKeyDownKeyCode = e.keyCode;
1651
- });
875
+ }, destroyer);
1652
876
  addListener(el, "keypress", function(e) {
1653
877
  return normalizeCommandKeys(callback, e, lastKeyDownKeyCode);
1654
- });
878
+ }, destroyer);
1655
879
  } else {
1656
880
  var lastDefaultPrevented = null;
1657
881
 
@@ -1660,18 +884,18 @@ exports.addCommandKeyListener = function(el, callback) {
1660
884
  var result = normalizeCommandKeys(callback, e, e.keyCode);
1661
885
  lastDefaultPrevented = e.defaultPrevented;
1662
886
  return result;
1663
- });
887
+ }, destroyer);
1664
888
 
1665
889
  addListener(el, "keypress", function(e) {
1666
890
  if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
1667
891
  exports.stopEvent(e);
1668
892
  lastDefaultPrevented = null;
1669
893
  }
1670
- });
894
+ }, destroyer);
1671
895
 
1672
896
  addListener(el, "keyup", function(e) {
1673
897
  pressedKeys[e.keyCode] = null;
1674
- });
898
+ }, destroyer);
1675
899
 
1676
900
  if (!pressedKeys) {
1677
901
  resetPressedKeys();
@@ -1692,12 +916,12 @@ if (typeof window == "object" && window.postMessage && !useragent.isOldIE) {
1692
916
  var listener = function(e) {
1693
917
  if (e.data == messageName) {
1694
918
  exports.stopPropagation(e);
1695
- exports.removeListener(win, "message", listener);
919
+ removeListener(win, "message", listener);
1696
920
  callback();
1697
921
  }
1698
922
  };
1699
923
 
1700
- exports.addListener(win, "message", listener);
924
+ addListener(win, "message", listener);
1701
925
  win.postMessage(messageName, "*");
1702
926
  };
1703
927
  }
@@ -2200,6 +1424,7 @@ var KEYS = require("../lib/keys");
2200
1424
  var MODS = KEYS.KEY_MODS;
2201
1425
  var isIOS = useragent.isIOS;
2202
1426
  var valueResetRegex = isIOS ? /\s/ : /\n/;
1427
+ var isMobile = useragent.isMobile;
2203
1428
 
2204
1429
  var TextInput = function(parentNode, host) {
2205
1430
  var text = dom.createElement("textarea");
@@ -2219,7 +1444,7 @@ var TextInput = function(parentNode, host) {
2219
1444
  var sendingText = false;
2220
1445
  var tempStyle = '';
2221
1446
 
2222
- if (!useragent.isMobile)
1447
+ if (!isMobile)
2223
1448
  text.style.fontSize = "1px";
2224
1449
 
2225
1450
  var commandMode = false;
@@ -2235,7 +1460,7 @@ var TextInput = function(parentNode, host) {
2235
1460
  if (ignoreFocusEvents) return;
2236
1461
  host.onBlur(e);
2237
1462
  isFocused = false;
2238
- });
1463
+ }, host);
2239
1464
  event.addListener(text, "focus", function(e) {
2240
1465
  if (ignoreFocusEvents) return;
2241
1466
  isFocused = true;
@@ -2250,7 +1475,7 @@ var TextInput = function(parentNode, host) {
2250
1475
  setTimeout(resetSelection);
2251
1476
  else
2252
1477
  resetSelection();
2253
- });
1478
+ }, host);
2254
1479
  this.$focusScroll = false;
2255
1480
  this.focus = function() {
2256
1481
  if (tempStyle || HAS_FOCUS_ARGS || this.$focusScroll == "browser")
@@ -2296,9 +1521,12 @@ var TextInput = function(parentNode, host) {
2296
1521
  };
2297
1522
 
2298
1523
  host.on("beforeEndOperation", function() {
2299
- if (host.curOp && host.curOp.command.name == "insertstring")
1524
+ var curOp = host.curOp;
1525
+ var commandName = curOp && curOp.command && curOp.command.name;
1526
+ if (commandName == "insertstring")
2300
1527
  return;
2301
- if (inComposition) {
1528
+ var isUserAction = commandName && (curOp.docChanged || curOp.selectionChanged);
1529
+ if (inComposition && isUserAction) {
2302
1530
  lastValue = text.value = "";
2303
1531
  onCompositionEnd();
2304
1532
  }
@@ -2330,33 +1558,49 @@ var TextInput = function(parentNode, host) {
2330
1558
  return;
2331
1559
  inComposition = true;
2332
1560
 
2333
- var selection = host.selection;
2334
- var range = selection.getRange();
2335
- var row = selection.cursor.row;
2336
- var selectionStart = range.start.column;
2337
- var selectionEnd = range.end.column;
2338
- var line = host.session.getLine(row);
2339
-
2340
- if (range.start.row != row) {
2341
- var prevLine = host.session.getLine(row - 1);
2342
- selectionStart = range.start.row < row - 1 ? 0 : selectionStart;
2343
- selectionEnd += prevLine.length + 1;
2344
- line = prevLine + "\n" + line;
2345
- }
2346
- else if (range.end.row != row) {
2347
- var nextLine = host.session.getLine(row + 1);
2348
- selectionEnd = range.end.row > row + 1 ? nextLine.length : selectionEnd;
2349
- selectionEnd += line.length + 1;
2350
- line = line + "\n" + nextLine;
2351
- }
2352
-
2353
- if (line.length > MAX_LINE_LENGTH) {
2354
- if (selectionStart < MAX_LINE_LENGTH && selectionEnd < MAX_LINE_LENGTH) {
2355
- line = line.slice(0, MAX_LINE_LENGTH);
2356
- } else {
2357
- line = "\n";
2358
- selectionStart = 0;
2359
- selectionEnd = 1;
1561
+ var selectionStart = 0;
1562
+ var selectionEnd = 0;
1563
+ var line = "";
1564
+
1565
+ if (host.session) {
1566
+ var selection = host.selection;
1567
+ var range = selection.getRange();
1568
+ var row = selection.cursor.row;
1569
+ selectionStart = range.start.column;
1570
+ selectionEnd = range.end.column;
1571
+ line = host.session.getLine(row);
1572
+
1573
+ if (range.start.row != row) {
1574
+ var prevLine = host.session.getLine(row - 1);
1575
+ selectionStart = range.start.row < row - 1 ? 0 : selectionStart;
1576
+ selectionEnd += prevLine.length + 1;
1577
+ line = prevLine + "\n" + line;
1578
+ }
1579
+ else if (range.end.row != row) {
1580
+ var nextLine = host.session.getLine(row + 1);
1581
+ selectionEnd = range.end.row > row + 1 ? nextLine.length : selectionEnd;
1582
+ selectionEnd += line.length + 1;
1583
+ line = line + "\n" + nextLine;
1584
+ }
1585
+ else if (isMobile && row > 0) {
1586
+ line = "\n" + line;
1587
+ selectionEnd += 1;
1588
+ selectionStart += 1;
1589
+ }
1590
+
1591
+ if (line.length > MAX_LINE_LENGTH) {
1592
+ if (selectionStart < MAX_LINE_LENGTH && selectionEnd < MAX_LINE_LENGTH) {
1593
+ line = line.slice(0, MAX_LINE_LENGTH);
1594
+ } else {
1595
+ line = "\n";
1596
+ if (selectionStart == selectionEnd) {
1597
+ selectionStart = selectionEnd = 0;
1598
+ }
1599
+ else {
1600
+ selectionStart = 0;
1601
+ selectionEnd = 1;
1602
+ }
1603
+ }
2360
1604
  }
2361
1605
  }
2362
1606
 
@@ -2382,6 +1626,7 @@ var TextInput = function(parentNode, host) {
2382
1626
  }
2383
1627
  inComposition = false;
2384
1628
  };
1629
+ this.resetSelection = resetSelection;
2385
1630
 
2386
1631
  if (isFocused)
2387
1632
  host.onFocus();
@@ -2401,6 +1646,8 @@ var TextInput = function(parentNode, host) {
2401
1646
  } else if (isAllSelected(text)) {
2402
1647
  host.selectAll();
2403
1648
  resetSelection();
1649
+ } else if (isMobile && text.selectionStart != lastSelectionStart) {
1650
+ resetSelection();
2404
1651
  }
2405
1652
  };
2406
1653
 
@@ -2451,6 +1698,12 @@ var TextInput = function(parentNode, host) {
2451
1698
  if (!fromInput && !inserted && !restoreStart && !extendLeft && !extendRight && !restoreEnd)
2452
1699
  return "";
2453
1700
  sendingText = true;
1701
+ var shouldReset = false;
1702
+ if (useragent.isAndroid && inserted == ". ") {
1703
+ inserted = " ";
1704
+ shouldReset = true;
1705
+ }
1706
+
2454
1707
  if (inserted && !extendLeft && !extendRight && !restoreStart && !restoreEnd || commandMode) {
2455
1708
  host.onTextInput(inserted);
2456
1709
  } else {
@@ -2467,7 +1720,7 @@ var TextInput = function(parentNode, host) {
2467
1720
  lastSelectionStart = selectionStart;
2468
1721
  lastSelectionEnd = selectionEnd;
2469
1722
  lastRestoreEnd = restoreEnd;
2470
- return inserted;
1723
+ return shouldReset ? "\n" : inserted;
2471
1724
  }
2472
1725
  };
2473
1726
  var onInput = function(e) {
@@ -2479,8 +1732,13 @@ var TextInput = function(parentNode, host) {
2479
1732
  }
2480
1733
  var data = text.value;
2481
1734
  var inserted = sendText(data, true);
2482
- if (data.length > MAX_LINE_LENGTH + 100 || valueResetRegex.test(inserted))
1735
+ if (
1736
+ data.length > MAX_LINE_LENGTH + 100
1737
+ || valueResetRegex.test(inserted)
1738
+ || isMobile && lastSelectionStart < 1 && lastSelectionStart == lastSelectionEnd
1739
+ ) {
2483
1740
  resetSelection();
1741
+ }
2484
1742
  };
2485
1743
 
2486
1744
  var handleClipboardData = function(e, data, forceIEMime) {
@@ -2552,14 +1810,14 @@ var TextInput = function(parentNode, host) {
2552
1810
  }
2553
1811
  };
2554
1812
 
2555
- event.addCommandKeyListener(text, host.onCommandKey.bind(host));
1813
+ event.addCommandKeyListener(text, host.onCommandKey.bind(host), host);
2556
1814
 
2557
- event.addListener(text, "select", onSelect);
2558
- event.addListener(text, "input", onInput);
1815
+ event.addListener(text, "select", onSelect, host);
1816
+ event.addListener(text, "input", onInput, host);
2559
1817
 
2560
- event.addListener(text, "cut", onCut);
2561
- event.addListener(text, "copy", onCopy);
2562
- event.addListener(text, "paste", onPaste);
1818
+ event.addListener(text, "cut", onCut, host);
1819
+ event.addListener(text, "copy", onCopy, host);
1820
+ event.addListener(text, "paste", onPaste, host);
2563
1821
  if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)) {
2564
1822
  event.addListener(parentNode, "keydown", function(e) {
2565
1823
  if ((useragent.isMac && !e.metaKey) || !e.ctrlKey)
@@ -2576,7 +1834,7 @@ var TextInput = function(parentNode, host) {
2576
1834
  onCut(e);
2577
1835
  break;
2578
1836
  }
2579
- });
1837
+ }, host);
2580
1838
  }
2581
1839
  var onCompositionStart = function(e) {
2582
1840
  if (inComposition || !host.onCompositionStart || host.$readOnly)
@@ -2587,7 +1845,11 @@ var TextInput = function(parentNode, host) {
2587
1845
  if (commandMode)
2588
1846
  return;
2589
1847
 
1848
+ if (e.data)
1849
+ inComposition.useTextareaForIME = false;
1850
+
2590
1851
  setTimeout(onCompositionUpdate, 0);
1852
+ host._signal("compositionStart");
2591
1853
  host.on("mousedown", cancelComposition);
2592
1854
 
2593
1855
  var range = host.getSelectionRange();
@@ -2598,8 +1860,7 @@ var TextInput = function(parentNode, host) {
2598
1860
  host.onCompositionStart(inComposition);
2599
1861
 
2600
1862
  if (inComposition.useTextareaForIME) {
2601
- text.value = "";
2602
- lastValue = "";
1863
+ lastValue = text.value = "";
2603
1864
  lastSelectionStart = 0;
2604
1865
  lastSelectionEnd = 0;
2605
1866
  }
@@ -2662,11 +1923,11 @@ var TextInput = function(parentNode, host) {
2662
1923
  syncComposition();
2663
1924
  }
2664
1925
 
2665
- event.addListener(text, "compositionstart", onCompositionStart);
2666
- event.addListener(text, "compositionupdate", onCompositionUpdate);
2667
- event.addListener(text, "keyup", onKeyup);
2668
- event.addListener(text, "keydown", syncComposition);
2669
- event.addListener(text, "compositionend", onCompositionEnd);
1926
+ event.addListener(text, "compositionstart", onCompositionStart, host);
1927
+ event.addListener(text, "compositionupdate", onCompositionUpdate, host);
1928
+ event.addListener(text, "keyup", onKeyup, host);
1929
+ event.addListener(text, "keydown", syncComposition, host);
1930
+ event.addListener(text, "compositionend", onCompositionEnd, host);
2670
1931
 
2671
1932
  this.getElement = function() {
2672
1933
  return text;
@@ -2737,13 +1998,13 @@ var TextInput = function(parentNode, host) {
2737
1998
  host.textInput.onContextMenu(e);
2738
1999
  onContextMenuClose();
2739
2000
  };
2740
- event.addListener(text, "mouseup", onContextMenu);
2001
+ event.addListener(text, "mouseup", onContextMenu, host);
2741
2002
  event.addListener(text, "mousedown", function(e) {
2742
2003
  e.preventDefault();
2743
2004
  onContextMenuClose();
2744
- });
2745
- event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
2746
- event.addListener(text, "contextmenu", onContextMenu);
2005
+ }, host);
2006
+ event.addListener(host.renderer.scroller, "contextmenu", onContextMenu, host);
2007
+ event.addListener(text, "contextmenu", onContextMenu, host);
2747
2008
 
2748
2009
  if (isIOS)
2749
2010
  addIosSelectionHandler(parentNode, host, text);
@@ -2829,10 +2090,13 @@ var TextInput = function(parentNode, host) {
2829
2090
  document.removeEventListener("selectionchange", detectArrowKeys);
2830
2091
  });
2831
2092
  }
2832
-
2833
2093
  };
2834
2094
 
2835
2095
  exports.TextInput = TextInput;
2096
+ exports.$setUserAgentForTests = function(_isMobile, _isIOS) {
2097
+ isMobile = _isMobile;
2098
+ isIOS = _isIOS;
2099
+ };
2836
2100
  });
2837
2101
 
2838
2102
  define("ace/mouse/default_handlers",["require","exports","module","ace/lib/useragent"], function(require, exports, module) {
@@ -3262,7 +2526,7 @@ function GutterHandler(mouseHandler) {
3262
2526
  tooltip.hide();
3263
2527
  tooltipAnnotation = null;
3264
2528
  editor._signal("hideGutterTooltip", tooltip);
3265
- editor.removeEventListener("mousewheel", hideTooltip);
2529
+ editor.off("mousewheel", hideTooltip);
3266
2530
  }
3267
2531
  }
3268
2532
 
@@ -3299,7 +2563,7 @@ function GutterHandler(mouseHandler) {
3299
2563
  tooltipTimeout = null;
3300
2564
  hideTooltip();
3301
2565
  }, 50);
3302
- });
2566
+ }, editor);
3303
2567
 
3304
2568
  editor.on("changeSession", hideTooltip);
3305
2569
  }
@@ -3434,7 +2698,7 @@ function DragdropHandler(mouseHandler) {
3434
2698
  exports.forEach(function(x) {
3435
2699
  mouseHandler[x] = this[x];
3436
2700
  }, this);
3437
- editor.addEventListener("mousedown", this.onMouseDown.bind(mouseHandler));
2701
+ editor.on("mousedown", this.onMouseDown.bind(mouseHandler));
3438
2702
 
3439
2703
 
3440
2704
  var mouseTarget = editor.container;
@@ -3559,12 +2823,12 @@ function DragdropHandler(mouseHandler) {
3559
2823
  return event.preventDefault(e);
3560
2824
  };
3561
2825
 
3562
- event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler));
3563
- event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler));
3564
- event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler));
3565
- event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler));
3566
- event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler));
3567
- event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler));
2826
+ event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler), editor);
2827
+ event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler), editor);
2828
+ event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler), editor);
2829
+ event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler), editor);
2830
+ event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler), editor);
2831
+ event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler), editor);
3568
2832
 
3569
2833
  function scrollCursorIntoView(cursor, prevCursor) {
3570
2834
  var now = Date.now();
@@ -3787,10 +3051,11 @@ exports.DragdropHandler = DragdropHandler;
3787
3051
 
3788
3052
  });
3789
3053
 
3790
- define("ace/mouse/touch_handler",["require","exports","module","ace/mouse/mouse_event","ace/lib/dom"], function(require, exports, module) {
3054
+ define("ace/mouse/touch_handler",["require","exports","module","ace/mouse/mouse_event","ace/lib/event","ace/lib/dom"], function(require, exports, module) {
3791
3055
  "use strict";
3792
3056
 
3793
3057
  var MouseEvent = require("./mouse_event").MouseEvent;
3058
+ var event = require("../lib/event");
3794
3059
  var dom = require("../lib/dom");
3795
3060
 
3796
3061
  exports.addTouchListeners = function(el, editor) {
@@ -3878,9 +3143,17 @@ exports.addTouchListeners = function(el, editor) {
3878
3143
  if (!contextMenu) createContextMenu();
3879
3144
  var cursor = editor.selection.cursor;
3880
3145
  var pagePos = editor.renderer.textToScreenCoordinates(cursor.row, cursor.column);
3146
+ var leftOffset = editor.renderer.textToScreenCoordinates(0, 0).pageX;
3147
+ var scrollLeft = editor.renderer.scrollLeft;
3881
3148
  var rect = editor.container.getBoundingClientRect();
3882
3149
  contextMenu.style.top = pagePos.pageY - rect.top - 3 + "px";
3883
- contextMenu.style.right = "10px";
3150
+ if (pagePos.pageX - rect.left < rect.width - 70) {
3151
+ contextMenu.style.left = "";
3152
+ contextMenu.style.right = "10px";
3153
+ } else {
3154
+ contextMenu.style.right = "";
3155
+ contextMenu.style.left = leftOffset + scrollLeft - rect.left + "px";
3156
+ }
3884
3157
  contextMenu.style.display = "";
3885
3158
  contextMenu.firstChild.style.display = "none";
3886
3159
  editor.on("input", hideContextMenu);
@@ -3917,12 +3190,12 @@ exports.addTouchListeners = function(el, editor) {
3917
3190
  }
3918
3191
  mode = "wait";
3919
3192
  }
3920
- el.addEventListener("contextmenu", function(e) {
3193
+ event.addListener(el, "contextmenu", function(e) {
3921
3194
  if (!pressed) return;
3922
3195
  var textarea = editor.textInput.getElement();
3923
3196
  textarea.focus();
3924
- });
3925
- el.addEventListener("touchstart", function (e) {
3197
+ }, editor);
3198
+ event.addListener(el, "touchstart", function (e) {
3926
3199
  var touches = e.touches;
3927
3200
  if (longTouchTimer || touches.length > 1) {
3928
3201
  clearTimeout(longTouchTimer);
@@ -3963,6 +3236,8 @@ exports.addTouchListeners = function(el, editor) {
3963
3236
  var cursorPos = editor.renderer.$cursorLayer.getPixelPosition(cursor, true);
3964
3237
  var anchorPos = editor.renderer.$cursorLayer.getPixelPosition(anchor, true);
3965
3238
  var rect = editor.renderer.scroller.getBoundingClientRect();
3239
+ var offsetTop = editor.renderer.layerConfig.offset;
3240
+ var offsetLeft = editor.renderer.scrollLeft;
3966
3241
  var weightedDistance = function(x, y) {
3967
3242
  x = x / w;
3968
3243
  y = y / h - 0.75;
@@ -3975,12 +3250,12 @@ exports.addTouchListeners = function(el, editor) {
3975
3250
  }
3976
3251
 
3977
3252
  var diff1 = weightedDistance(
3978
- e.clientX - rect.left - cursorPos.left,
3979
- e.clientY - rect.top - cursorPos.top
3253
+ e.clientX - rect.left - cursorPos.left + offsetLeft,
3254
+ e.clientY - rect.top - cursorPos.top + offsetTop
3980
3255
  );
3981
3256
  var diff2 = weightedDistance(
3982
- e.clientX - rect.left - anchorPos.left,
3983
- e.clientY - rect.top - anchorPos.top
3257
+ e.clientX - rect.left - anchorPos.left + offsetLeft,
3258
+ e.clientY - rect.top - anchorPos.top + offsetTop
3984
3259
  );
3985
3260
  if (diff1 < 3.5 && diff2 < 3.5)
3986
3261
  mode = diff1 > diff2 ? "cursor" : "anchor";
@@ -3994,9 +3269,9 @@ exports.addTouchListeners = function(el, editor) {
3994
3269
  longTouchTimer = setTimeout(handleLongTap, 450);
3995
3270
  }
3996
3271
  touchStartT = t;
3997
- });
3272
+ }, editor);
3998
3273
 
3999
- el.addEventListener("touchend", function (e) {
3274
+ event.addListener(el, "touchend", function (e) {
4000
3275
  pressed = editor.$mouseHandler.isMousePressed = false;
4001
3276
  if (animationTimer) clearInterval(animationTimer);
4002
3277
  if (mode == "zoom") {
@@ -4008,15 +3283,14 @@ exports.addTouchListeners = function(el, editor) {
4008
3283
  showContextMenu();
4009
3284
  } else if (mode == "scroll") {
4010
3285
  animate();
4011
- e.preventDefault();
4012
3286
  hideContextMenu();
4013
3287
  } else {
4014
3288
  showContextMenu();
4015
3289
  }
4016
3290
  clearTimeout(longTouchTimer);
4017
3291
  longTouchTimer = null;
4018
- });
4019
- el.addEventListener("touchmove", function (e) {
3292
+ }, editor);
3293
+ event.addListener(el, "touchmove", function (e) {
4020
3294
  if (longTouchTimer) {
4021
3295
  clearTimeout(longTouchTimer);
4022
3296
  longTouchTimer = null;
@@ -4071,7 +3345,7 @@ exports.addTouchListeners = function(el, editor) {
4071
3345
  editor.renderer.scrollCursorIntoView(pos);
4072
3346
  e.preventDefault();
4073
3347
  }
4074
- });
3348
+ }, editor);
4075
3349
 
4076
3350
  function animate() {
4077
3351
  animationSteps += 60;
@@ -4182,8 +3456,8 @@ EventEmitter._signal = function(eventName, e) {
4182
3456
 
4183
3457
  EventEmitter.once = function(eventName, callback) {
4184
3458
  var _self = this;
4185
- this.addEventListener(eventName, function newCallback() {
4186
- _self.removeEventListener(eventName, newCallback);
3459
+ this.on(eventName, function newCallback() {
3460
+ _self.off(eventName, newCallback);
4187
3461
  callback.apply(null, arguments);
4188
3462
  });
4189
3463
  if (!callback) {
@@ -4255,7 +3529,9 @@ EventEmitter.removeEventListener = function(eventName, callback) {
4255
3529
  };
4256
3530
 
4257
3531
  EventEmitter.removeAllListeners = function(eventName) {
4258
- if (this._eventRegistry) this._eventRegistry[eventName] = [];
3532
+ if (!eventName) this._eventRegistry = this._defaultHandlers = undefined;
3533
+ if (this._eventRegistry) this._eventRegistry[eventName] = undefined;
3534
+ if (this._defaultHandlers) this._defaultHandlers[eventName] = undefined;
4259
3535
  };
4260
3536
 
4261
3537
  exports.EventEmitter = EventEmitter;
@@ -4578,7 +3854,7 @@ function deHyphenate(str) {
4578
3854
  return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
4579
3855
  }
4580
3856
 
4581
- exports.version = "1.4.7";
3857
+ exports.version = "1.4.12";
4582
3858
 
4583
3859
  });
4584
3860
 
@@ -4611,28 +3887,28 @@ var MouseHandler = function(editor) {
4611
3887
  };
4612
3888
 
4613
3889
  var mouseTarget = editor.renderer.getMouseEventTarget();
4614
- event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
4615
- event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
3890
+ event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"), editor);
3891
+ event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"), editor);
4616
3892
  event.addMultiMouseDownListener([
4617
3893
  mouseTarget,
4618
3894
  editor.renderer.scrollBarV && editor.renderer.scrollBarV.inner,
4619
3895
  editor.renderer.scrollBarH && editor.renderer.scrollBarH.inner,
4620
3896
  editor.textInput && editor.textInput.getElement()
4621
- ].filter(Boolean), [400, 300, 250], this, "onMouseEvent");
4622
- event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
3897
+ ].filter(Boolean), [400, 300, 250], this, "onMouseEvent", editor);
3898
+ event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"), editor);
4623
3899
  addTouchListeners(editor.container, editor);
4624
3900
 
4625
3901
  var gutterEl = editor.renderer.$gutter;
4626
- event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"));
4627
- event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"));
4628
- event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"));
4629
- event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove"));
3902
+ event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"), editor);
3903
+ event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"), editor);
3904
+ event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"), editor);
3905
+ event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove"), editor);
4630
3906
 
4631
- event.addListener(mouseTarget, "mousedown", focusEditor);
4632
- event.addListener(gutterEl, "mousedown", focusEditor);
3907
+ event.addListener(mouseTarget, "mousedown", focusEditor, editor);
3908
+ event.addListener(gutterEl, "mousedown", focusEditor, editor);
4633
3909
  if (useragent.isIE && editor.renderer.scrollBarV) {
4634
- event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor);
4635
- event.addListener(editor.renderer.scrollBarH.element, "mousedown", focusEditor);
3910
+ event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor, editor);
3911
+ event.addListener(editor.renderer.scrollBarH.element, "mousedown", focusEditor, editor);
4636
3912
  }
4637
3913
 
4638
3914
  editor.on("mousemove", function(e){
@@ -4648,7 +3924,7 @@ var MouseHandler = function(editor) {
4648
3924
  } else {
4649
3925
  renderer.setCursorStyle("");
4650
3926
  }
4651
- });
3927
+ }, editor);
4652
3928
  };
4653
3929
 
4654
3930
  (function() {
@@ -4750,6 +4026,9 @@ var MouseHandler = function(editor) {
4750
4026
  setTimeout(stop, 10);
4751
4027
  this.editor.on("nativecontextmenu", stop);
4752
4028
  };
4029
+ this.destroy = function() {
4030
+ if (this.releaseMouse) this.releaseMouse();
4031
+ };
4753
4032
  }).call(MouseHandler.prototype);
4754
4033
 
4755
4034
  config.defineOptions(MouseHandler.prototype, "mouseHandler", {
@@ -5678,6 +4957,8 @@ var Selection = function(session) {
5678
4957
  };
5679
4958
 
5680
4959
  this.$setSelection = function(anchorRow, anchorColumn, cursorRow, cursorColumn) {
4960
+ if (this.$silent)
4961
+ return;
5681
4962
  var wasEmpty = this.$isEmpty;
5682
4963
  var wasMultiselect = this.inMultiSelectMode;
5683
4964
  this.$silent = true;
@@ -6071,14 +5352,19 @@ var Selection = function(session) {
6071
5352
  else
6072
5353
  this.$desiredColumn = screenPos.column;
6073
5354
  }
6074
-
5355
+
5356
+ if (rows != 0 && this.session.lineWidgets && this.session.lineWidgets[this.lead.row]) {
5357
+ var widget = this.session.lineWidgets[this.lead.row];
5358
+ if (rows < 0)
5359
+ rows -= widget.rowsAbove || 0;
5360
+ else if (rows > 0)
5361
+ rows += widget.rowCount - (widget.rowsAbove || 0);
5362
+ }
5363
+
6075
5364
  var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column, offsetX);
6076
5365
 
6077
5366
  if (rows !== 0 && chars === 0 && docPos.row === this.lead.row && docPos.column === this.lead.column) {
6078
- if (this.session.lineWidgets && this.session.lineWidgets[docPos.row]) {
6079
- if (docPos.row > 0 || rows > 0)
6080
- docPos.row++;
6081
- }
5367
+
6082
5368
  }
6083
5369
  this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
6084
5370
  };
@@ -6688,18 +5974,18 @@ var TextHighlightRules = function() {
6688
5974
 
6689
5975
  this.createKeywordMapper = function(map, defaultToken, ignoreCase, splitChar) {
6690
5976
  var keywords = Object.create(null);
5977
+ this.$keywordList = [];
6691
5978
  Object.keys(map).forEach(function(className) {
6692
5979
  var a = map[className];
6693
- if (ignoreCase)
6694
- a = a.toLowerCase();
6695
5980
  var list = a.split(splitChar || "|");
6696
- for (var i = list.length; i--; )
6697
- keywords[list[i]] = className;
6698
- });
6699
- if (Object.getPrototypeOf(keywords)) {
6700
- keywords.__proto__ = null;
6701
- }
6702
- this.$keywordList = Object.keys(keywords);
5981
+ for (var i = list.length; i--; ) {
5982
+ var word = list[i];
5983
+ this.$keywordList.push(word);
5984
+ if (ignoreCase)
5985
+ word = word.toLowerCase();
5986
+ keywords[word] = className;
5987
+ }
5988
+ }, this);
6703
5989
  map = null;
6704
5990
  return ignoreCase
6705
5991
  ? function(value) {return keywords[value.toLowerCase()] || defaultToken; }
@@ -7762,7 +7048,7 @@ var Anchor = exports.Anchor = function(doc, row, column) {
7762
7048
  });
7763
7049
  };
7764
7050
  this.detach = function() {
7765
- this.document.removeEventListener("change", this.$onChange);
7051
+ this.document.off("change", this.$onChange);
7766
7052
  };
7767
7053
  this.attach = function(doc) {
7768
7054
  this.document = doc || this.document;
@@ -8094,6 +7380,16 @@ var Document = function(textOrLines) {
8094
7380
  }
8095
7381
  };
8096
7382
 
7383
+ this.$safeApplyDelta = function(delta) {
7384
+ var docLength = this.$lines.length;
7385
+ if (
7386
+ delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength
7387
+ || delta.action == "insert" && delta.start.row <= docLength
7388
+ ) {
7389
+ this.applyDelta(delta);
7390
+ }
7391
+ };
7392
+
8097
7393
  this.$splitAndapplyLargeDelta = function(delta, MAX) {
8098
7394
  var lines = delta.lines;
8099
7395
  var l = lines.length - MAX + 1;
@@ -8116,7 +7412,7 @@ var Document = function(textOrLines) {
8116
7412
  this.applyDelta(delta, true);
8117
7413
  };
8118
7414
  this.revertDelta = function(delta) {
8119
- this.applyDelta({
7415
+ this.$safeApplyDelta({
8120
7416
  start: this.clonePos(delta.start),
8121
7417
  end: this.clonePos(delta.end),
8122
7418
  action: (delta.action == "insert" ? "remove" : "insert"),
@@ -9153,9 +8449,11 @@ function Folding() {
9153
8449
  var folds = this.getFoldsInRange(fold.range);
9154
8450
  if (folds.length > 0) {
9155
8451
  this.removeFolds(folds);
9156
- folds.forEach(function(subFold) {
9157
- fold.addSubFold(subFold);
9158
- });
8452
+ if (!fold.collapseChildren) {
8453
+ folds.forEach(function(subFold) {
8454
+ fold.addSubFold(subFold);
8455
+ });
8456
+ }
9159
8457
  }
9160
8458
 
9161
8459
  for (var i = 0; i < foldData.length; i++) {
@@ -9274,7 +8572,7 @@ function Folding() {
9274
8572
  var range, folds;
9275
8573
  if (location == null) {
9276
8574
  range = new Range(0, 0, this.getLength(), 0);
9277
- expandInner = true;
8575
+ if (expandInner == null) expandInner = true;
9278
8576
  } else if (typeof location == "number")
9279
8577
  range = new Range(location, 0, location, this.getLine(location).length);
9280
8578
  else if ("row" in location)
@@ -9283,14 +8581,10 @@ function Folding() {
9283
8581
  range = location;
9284
8582
 
9285
8583
  folds = this.getFoldsInRangeList(range);
9286
- if (expandInner) {
8584
+ if (expandInner != false) {
9287
8585
  this.removeFolds(folds);
9288
8586
  } else {
9289
- var subFolds = folds;
9290
- while (subFolds.length) {
9291
- this.expandFolds(subFolds);
9292
- subFolds = this.getFoldsInRangeList(range);
9293
- }
8587
+ this.expandFolds(folds);
9294
8588
  }
9295
8589
  if (folds.length)
9296
8590
  return folds;
@@ -9427,7 +8721,7 @@ function Folding() {
9427
8721
  this.getCommentFoldRange = function(row, column, dir) {
9428
8722
  var iterator = new TokenIterator(this, row, column);
9429
8723
  var token = iterator.getCurrentToken();
9430
- var type = token.type;
8724
+ var type = token && token.type;
9431
8725
  if (token && /^comment|string/.test(type)) {
9432
8726
  type = type.match(/comment|string/)[0];
9433
8727
  if (type == "comment")
@@ -9468,7 +8762,7 @@ function Folding() {
9468
8762
  }
9469
8763
  };
9470
8764
 
9471
- this.foldAll = function(startRow, endRow, depth) {
8765
+ this.foldAll = function(startRow, endRow, depth, test) {
9472
8766
  if (depth == undefined)
9473
8767
  depth = 100000; // JSON.stringify doesn't hanle Infinity
9474
8768
  var foldWidgets = this.foldWidgets;
@@ -9481,6 +8775,8 @@ function Folding() {
9481
8775
  foldWidgets[row] = this.getFoldWidget(row);
9482
8776
  if (foldWidgets[row] != "start")
9483
8777
  continue;
8778
+
8779
+ if (test && !test(row)) continue;
9484
8780
 
9485
8781
  var range = this.getFoldWidgetRange(row);
9486
8782
  if (range && range.isMultiLine()
@@ -9488,14 +8784,32 @@ function Folding() {
9488
8784
  && range.start.row >= startRow
9489
8785
  ) {
9490
8786
  row = range.end.row;
9491
- try {
9492
- var fold = this.addFold("...", range);
9493
- if (fold)
9494
- fold.collapseChildren = depth;
9495
- } catch(e) {}
8787
+ range.collapseChildren = depth;
8788
+ this.addFold("...", range);
9496
8789
  }
9497
8790
  }
9498
8791
  };
8792
+
8793
+ this.foldToLevel = function(level) {
8794
+ this.foldAll();
8795
+ while (level-- > 0)
8796
+ this.unfold(null, false);
8797
+ };
8798
+
8799
+ this.foldAllComments = function() {
8800
+ var session = this;
8801
+ this.foldAll(null, null, null, function(row) {
8802
+ var tokens = session.getTokens(row);
8803
+ for (var i = 0; i < tokens.length; i++) {
8804
+ var token = tokens[i];
8805
+ if (token.type == "text" && /^\s+$/.test(token.value))
8806
+ continue;
8807
+ if (/comment/.test(token.type))
8808
+ return true;
8809
+ return false;
8810
+ }
8811
+ });
8812
+ };
9499
8813
  this.$foldStyles = {
9500
8814
  "manual": 1,
9501
8815
  "markbegin": 1,
@@ -9711,7 +9025,7 @@ function BracketMatch() {
9711
9025
  var line = this.getLine(pos.row);
9712
9026
  var before = true, range;
9713
9027
 
9714
- var chr = line.charAt(pos.column-1);
9028
+ var chr = line.charAt(pos.column - 1);
9715
9029
  var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
9716
9030
  if (!match) {
9717
9031
  chr = line.charAt(pos.column);
@@ -9746,6 +9060,29 @@ function BracketMatch() {
9746
9060
 
9747
9061
  return range;
9748
9062
  };
9063
+ this.getMatchingBracketRanges = function(pos) {
9064
+ var line = this.getLine(pos.row);
9065
+
9066
+ var chr = line.charAt(pos.column - 1);
9067
+ var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
9068
+ if (!match) {
9069
+ chr = line.charAt(pos.column);
9070
+ pos = {row: pos.row, column: pos.column + 1};
9071
+ match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
9072
+ }
9073
+
9074
+ if (!match)
9075
+ return null;
9076
+
9077
+ var startRange = new Range(pos.row, pos.column - 1, pos.row, pos.column);
9078
+ var bracketPos = match[1] ? this.$findClosingBracket(match[1], pos)
9079
+ : this.$findOpeningBracket(match[2], pos);
9080
+ if (!bracketPos)
9081
+ return [startRange];
9082
+ var endRange = new Range(bracketPos.row, bracketPos.column, bracketPos.row, bracketPos.column + 1);
9083
+
9084
+ return [startRange, endRange];
9085
+ };
9749
9086
 
9750
9087
  this.$brackets = {
9751
9088
  ")": "(",
@@ -10344,7 +9681,8 @@ EditSession.$uid = 0;
10344
9681
  this.$modeId = mode.$id;
10345
9682
  if (this.$mode === mode)
10346
9683
  return;
10347
-
9684
+
9685
+ var oldMode = this.$mode;
10348
9686
  this.$mode = mode;
10349
9687
 
10350
9688
  this.$stopWorker();
@@ -10354,15 +9692,15 @@ EditSession.$uid = 0;
10354
9692
 
10355
9693
  var tokenizer = mode.getTokenizer();
10356
9694
 
10357
- if(tokenizer.addEventListener !== undefined) {
9695
+ if(tokenizer.on !== undefined) {
10358
9696
  var onReloadTokenizer = this.onReloadTokenizer.bind(this);
10359
- tokenizer.addEventListener("update", onReloadTokenizer);
9697
+ tokenizer.on("update", onReloadTokenizer);
10360
9698
  }
10361
9699
 
10362
9700
  if (!this.bgTokenizer) {
10363
9701
  this.bgTokenizer = new BackgroundTokenizer(tokenizer);
10364
9702
  var _self = this;
10365
- this.bgTokenizer.addEventListener("update", function(e) {
9703
+ this.bgTokenizer.on("update", function(e) {
10366
9704
  _self._signal("tokenizerUpdate", e);
10367
9705
  });
10368
9706
  } else {
@@ -10381,7 +9719,7 @@ EditSession.$uid = 0;
10381
9719
  this.$options.wrapMethod.set.call(this, this.$wrapMethod);
10382
9720
  this.$setFolding(mode.foldingRules);
10383
9721
  this.bgTokenizer.start(0);
10384
- this._emit("changeMode");
9722
+ this._emit("changeMode", {oldMode: oldMode, mode: mode});
10385
9723
  }
10386
9724
  };
10387
9725
 
@@ -10527,7 +9865,7 @@ EditSession.$uid = 0;
10527
9865
  for (var i = 0; i < deltas.length; i++) {
10528
9866
  var delta = deltas[i];
10529
9867
  if (delta.action == "insert" || delta.action == "remove") {
10530
- this.doc.applyDelta(delta);
9868
+ this.doc.$safeApplyDelta(delta);
10531
9869
  }
10532
9870
  }
10533
9871
 
@@ -10549,7 +9887,6 @@ EditSession.$uid = 0;
10549
9887
  }
10550
9888
 
10551
9889
  var range, point;
10552
- var lastDeltaIsInsert;
10553
9890
 
10554
9891
  for (var i = 0; i < deltas.length; i++) {
10555
9892
  var delta = deltas[i];
@@ -10557,10 +9894,8 @@ EditSession.$uid = 0;
10557
9894
  if (!range) {
10558
9895
  if (isInsert(delta)) {
10559
9896
  range = Range.fromPoints(delta.start, delta.end);
10560
- lastDeltaIsInsert = true;
10561
9897
  } else {
10562
9898
  range = Range.fromPoints(delta.start, delta.start);
10563
- lastDeltaIsInsert = false;
10564
9899
  }
10565
9900
  continue;
10566
9901
  }
@@ -10574,13 +9909,11 @@ EditSession.$uid = 0;
10574
9909
  if (range.compare(point.row, point.column) == 1) {
10575
9910
  range.setEnd(point);
10576
9911
  }
10577
- lastDeltaIsInsert = true;
10578
9912
  } else {
10579
9913
  point = delta.start;
10580
9914
  if (range.compare(point.row, point.column) == -1) {
10581
9915
  range = Range.fromPoints(delta.start, delta.start);
10582
9916
  }
10583
- lastDeltaIsInsert = false;
10584
9917
  }
10585
9918
  }
10586
9919
  return range;
@@ -11148,15 +10481,14 @@ EditSession.$uid = 0;
11148
10481
 
11149
10482
  this.lineWidgets = null;
11150
10483
  this.getRowLength = function(row) {
10484
+ var h = 1;
11151
10485
  if (this.lineWidgets)
11152
- var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
11153
- else
11154
- h = 0;
11155
- if (!this.$useWrapMode || !this.$wrapData[row]) {
11156
- return 1 + h;
11157
- } else {
11158
- return this.$wrapData[row].length + 1 + h;
11159
- }
10486
+ h += this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
10487
+
10488
+ if (!this.$useWrapMode || !this.$wrapData[row])
10489
+ return h;
10490
+ else
10491
+ return this.$wrapData[row].length + h;
11160
10492
  };
11161
10493
  this.getRowLineCount = function(row) {
11162
10494
  if (!this.$useWrapMode || !this.$wrapData[row]) {
@@ -11368,6 +10700,9 @@ EditSession.$uid = 0;
11368
10700
  wrapIndent = screenRowOffset > 0 ? wrapRow.indent : 0;
11369
10701
  }
11370
10702
  }
10703
+
10704
+ if (this.lineWidgets && this.lineWidgets[row] && this.lineWidgets[row].rowsAbove)
10705
+ screenRow += this.lineWidgets[row].rowsAbove;
11371
10706
 
11372
10707
  return {
11373
10708
  row: screenRow,
@@ -11444,6 +10779,8 @@ EditSession.$uid = 0;
11444
10779
  this.bgTokenizer = null;
11445
10780
  }
11446
10781
  this.$stopWorker();
10782
+ this.removeAllListeners();
10783
+ this.selection.detach();
11447
10784
  };
11448
10785
 
11449
10786
  this.isFullWidth = isFullWidth;
@@ -12185,7 +11522,7 @@ oop.inherits(CommandManager, MultiHashHandler);
12185
11522
  editor && editor._emit("changeStatus");
12186
11523
  if (this.recording) {
12187
11524
  this.macro.pop();
12188
- this.removeEventListener("exec", this.$addCommandToMacro);
11525
+ this.off("exec", this.$addCommandToMacro);
12189
11526
 
12190
11527
  if (!this.macro.length)
12191
11528
  this.macro = this.oldMacro;
@@ -12337,6 +11674,13 @@ exports.commands = [{
12337
11674
  exec: function(editor) { editor.session.foldAll(); },
12338
11675
  scrollIntoView: "center",
12339
11676
  readOnly: true
11677
+ }, {
11678
+ name: "foldAllComments",
11679
+ description: "Fold all comments",
11680
+ bindKey: bindKey(null, "Ctrl-Command-Option-0"),
11681
+ exec: function(editor) { editor.session.foldAllComments(); },
11682
+ scrollIntoView: "center",
11683
+ readOnly: true
12340
11684
  }, {
12341
11685
  name: "foldOther",
12342
11686
  description: "Fold other",
@@ -12945,6 +12289,13 @@ exports.commands = [{
12945
12289
  exec: function(editor) { editor.toLowerCase(); },
12946
12290
  multiSelectAction: "forEach",
12947
12291
  scrollIntoView: "cursor"
12292
+ }, {
12293
+ name: "autoindent",
12294
+ description: "Auto Indent",
12295
+ bindKey: bindKey(null, null),
12296
+ exec: function(editor) { editor.autoIndent(); },
12297
+ multiSelectAction: "forEachLine",
12298
+ scrollIntoView: "animate"
12948
12299
  }, {
12949
12300
  name: "expandtoline",
12950
12301
  description: "Expand to line",
@@ -13035,6 +12386,26 @@ exports.commands = [{
13035
12386
  },
13036
12387
  readOnly: true,
13037
12388
  scrollIntoView: "none"
12389
+ }, {
12390
+ name: "addLineAfter",
12391
+ exec: function(editor) {
12392
+ editor.selection.clearSelection();
12393
+ editor.navigateLineEnd();
12394
+ editor.insert("\n");
12395
+ },
12396
+ multiSelectAction: "forEach",
12397
+ scrollIntoView: "cursor"
12398
+ }, {
12399
+ name: "addLineBefore",
12400
+ exec: function(editor) {
12401
+ editor.selection.clearSelection();
12402
+ var cursor = editor.getCursorPosition();
12403
+ editor.selection.moveTo(cursor.row - 1, Number.MAX_VALUE);
12404
+ editor.insert("\n");
12405
+ if (cursor.row === 0) editor.navigateUp();
12406
+ },
12407
+ multiSelectAction: "forEach",
12408
+ scrollIntoView: "cursor"
13038
12409
  }, {
13039
12410
  name: "openCommandPallete",
13040
12411
  description: "Open command pallete",
@@ -13053,6 +12424,17 @@ exports.commands = [{
13053
12424
  readOnly: true
13054
12425
  }];
13055
12426
 
12427
+ for (var i = 1; i < 9; i++) {
12428
+ exports.commands.push({
12429
+ name: "foldToLevel" + i,
12430
+ description: "Fold To Level " + i,
12431
+ level: i,
12432
+ exec: function(editor) { editor.session.foldToLevel(this.level); },
12433
+ scrollIntoView: "center",
12434
+ readOnly: true
12435
+ });
12436
+ }
12437
+
13056
12438
  });
13057
12439
 
13058
12440
  define("ace/editor",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/keyboard/textinput","ace/mouse/mouse_handler","ace/mouse/fold_handler","ace/keyboard/keybinding","ace/edit_session","ace/search","ace/range","ace/lib/event_emitter","ace/commands/command_manager","ace/commands/default_commands","ace/config","ace/token_iterator","ace/clipboard"], function(require, exports, module) {
@@ -13079,6 +12461,7 @@ var TokenIterator = require("./token_iterator").TokenIterator;
13079
12461
 
13080
12462
  var clipboard = require("./clipboard");
13081
12463
  var Editor = function(renderer, session, options) {
12464
+ this.$toDestroy = [];
13082
12465
  var container = renderer.getContainerElement();
13083
12466
  this.container = container;
13084
12467
  this.renderer = renderer;
@@ -13171,8 +12554,8 @@ Editor.$uid = 0;
13171
12554
  };
13172
12555
 
13173
12556
  this.endOperation = function(e) {
13174
- if (this.curOp) {
13175
- if (e && e.returnValue === false)
12557
+ if (this.curOp && this.session) {
12558
+ if (e && e.returnValue === false || !this.session)
13176
12559
  return (this.curOp = null);
13177
12560
  if (e == true && this.curOp.command && this.curOp.command.name == "mouse")
13178
12561
  return;
@@ -13420,28 +12803,46 @@ Editor.$uid = 0;
13420
12803
  };
13421
12804
 
13422
12805
  this.$highlightBrackets = function() {
13423
- if (this.session.$bracketHighlight) {
13424
- this.session.removeMarker(this.session.$bracketHighlight);
13425
- this.session.$bracketHighlight = null;
13426
- }
13427
-
13428
12806
  if (this.$highlightPending) {
13429
12807
  return;
13430
12808
  }
13431
12809
  var self = this;
13432
12810
  this.$highlightPending = true;
13433
- setTimeout(function() {
12811
+ setTimeout(function () {
13434
12812
  self.$highlightPending = false;
13435
12813
  var session = self.session;
13436
12814
  if (!session || !session.bgTokenizer) return;
13437
- var pos = session.findMatchingBracket(self.getCursorPosition());
13438
- if (pos) {
13439
- var range = new Range(pos.row, pos.column, pos.row, pos.column + 1);
13440
- } else if (session.$mode.getMatching) {
13441
- var range = session.$mode.getMatching(self.session);
13442
- }
13443
- if (range)
13444
- session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text");
12815
+ if (session.$bracketHighlight) {
12816
+ session.$bracketHighlight.markerIds.forEach(function(id) {
12817
+ session.removeMarker(id);
12818
+ });
12819
+ session.$bracketHighlight = null;
12820
+ }
12821
+ var ranges = session.getMatchingBracketRanges(self.getCursorPosition());
12822
+ if (!ranges && session.$mode.getMatching)
12823
+ ranges = session.$mode.getMatching(self.session);
12824
+ if (!ranges)
12825
+ return;
12826
+
12827
+ var markerType = "ace_bracket";
12828
+ if (!Array.isArray(ranges)) {
12829
+ ranges = [ranges];
12830
+ } else if (ranges.length == 1) {
12831
+ markerType = "ace_error_bracket";
12832
+ }
12833
+ if (ranges.length == 2) {
12834
+ if (Range.comparePoints(ranges[0].end, ranges[1].start) == 0)
12835
+ ranges = [Range.fromPoints(ranges[0].start, ranges[1].end)];
12836
+ else if (Range.comparePoints(ranges[0].start, ranges[1].end) == 0)
12837
+ ranges = [Range.fromPoints(ranges[1].start, ranges[0].end)];
12838
+ }
12839
+
12840
+ session.$bracketHighlight = {
12841
+ ranges: ranges,
12842
+ markerIds: ranges.map(function(range) {
12843
+ return session.addMarker(range, markerType, "text");
12844
+ })
12845
+ };
13445
12846
  }, 50);
13446
12847
  };
13447
12848
  this.$highlightTags = function() {
@@ -13465,25 +12866,33 @@ Editor.$uid = 0;
13465
12866
  return;
13466
12867
  }
13467
12868
 
13468
- if (token.type.indexOf("tag-open") != -1) {
12869
+ if (token.type.indexOf("tag-open") !== -1) {
13469
12870
  token = iterator.stepForward();
13470
12871
  if (!token)
13471
12872
  return;
13472
12873
  }
13473
12874
 
13474
12875
  var tag = token.value;
12876
+ var currentTag = token.value;
13475
12877
  var depth = 0;
13476
12878
  var prevToken = iterator.stepBackward();
13477
12879
 
13478
- if (prevToken.value == '<'){
12880
+ if (prevToken.value === '<'){
13479
12881
  do {
13480
12882
  prevToken = token;
13481
12883
  token = iterator.stepForward();
13482
-
13483
- if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
13484
- if (prevToken.value === '<'){
13485
- depth++;
13486
- } else if (prevToken.value === '</'){
12884
+
12885
+ if (token) {
12886
+ if (token.type.indexOf('tag-name') !== -1) {
12887
+ currentTag = token.value;
12888
+ if (tag === currentTag) {
12889
+ if (prevToken.value === '<') {
12890
+ depth++;
12891
+ } else if (prevToken.value === '</') {
12892
+ depth--;
12893
+ }
12894
+ }
12895
+ } else if (tag === currentTag && token.value === '/>') { // self closing tag
13487
12896
  depth--;
13488
12897
  }
13489
12898
  }
@@ -13493,12 +12902,32 @@ Editor.$uid = 0;
13493
12902
  do {
13494
12903
  token = prevToken;
13495
12904
  prevToken = iterator.stepBackward();
13496
-
13497
- if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
13498
- if (prevToken.value === '<') {
13499
- depth++;
13500
- } else if (prevToken.value === '</') {
13501
- depth--;
12905
+
12906
+ if (token) {
12907
+ if (token.type.indexOf('tag-name') !== -1) {
12908
+ if (tag === token.value) {
12909
+ if (prevToken.value === '<') {
12910
+ depth++;
12911
+ } else if (prevToken.value === '</') {
12912
+ depth--;
12913
+ }
12914
+ }
12915
+ } else if (token.value === '/>') { // self closing tag
12916
+ var stepCount = 0;
12917
+ var tmpToken = prevToken;
12918
+ while (tmpToken) {
12919
+ if (tmpToken.type.indexOf('tag-name') !== -1 && tmpToken.value === tag) {
12920
+ depth--;
12921
+ break;
12922
+ } else if (tmpToken.value === '<') {
12923
+ break;
12924
+ }
12925
+ tmpToken = iterator.stepBackward();
12926
+ stepCount++;
12927
+ }
12928
+ for (var i = 0; i < stepCount; i++) {
12929
+ iterator.stepForward();
12930
+ }
13502
12931
  }
13503
12932
  }
13504
12933
  } while (prevToken && depth <= 0);
@@ -13557,6 +12986,9 @@ Editor.$uid = 0;
13557
12986
 
13558
12987
  this.$cursorChange = function() {
13559
12988
  this.renderer.updateCursor();
12989
+ this.$highlightBrackets();
12990
+ this.$highlightTags();
12991
+ this.$updateHighlightActiveLine();
13560
12992
  };
13561
12993
  this.onDocumentChange = function(delta) {
13562
12994
  var wrap = this.session.$useWrapMode;
@@ -13565,7 +12997,6 @@ Editor.$uid = 0;
13565
12997
 
13566
12998
  this._signal("change", delta);
13567
12999
  this.$cursorChange();
13568
- this.$updateHighlightActiveLine();
13569
13000
  };
13570
13001
 
13571
13002
  this.onTokenizerUpdate = function(e) {
@@ -13583,10 +13014,6 @@ Editor.$uid = 0;
13583
13014
  };
13584
13015
  this.onCursorChange = function() {
13585
13016
  this.$cursorChange();
13586
-
13587
- this.$highlightBrackets();
13588
- this.$highlightTags();
13589
- this.$updateHighlightActiveLine();
13590
13017
  this._signal("changeSelection");
13591
13018
  };
13592
13019
 
@@ -13837,16 +13264,62 @@ Editor.$uid = 0;
13837
13264
  transform.selection[3]));
13838
13265
  }
13839
13266
  }
13267
+ if (this.$enableAutoIndent) {
13268
+ if (session.getDocument().isNewLine(text)) {
13269
+ var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
13270
+
13271
+ session.insert({row: cursor.row+1, column: 0}, lineIndent);
13272
+ }
13273
+ if (shouldOutdent)
13274
+ mode.autoOutdent(lineState, session, cursor.row);
13275
+ }
13276
+ };
13277
+
13278
+ this.autoIndent = function () {
13279
+ var session = this.session;
13280
+ var mode = session.getMode();
13281
+
13282
+ var startRow, endRow;
13283
+ if (this.selection.isEmpty()) {
13284
+ startRow = 0;
13285
+ endRow = session.doc.getLength() - 1;
13286
+ } else {
13287
+ var selectedRange = this.getSelectionRange();
13288
+
13289
+ startRow = selectedRange.start.row;
13290
+ endRow = selectedRange.end.row;
13291
+ }
13292
+
13293
+ var prevLineState = "";
13294
+ var prevLine = "";
13295
+ var lineIndent = "";
13296
+ var line, currIndent, range;
13297
+ var tab = session.getTabString();
13298
+
13299
+ for (var row = startRow; row <= endRow; row++) {
13300
+ if (row > 0) {
13301
+ prevLineState = session.getState(row - 1);
13302
+ prevLine = session.getLine(row - 1);
13303
+ lineIndent = mode.getNextLineIndent(prevLineState, prevLine, tab);
13304
+ }
13840
13305
 
13841
- if (session.getDocument().isNewLine(text)) {
13842
- var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
13306
+ line = session.getLine(row);
13307
+ currIndent = mode.$getIndent(line);
13308
+ if (lineIndent !== currIndent) {
13309
+ if (currIndent.length > 0) {
13310
+ range = new Range(row, 0, row, currIndent.length);
13311
+ session.remove(range);
13312
+ }
13313
+ if (lineIndent.length > 0) {
13314
+ session.insert({row: row, column: 0}, lineIndent);
13315
+ }
13316
+ }
13843
13317
 
13844
- session.insert({row: cursor.row+1, column: 0}, lineIndent);
13318
+ mode.autoOutdent(prevLineState, session, row);
13845
13319
  }
13846
- if (shouldOutdent)
13847
- mode.autoOutdent(lineState, session, cursor.row);
13848
13320
  };
13849
13321
 
13322
+
13850
13323
  this.onTextInput = function(text, composition) {
13851
13324
  if (!composition)
13852
13325
  return this.keyBinding.onTextInput(text);
@@ -13865,6 +13338,10 @@ Editor.$uid = 0;
13865
13338
  var r = this.selection.getRange();
13866
13339
  r.start.column -= composition.extendLeft;
13867
13340
  r.end.column += composition.extendRight;
13341
+ if (r.start.column < 0) {
13342
+ r.start.row--;
13343
+ r.start.column += this.session.getLine(r.start.row).length + 1;
13344
+ }
13868
13345
  this.selection.setRange(r);
13869
13346
  if (!text && !r.isEmpty())
13870
13347
  this.remove();
@@ -14870,11 +14347,21 @@ Editor.$uid = 0;
14870
14347
  this.renderer.scrollCursorIntoView(null, 0.5);
14871
14348
  };
14872
14349
  this.destroy = function() {
14350
+ if (this.$toDestroy) {
14351
+ this.$toDestroy.forEach(function(el) {
14352
+ el.destroy();
14353
+ });
14354
+ this.$toDestroy = null;
14355
+ }
14356
+ if (this.$mouseHandler)
14357
+ this.$mouseHandler.destroy();
14873
14358
  this.renderer.destroy();
14874
14359
  this._signal("destroy", this);
14875
- if (this.session) {
14360
+ if (this.session)
14876
14361
  this.session.destroy();
14877
- }
14362
+ if (this._$emitInputEvent)
14363
+ this._$emitInputEvent.cancel();
14364
+ this.removeAllListeners();
14878
14365
  };
14879
14366
  this.setAutoScrollEditorIntoView = function(enable) {
14880
14367
  if (!enable)
@@ -14990,6 +14477,7 @@ config.defineOptions(Editor.prototype, "editor", {
14990
14477
  },
14991
14478
  behavioursEnabled: {initialValue: true},
14992
14479
  wrapBehavioursEnabled: {initialValue: true},
14480
+ enableAutoIndent: {initialValue: true},
14993
14481
  autoScrollEditorIntoView: {
14994
14482
  set: function(val) {this.setAutoScrollEditorIntoView(val);}
14995
14483
  },
@@ -15034,7 +14522,7 @@ config.defineOptions(Editor.prototype, "editor", {
15034
14522
  set: function(message) {
15035
14523
  if (!this.$updatePlaceholder) {
15036
14524
  this.$updatePlaceholder = function() {
15037
- var value = this.renderer.$composition || this.getValue();
14525
+ var value = this.session && (this.renderer.$composition || this.getValue());
15038
14526
  if (value && this.renderer.placeholderNode) {
15039
14527
  this.renderer.off("afterRender", this.$updatePlaceholder);
15040
14528
  dom.removeCssClass(this.container, "ace_hasPlaceholder");
@@ -15048,6 +14536,8 @@ config.defineOptions(Editor.prototype, "editor", {
15048
14536
  el.textContent = this.$placeholder || "";
15049
14537
  this.renderer.placeholderNode = el;
15050
14538
  this.renderer.content.appendChild(this.renderer.placeholderNode);
14539
+ } else if (!value && this.renderer.placeholderNode) {
14540
+ this.renderer.placeholderNode.textContent = this.$placeholder || "";
15051
14541
  }
15052
14542
  }.bind(this);
15053
14543
  this.on("input", this.$updatePlaceholder);
@@ -15145,6 +14635,7 @@ var UndoManager = function() {
15145
14635
  this.add = function(delta, allowMerge, session) {
15146
14636
  if (this.$fromUndo) return;
15147
14637
  if (delta == this.$lastDelta) return;
14638
+ if (!this.$keepRedoStack) this.$redoStack.length = 0;
15148
14639
  if (allowMerge === false || !this.lastDeltas) {
15149
14640
  this.lastDeltas = [];
15150
14641
  this.$undoStack.push(this.lastDeltas);
@@ -15238,7 +14729,7 @@ var UndoManager = function() {
15238
14729
 
15239
14730
  var deltaSet = stack.pop();
15240
14731
  var undoSelectionRange = null;
15241
- if (deltaSet && deltaSet.length) {
14732
+ if (deltaSet) {
15242
14733
  undoSelectionRange = session.undoChanges(deltaSet, dontSelect);
15243
14734
  this.$redoStack.push(deltaSet);
15244
14735
  this.$syncRev();
@@ -15645,7 +15136,7 @@ var Lines = function(element, canvasHeight) {
15645
15136
  };
15646
15137
 
15647
15138
  this.computeLineHeight = function(row, config, session) {
15648
- return config.lineHeight * session.getRowLength(row);
15139
+ return config.lineHeight * session.getRowLineCount(row);
15649
15140
  };
15650
15141
 
15651
15142
  this.getLength = function() {
@@ -15672,10 +15163,10 @@ var Lines = function(element, canvasHeight) {
15672
15163
  fragment.appendChild(cell[i].element);
15673
15164
  }
15674
15165
  this.element.appendChild(fragment);
15675
- } else {
15166
+ } else {
15676
15167
  this.cells.push(cell);
15677
15168
  this.element.appendChild(cell.element);
15678
- }
15169
+ }
15679
15170
  };
15680
15171
 
15681
15172
  this.unshift = function(cell) {
@@ -15689,10 +15180,10 @@ var Lines = function(element, canvasHeight) {
15689
15180
  this.element.insertBefore(fragment, this.element.firstChild);
15690
15181
  else
15691
15182
  this.element.appendChild(fragment);
15692
- } else {
15183
+ } else {
15693
15184
  this.cells.unshift(cell);
15694
15185
  this.element.insertAdjacentElement("afterbegin", cell.element);
15695
- }
15186
+ }
15696
15187
  };
15697
15188
 
15698
15189
  this.last = function() {
@@ -15766,7 +15257,7 @@ var Gutter = function(parentEl) {
15766
15257
 
15767
15258
  this.setSession = function(session) {
15768
15259
  if (this.session)
15769
- this.session.removeEventListener("change", this.$updateAnnotations);
15260
+ this.session.off("change", this.$updateAnnotations);
15770
15261
  this.session = session;
15771
15262
  if (session)
15772
15263
  session.on("change", this.$updateAnnotations);
@@ -16455,11 +15946,21 @@ var Text = function(parentEl) {
16455
15946
  };
16456
15947
 
16457
15948
  this.showInvisibles = false;
15949
+ this.showSpaces = false;
15950
+ this.showTabs = false;
15951
+ this.showEOL = false;
16458
15952
  this.setShowInvisibles = function(showInvisibles) {
16459
15953
  if (this.showInvisibles == showInvisibles)
16460
15954
  return false;
16461
15955
 
16462
15956
  this.showInvisibles = showInvisibles;
15957
+ if (typeof showInvisibles == "string") {
15958
+ this.showSpaces = /tab/i.test(showInvisibles);
15959
+ this.showTabs = /space/i.test(showInvisibles);
15960
+ this.showEOL = /eol/i.test(showInvisibles);
15961
+ } else {
15962
+ this.showSpaces = this.showTabs = this.showEOL = showInvisibles;
15963
+ }
16463
15964
  this.$computeTabString();
16464
15965
  return true;
16465
15966
  };
@@ -16481,7 +15982,7 @@ var Text = function(parentEl) {
16481
15982
  this.tabSize = tabSize;
16482
15983
  var tabStr = this.$tabStrings = [0];
16483
15984
  for (var i = 1; i < tabSize + 1; i++) {
16484
- if (this.showInvisibles) {
15985
+ if (this.showTabs) {
16485
15986
  var span = this.dom.createElement("span");
16486
15987
  span.className = "ace_invisible ace_invisible_tab";
16487
15988
  span.textContent = lang.stringRepeat(this.TAB_CHAR, i);
@@ -16493,18 +15994,15 @@ var Text = function(parentEl) {
16493
15994
  if (this.displayIndentGuides) {
16494
15995
  this.$indentGuideRe = /\s\S| \t|\t |\s$/;
16495
15996
  var className = "ace_indent-guide";
16496
- var spaceClass = "";
16497
- var tabClass = "";
16498
- if (this.showInvisibles) {
16499
- className += " ace_invisible";
16500
- spaceClass = " ace_invisible_space";
16501
- tabClass = " ace_invisible_tab";
16502
- var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
16503
- var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize);
16504
- } else {
16505
- var spaceContent = lang.stringRepeat(" ", this.tabSize);
16506
- var tabContent = spaceContent;
16507
- }
15997
+ var spaceClass = this.showSpaces ? " ace_invisible ace_invisible_space" : "";
15998
+ var spaceContent = this.showSpaces
15999
+ ? lang.stringRepeat(this.SPACE_CHAR, this.tabSize)
16000
+ : lang.stringRepeat(" ", this.tabSize);
16001
+
16002
+ var tabClass = this.showTabs ? " ace_invisible ace_invisible_tab" : "";
16003
+ var tabContent = this.showTabs
16004
+ ? lang.stringRepeat(this.TAB_CHAR, this.tabSize)
16005
+ : spaceContent;
16508
16006
 
16509
16007
  var span = this.dom.createElement("span");
16510
16008
  span.className = className + spaceClass;
@@ -16697,7 +16195,7 @@ var Text = function(parentEl) {
16697
16195
  var cjkSpace = m[4];
16698
16196
  var cjk = m[5];
16699
16197
 
16700
- if (!self.showInvisibles && simpleSpace)
16198
+ if (!self.showSpaces && simpleSpace)
16701
16199
  continue;
16702
16200
 
16703
16201
  var before = i != m.index ? value.slice(i, m.index) : "";
@@ -16713,7 +16211,7 @@ var Text = function(parentEl) {
16713
16211
  valueFragment.appendChild(self.$tabStrings[tabSize].cloneNode(true));
16714
16212
  screenColumn += tabSize - 1;
16715
16213
  } else if (simpleSpace) {
16716
- if (self.showInvisibles) {
16214
+ if (self.showSpaces) {
16717
16215
  var span = this.dom.createElement("span");
16718
16216
  span.className = "ace_invisible ace_invisible_space";
16719
16217
  span.textContent = lang.stringRepeat(self.SPACE_CHAR, simpleSpace.length);
@@ -16731,8 +16229,8 @@ var Text = function(parentEl) {
16731
16229
 
16732
16230
  var span = this.dom.createElement("span");
16733
16231
  span.style.width = (self.config.characterWidth * 2) + "px";
16734
- span.className = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
16735
- span.textContent = self.showInvisibles ? self.SPACE_CHAR : cjkSpace;
16232
+ span.className = self.showSpaces ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
16233
+ span.textContent = self.showSpaces ? self.SPACE_CHAR : cjkSpace;
16736
16234
  valueFragment.appendChild(span);
16737
16235
  } else if (cjk) {
16738
16236
  screenColumn += 1;
@@ -16901,7 +16399,7 @@ var Text = function(parentEl) {
16901
16399
  parent.appendChild(lastLineEl);
16902
16400
  }
16903
16401
 
16904
- if (this.showInvisibles && lastLineEl) {
16402
+ if (this.showEOL && lastLineEl) {
16905
16403
  if (foldLine)
16906
16404
  row = foldLine.end.row;
16907
16405
 
@@ -17432,7 +16930,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl) {
17432
16930
  this.el.appendChild(this.$measureNode);
17433
16931
  parentEl.appendChild(this.el);
17434
16932
 
17435
- this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT);
16933
+ this.$measureNode.textContent = lang.stringRepeat("X", CHAR_COUNT);
17436
16934
 
17437
16935
  this.$characterSize = {width: 0, height: 0};
17438
16936
 
@@ -17481,11 +16979,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl) {
17481
16979
  this.$addObserver = function() {
17482
16980
  var self = this;
17483
16981
  this.$observer = new window.ResizeObserver(function(e) {
17484
- var rect = e[0].contentRect;
17485
- self.checkForSizeChanges({
17486
- height: rect.height,
17487
- width: rect.width / CHAR_COUNT
17488
- });
16982
+ self.checkForSizeChanges();
17489
16983
  });
17490
16984
  this.$observer.observe(this.$measureNode);
17491
16985
  };
@@ -17521,7 +17015,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl) {
17521
17015
  };
17522
17016
 
17523
17017
  this.$measureCharWidth = function(ch) {
17524
- this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT);
17018
+ this.$main.textContent = lang.stringRepeat(ch, CHAR_COUNT);
17525
17019
  var rect = this.$main.getBoundingClientRect();
17526
17020
  return rect.width / CHAR_COUNT;
17527
17021
  };
@@ -17544,7 +17038,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl) {
17544
17038
 
17545
17039
 
17546
17040
  this.$getZoom = function getZoom(element) {
17547
- if (!element) return 1;
17041
+ if (!element || !element.parentElement) return 1;
17548
17042
  return (window.getComputedStyle(element).zoom || 1) * getZoom(element.parentElement);
17549
17043
  };
17550
17044
  this.$initTransformMeasureNodes = function() {
@@ -17638,6 +17132,7 @@ var editorCss = "\
17638
17132
  .ace_editor {\
17639
17133
  position: relative;\
17640
17134
  overflow: hidden;\
17135
+ padding: 0;\
17641
17136
  font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\
17642
17137
  direction: ltr;\
17643
17138
  text-align: left;\
@@ -17660,6 +17155,7 @@ position: absolute;\
17660
17155
  box-sizing: border-box;\
17661
17156
  min-width: 100%;\
17662
17157
  contain: style size layout;\
17158
+ font-variant-ligatures: no-common-ligatures;\
17663
17159
  }\
17664
17160
  .ace_dragging .ace_scroller:before{\
17665
17161
  position: absolute;\
@@ -17791,7 +17287,6 @@ margin-top: 1px;\
17791
17287
  [ace_nocontext=true] {\
17792
17288
  transform: none!important;\
17793
17289
  filter: none!important;\
17794
- perspective: none!important;\
17795
17290
  clip-path: none!important;\
17796
17291
  mask : none!important;\
17797
17292
  contain: none!important;\
@@ -17909,6 +17404,11 @@ z-index: 5;\
17909
17404
  position: absolute;\
17910
17405
  z-index: 6;\
17911
17406
  }\
17407
+ .ace_marker-layer .ace_error_bracket {\
17408
+ position: absolute;\
17409
+ border-bottom: 1px solid #DE5555;\
17410
+ border-radius: 0;\
17411
+ }\
17912
17412
  .ace_marker-layer .ace_active-line {\
17913
17413
  position: absolute;\
17914
17414
  z-index: 2;\
@@ -18096,9 +17596,10 @@ background-color: #ddd;\
18096
17596
  .ace_placeholder {\
18097
17597
  font-family: arial;\
18098
17598
  transform: scale(0.9);\
18099
- opacity: 0.7;\
18100
17599
  transform-origin: left;\
18101
- text-indent: 10px;\
17600
+ white-space: pre;\
17601
+ opacity: 0.7;\
17602
+ margin: 0 10px;\
18102
17603
  }";
18103
17604
 
18104
17605
  var useragent = require("./lib/useragent");
@@ -18147,11 +17648,11 @@ var VirtualRenderer = function(container, theme) {
18147
17648
  this.scrollBar =
18148
17649
  this.scrollBarV = new VScrollBar(this.container, this);
18149
17650
  this.scrollBarH = new HScrollBar(this.container, this);
18150
- this.scrollBarV.addEventListener("scroll", function(e) {
17651
+ this.scrollBarV.on("scroll", function(e) {
18151
17652
  if (!_self.$scrollAnimation)
18152
17653
  _self.session.setScrollTop(e.data - _self.scrollMargin.top);
18153
17654
  });
18154
- this.scrollBarH.addEventListener("scroll", function(e) {
17655
+ this.scrollBarH.on("scroll", function(e) {
18155
17656
  if (!_self.$scrollAnimation)
18156
17657
  _self.session.setScrollLeft(e.data - _self.scrollMargin.left);
18157
17658
  });
@@ -18166,7 +17667,7 @@ var VirtualRenderer = function(container, theme) {
18166
17667
 
18167
17668
  this.$fontMetrics = new FontMetrics(this.container);
18168
17669
  this.$textLayer.$setFontMetrics(this.$fontMetrics);
18169
- this.$textLayer.addEventListener("changeCharacterSize", function(e) {
17670
+ this.$textLayer.on("changeCharacterSize", function(e) {
18170
17671
  _self.updateCharacterSize();
18171
17672
  _self.onResize(true, _self.gutterWidth, _self.$size.width, _self.$size.height);
18172
17673
  _self._signal("changeCharacterSize", e);
@@ -18685,7 +18186,7 @@ var VirtualRenderer = function(container, theme) {
18685
18186
  this.$textLayer.checkForSizeChanges();
18686
18187
  }
18687
18188
 
18688
- this._signal("beforeRender");
18189
+ this._signal("beforeRender", changes);
18689
18190
 
18690
18191
  if (this.session && this.session.$bidiHandler)
18691
18192
  this.session.$bidiHandler.updateCharacterWidths(this.$fontMetrics);
@@ -18733,7 +18234,7 @@ var VirtualRenderer = function(container, theme) {
18733
18234
  this.$markerFront.update(config);
18734
18235
  this.$cursorLayer.update(config);
18735
18236
  this.$moveTextAreaToCursor();
18736
- this._signal("afterRender");
18237
+ this._signal("afterRender", changes);
18737
18238
  return;
18738
18239
  }
18739
18240
  if (changes & this.CHANGE_SCROLL) {
@@ -18753,7 +18254,7 @@ var VirtualRenderer = function(container, theme) {
18753
18254
  this.$markerFront.update(config);
18754
18255
  this.$cursorLayer.update(config);
18755
18256
  this.$moveTextAreaToCursor();
18756
- this._signal("afterRender");
18257
+ this._signal("afterRender", changes);
18757
18258
  return;
18758
18259
  }
18759
18260
 
@@ -18789,7 +18290,7 @@ var VirtualRenderer = function(container, theme) {
18789
18290
  this.$markerBack.update(config);
18790
18291
  }
18791
18292
 
18792
- this._signal("afterRender");
18293
+ this._signal("afterRender", changes);
18793
18294
  };
18794
18295
 
18795
18296
 
@@ -19103,6 +18604,8 @@ var VirtualRenderer = function(container, theme) {
19103
18604
  _self.session.setScrollTop(steps.shift());
19104
18605
  _self.session.$scrollTop = toValue;
19105
18606
  this.$timer = setInterval(function() {
18607
+ if (!_self.session)
18608
+ return clearInterval(_self.$timer);
19106
18609
  if (steps.length) {
19107
18610
  _self.session.setScrollTop(steps.shift());
19108
18611
  _self.session.$scrollTop = toValue;
@@ -19213,7 +18716,8 @@ var VirtualRenderer = function(container, theme) {
19213
18716
  if (!composition.cssText) {
19214
18717
  composition.cssText = this.textarea.style.cssText;
19215
18718
  }
19216
- composition.useTextareaForIME = this.$useTextareaForIME;
18719
+ if (composition.useTextareaForIME == undefined)
18720
+ composition.useTextareaForIME = this.$useTextareaForIME;
19217
18721
 
19218
18722
  if (this.$useTextareaForIME) {
19219
18723
  dom.addCssClass(this.textarea, "ace_composition");
@@ -19239,6 +18743,8 @@ var VirtualRenderer = function(container, theme) {
19239
18743
 
19240
18744
  dom.removeCssClass(this.textarea, "ace_composition");
19241
18745
  this.textarea.style.cssText = this.$composition.cssText;
18746
+ var cursor = this.session.selection.cursor;
18747
+ this.removeExtraToken(cursor.row, cursor.column);
19242
18748
  this.$composition = null;
19243
18749
  this.$cursorLayer.element.style.display = "";
19244
18750
  };
@@ -19267,6 +18773,10 @@ var VirtualRenderer = function(container, theme) {
19267
18773
  }
19268
18774
  this.updateLines(row, row);
19269
18775
  };
18776
+
18777
+ this.removeExtraToken = function(row, column) {
18778
+ this.updateLines(row, row);
18779
+ };
19270
18780
  this.setTheme = function(theme, cb) {
19271
18781
  var _self = this;
19272
18782
  this.$themeId = theme;
@@ -19337,6 +18847,8 @@ var VirtualRenderer = function(container, theme) {
19337
18847
  this.freeze();
19338
18848
  this.$fontMetrics.destroy();
19339
18849
  this.$cursorLayer.destroy();
18850
+ this.removeAllListeners();
18851
+ this.container.textContent = "";
19340
18852
  };
19341
18853
 
19342
18854
  }).call(VirtualRenderer.prototype);
@@ -19863,8 +19375,8 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
19863
19375
  this.detach = function() {
19864
19376
  this.session.removeMarker(this.pos && this.pos.markerId);
19865
19377
  this.hideOtherMarkers();
19866
- this.doc.removeEventListener("change", this.$onUpdate);
19867
- this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
19378
+ this.doc.off("change", this.$onUpdate);
19379
+ this.session.selection.off("changeCursor", this.$onCursorChange);
19868
19380
  this.session.setUndoSelect(true);
19869
19381
  this.session = null;
19870
19382
  };
@@ -20115,11 +19627,21 @@ exports.defaultCommands = [{
20115
19627
  scrollIntoView: "cursor",
20116
19628
  readOnly: true
20117
19629
  }, {
20118
- name: "splitIntoLines",
19630
+ name: "toggleSplitSelectionIntoLines",
20119
19631
  description: "Split into lines",
20120
- exec: function(editor) { editor.multiSelect.splitIntoLines(); },
19632
+ exec: function(editor) {
19633
+ if (editor.multiSelect.rangeCount > 1)
19634
+ editor.multiSelect.joinSelections();
19635
+ else
19636
+ editor.multiSelect.splitIntoLines();
19637
+ },
20121
19638
  bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"},
20122
19639
  readOnly: true
19640
+ }, {
19641
+ name: "splitSelectionIntoLines",
19642
+ description: "Split into lines",
19643
+ exec: function(editor) { editor.multiSelect.splitIntoLines(); },
19644
+ readOnly: true
20123
19645
  }, {
20124
19646
  name: "alignCursors",
20125
19647
  description: "Align cursors",
@@ -20213,7 +19735,6 @@ var EditSession = require("./edit_session").EditSession;
20213
19735
 
20214
19736
  return $blockChangeEvents || this.fromOrientedRange(range);
20215
19737
  };
20216
-
20217
19738
  this.toSingleRange = function(range) {
20218
19739
  range = range || this.ranges[0];
20219
19740
  var removed = this.rangeList.removeAll();
@@ -20278,45 +19799,36 @@ var EditSession = require("./edit_session").EditSession;
20278
19799
  this.getAllRanges = function() {
20279
19800
  return this.rangeCount ? this.rangeList.ranges.concat() : [this.getRange()];
20280
19801
  };
20281
-
20282
19802
  this.splitIntoLines = function () {
20283
- if (this.rangeCount > 1) {
20284
- var ranges = this.rangeList.ranges;
20285
- var lastRange = ranges[ranges.length - 1];
20286
- var range = Range.fromPoints(ranges[0].start, lastRange.end);
20287
-
20288
- this.toSingleRange();
20289
- this.setSelectionRange(range, lastRange.cursor == lastRange.start);
20290
- } else {
20291
- var range = this.getRange();
20292
- var isBackwards = this.isBackwards();
20293
- var startRow = range.start.row;
19803
+ var ranges = this.ranges.length ? this.ranges : [this.getRange()];
19804
+ var newRanges = [];
19805
+ for (var i = 0; i < ranges.length; i++) {
19806
+ var range = ranges[i];
19807
+ var row = range.start.row;
20294
19808
  var endRow = range.end.row;
20295
- if (startRow == endRow) {
20296
- if (isBackwards)
20297
- var start = range.end, end = range.start;
20298
- else
20299
- var start = range.start, end = range.end;
20300
-
20301
- this.addRange(Range.fromPoints(end, end));
20302
- this.addRange(Range.fromPoints(start, start));
20303
- return;
19809
+ if (row === endRow) {
19810
+ newRanges.push(range.clone());
19811
+ } else {
19812
+ newRanges.push(new Range(row, range.start.column, row, this.session.getLine(row).length));
19813
+ while (++row < endRow)
19814
+ newRanges.push(this.getLineRange(row, true));
19815
+ newRanges.push(new Range(endRow, 0, endRow, range.end.column));
20304
19816
  }
20305
-
20306
- var rectSel = [];
20307
- var r = this.getLineRange(startRow, true);
20308
- r.start.column = range.start.column;
20309
- rectSel.push(r);
20310
-
20311
- for (var i = startRow + 1; i < endRow; i++)
20312
- rectSel.push(this.getLineRange(i, true));
20313
-
20314
- r = this.getLineRange(endRow, true);
20315
- r.end.column = range.end.column;
20316
- rectSel.push(r);
20317
-
20318
- rectSel.forEach(this.addRange, this);
19817
+ if (i == 0 && !this.isBackwards())
19818
+ newRanges = newRanges.reverse();
20319
19819
  }
19820
+ this.toSingleRange();
19821
+ for (var i = newRanges.length; i--;)
19822
+ this.addRange(newRanges[i]);
19823
+ };
19824
+
19825
+ this.joinSelections = function () {
19826
+ var ranges = this.rangeList.ranges;
19827
+ var lastRange = ranges[ranges.length - 1];
19828
+ var range = Range.fromPoints(ranges[0].start, lastRange.end);
19829
+
19830
+ this.toSingleRange();
19831
+ this.setSelectionRange(range, lastRange.cursor == lastRange.start);
20320
19832
  };
20321
19833
  this.toggleBlockSelection = function () {
20322
19834
  if (this.rangeCount > 1) {
@@ -20918,10 +20430,10 @@ function addAltCursorListeners(editor){
20918
20430
  } else if (altCursor) {
20919
20431
  reset();
20920
20432
  }
20921
- });
20433
+ }, editor);
20922
20434
 
20923
- event.addListener(el, "keyup", reset);
20924
- event.addListener(el, "blur", reset);
20435
+ event.addListener(el, "keyup", reset, editor);
20436
+ event.addListener(el, "blur", reset, editor);
20925
20437
  function reset(e) {
20926
20438
  if (altCursor) {
20927
20439
  editor.renderer.setMouseCursor("");
@@ -21182,13 +20694,10 @@ var dom = require("../lib/dom");
21182
20694
  dom.importCssString(exports.cssText, exports.cssClass);
21183
20695
  });
21184
20696
 
21185
- define("ace/line_widgets",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/range"], function(require, exports, module) {
20697
+ define("ace/line_widgets",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
21186
20698
  "use strict";
21187
20699
 
21188
- var oop = require("./lib/oop");
21189
20700
  var dom = require("./lib/dom");
21190
- var Range = require("./range").Range;
21191
-
21192
20701
 
21193
20702
  function LineWidgets(session) {
21194
20703
  this.session = session;
@@ -21302,14 +20811,21 @@ function LineWidgets(session) {
21302
20811
  var len = delta.end.row - startRow;
21303
20812
 
21304
20813
  if (len === 0) {
21305
- } else if (delta.action == 'remove') {
20814
+ } else if (delta.action == "remove") {
21306
20815
  var removed = lineWidgets.splice(startRow + 1, len);
20816
+ if (!lineWidgets[startRow] && removed[removed.length - 1]) {
20817
+ lineWidgets[startRow] = removed.pop();
20818
+ }
21307
20819
  removed.forEach(function(w) {
21308
20820
  w && this.removeLineWidget(w);
21309
20821
  }, this);
21310
20822
  this.$updateRows();
21311
20823
  } else {
21312
20824
  var args = new Array(len);
20825
+ if (lineWidgets[startRow] && lineWidgets[startRow].column != null) {
20826
+ if (delta.start.column > lineWidgets[startRow].column)
20827
+ startRow++;
20828
+ }
21313
20829
  args.unshift(startRow, 0);
21314
20830
  lineWidgets.splice.apply(lineWidgets, args);
21315
20831
  this.$updateRows();
@@ -21334,7 +20850,7 @@ function LineWidgets(session) {
21334
20850
  this.session.lineWidgets = null;
21335
20851
  };
21336
20852
 
21337
- this.addLineWidget = function(w) {
20853
+ this.$registerLineWidget = function(w) {
21338
20854
  if (!this.session.lineWidgets)
21339
20855
  this.session.lineWidgets = new Array(this.session.getLength());
21340
20856
 
@@ -21348,9 +20864,15 @@ function LineWidgets(session) {
21348
20864
  }
21349
20865
 
21350
20866
  this.session.lineWidgets[w.row] = w;
21351
-
20867
+ return w;
20868
+ };
20869
+
20870
+ this.addLineWidget = function(w) {
20871
+ this.$registerLineWidget(w);
21352
20872
  w.session = this.session;
21353
20873
 
20874
+ if (!this.editor) return w;
20875
+
21354
20876
  var renderer = this.editor.renderer;
21355
20877
  if (w.html && !w.el) {
21356
20878
  w.el = dom.createElement("div");
@@ -21362,13 +20884,13 @@ function LineWidgets(session) {
21362
20884
  w.el.style.zIndex = 5;
21363
20885
  renderer.container.appendChild(w.el);
21364
20886
  w._inDocument = true;
21365
- }
21366
-
21367
- if (!w.coverGutter) {
21368
- w.el.style.zIndex = 3;
21369
- }
21370
- if (w.pixelHeight == null) {
21371
- w.pixelHeight = w.el.offsetHeight;
20887
+
20888
+ if (!w.coverGutter) {
20889
+ w.el.style.zIndex = 3;
20890
+ }
20891
+ if (w.pixelHeight == null) {
20892
+ w.pixelHeight = w.el.offsetHeight;
20893
+ }
21372
20894
  }
21373
20895
  if (w.rowCount == null) {
21374
20896
  w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight;