@openui5/sap.ui.codeeditor 1.133.1 → 1.135.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (450) hide show
  1. package/.reuse/dep5 +0 -7
  2. package/THIRDPARTY.txt +2 -23
  3. package/package.json +2 -2
  4. package/src/sap/ui/codeeditor/.library +2 -2
  5. package/src/sap/ui/codeeditor/CodeEditor.js +4 -4
  6. package/src/sap/ui/codeeditor/js/ace/ace.js +6564 -6162
  7. package/src/sap/ui/codeeditor/js/ace/css/ace.css +55 -23
  8. package/src/sap/ui/codeeditor/js/ace/css/github_light_default-1.png +0 -0
  9. package/src/sap/ui/codeeditor/js/ace/css/github_light_default-2.png +0 -0
  10. package/src/sap/ui/codeeditor/js/ace/css/main-10.svg +4 -0
  11. package/src/sap/ui/codeeditor/js/ace/css/main-11.svg +5 -0
  12. package/src/sap/ui/codeeditor/js/ace/css/main-12.svg +4 -0
  13. package/src/sap/ui/codeeditor/js/ace/css/main-13.png +0 -0
  14. package/src/sap/ui/codeeditor/js/ace/css/main-14.png +0 -0
  15. package/src/sap/ui/codeeditor/js/ace/css/main-15.png +0 -0
  16. package/src/sap/ui/codeeditor/js/ace/css/main-16.png +0 -0
  17. package/src/sap/ui/codeeditor/js/ace/css/main-17.png +0 -0
  18. package/src/sap/ui/codeeditor/js/ace/css/main-18.png +0 -0
  19. package/src/sap/ui/codeeditor/js/ace/css/main-19.png +0 -0
  20. package/src/sap/ui/codeeditor/js/ace/css/main-20.png +0 -0
  21. package/src/sap/ui/codeeditor/js/ace/css/main-21.png +0 -0
  22. package/src/sap/ui/codeeditor/js/ace/css/main-22.png +0 -0
  23. package/src/sap/ui/codeeditor/js/ace/css/main-23.png +0 -0
  24. package/src/sap/ui/codeeditor/js/ace/css/main-24.png +0 -0
  25. package/src/sap/ui/codeeditor/js/ace/css/main-25.svg +1 -0
  26. package/src/sap/ui/codeeditor/js/ace/css/main-26.png +0 -0
  27. package/src/sap/ui/codeeditor/js/ace/css/main-6.svg +8 -6
  28. package/src/sap/ui/codeeditor/js/ace/css/main-7.svg +4 -6
  29. package/src/sap/ui/codeeditor/js/ace/css/main-8.svg +8 -3
  30. package/src/sap/ui/codeeditor/js/ace/css/main-9.svg +5 -3
  31. package/src/sap/ui/codeeditor/js/ace/css/theme/cloud_editor.css +221 -0
  32. package/src/sap/ui/codeeditor/js/ace/css/theme/cloud_editor_dark.css +224 -0
  33. package/src/sap/ui/codeeditor/js/ace/css/theme/github_light_default.css +164 -0
  34. package/src/sap/ui/codeeditor/js/ace/css/theme/solarized_dark.css +2 -2
  35. package/src/sap/ui/codeeditor/js/ace/ext-beautify.js +0 -0
  36. package/src/sap/ui/codeeditor/js/ace/ext-code_lens.js +1 -6
  37. package/src/sap/ui/codeeditor/js/ace/ext-command_bar.js +4 -2
  38. package/src/sap/ui/codeeditor/js/ace/ext-elastic_tabstops_lite.js +0 -0
  39. package/src/sap/ui/codeeditor/js/ace/ext-emmet.js +24 -6
  40. package/src/sap/ui/codeeditor/js/ace/ext-error_marker.js +0 -0
  41. package/src/sap/ui/codeeditor/js/ace/ext-inline_autocomplete.js +198 -87
  42. package/src/sap/ui/codeeditor/js/ace/ext-keybinding_menu.js +8 -5
  43. package/src/sap/ui/codeeditor/js/ace/ext-language_tools.js +180 -79
  44. package/src/sap/ui/codeeditor/js/ace/ext-linking.js +0 -0
  45. package/src/sap/ui/codeeditor/js/ace/ext-modelist.js +7 -3
  46. package/src/sap/ui/codeeditor/js/ace/ext-options.js +12 -5
  47. package/src/sap/ui/codeeditor/js/ace/ext-prompt.js +202 -116
  48. package/src/sap/ui/codeeditor/js/ace/ext-rtl.js +0 -0
  49. package/src/sap/ui/codeeditor/js/ace/ext-searchbox.js +14 -12
  50. package/src/sap/ui/codeeditor/js/ace/ext-settings_menu.js +12 -5
  51. package/src/sap/ui/codeeditor/js/ace/ext-spellcheck.js +0 -0
  52. package/src/sap/ui/codeeditor/js/ace/ext-split.js +2 -1
  53. package/src/sap/ui/codeeditor/js/ace/ext-static_highlight.js +0 -0
  54. package/src/sap/ui/codeeditor/js/ace/ext-statusbar.js +0 -0
  55. package/src/sap/ui/codeeditor/js/ace/ext-textarea.js +476 -3
  56. package/src/sap/ui/codeeditor/js/ace/ext-themelist.js +6 -2
  57. package/src/sap/ui/codeeditor/js/ace/ext-whitespace.js +0 -0
  58. package/src/sap/ui/codeeditor/js/ace/keybinding-emacs.js +13 -6
  59. package/src/sap/ui/codeeditor/js/ace/keybinding-vim.js +748 -373
  60. package/src/sap/ui/codeeditor/js/ace/mode-abap.js +0 -0
  61. package/src/sap/ui/codeeditor/js/ace/mode-abc.js +0 -0
  62. package/src/sap/ui/codeeditor/js/ace/mode-actionscript.js +0 -0
  63. package/src/sap/ui/codeeditor/js/ace/mode-ada.js +3 -3
  64. package/src/sap/ui/codeeditor/js/ace/mode-apache_conf.js +0 -0
  65. package/src/sap/ui/codeeditor/js/ace/mode-apex.js +6 -6
  66. package/src/sap/ui/codeeditor/js/ace/mode-applescript.js +3 -3
  67. package/src/sap/ui/codeeditor/js/ace/mode-aql.js +3 -3
  68. package/src/sap/ui/codeeditor/js/ace/mode-asciidoc.js +0 -0
  69. package/src/sap/ui/codeeditor/js/ace/mode-asl.js +14 -14
  70. package/src/sap/ui/codeeditor/js/ace/mode-assembly_arm32.js +185 -0
  71. package/src/sap/ui/codeeditor/js/ace/mode-assembly_x86.js +0 -0
  72. package/src/sap/ui/codeeditor/js/ace/mode-astro.js +377 -317
  73. package/src/sap/ui/codeeditor/js/ace/mode-autohotkey.js +0 -0
  74. package/src/sap/ui/codeeditor/js/ace/mode-basic.js +201 -0
  75. package/src/sap/ui/codeeditor/js/ace/mode-batchfile.js +0 -0
  76. package/src/sap/ui/codeeditor/js/ace/mode-c9search.js +1 -1
  77. package/src/sap/ui/codeeditor/js/ace/mode-c_cpp.js +13 -13
  78. package/src/sap/ui/codeeditor/js/ace/mode-cirru.js +0 -0
  79. package/src/sap/ui/codeeditor/js/ace/mode-clojure.js +13 -13
  80. package/src/sap/ui/codeeditor/js/ace/mode-cobol.js +3 -3
  81. package/src/sap/ui/codeeditor/js/ace/mode-coffee.js +0 -0
  82. package/src/sap/ui/codeeditor/js/ace/mode-coldfusion.js +377 -317
  83. package/src/sap/ui/codeeditor/js/ace/mode-crystal.js +6 -6
  84. package/src/sap/ui/codeeditor/js/ace/mode-csharp.js +9 -9
  85. package/src/sap/ui/codeeditor/js/ace/mode-csound_document.js +75 -78
  86. package/src/sap/ui/codeeditor/js/ace/mode-csound_orchestra.js +22 -22
  87. package/src/sap/ui/codeeditor/js/ace/mode-csound_score.js +0 -0
  88. package/src/sap/ui/codeeditor/js/ace/mode-csp.js +0 -0
  89. package/src/sap/ui/codeeditor/js/ace/mode-css.js +6 -3
  90. package/src/sap/ui/codeeditor/js/ace/mode-curly.js +377 -317
  91. package/src/sap/ui/codeeditor/js/ace/mode-d.js +12 -12
  92. package/src/sap/ui/codeeditor/js/ace/mode-dart.js +17 -17
  93. package/src/sap/ui/codeeditor/js/ace/mode-diff.js +0 -0
  94. package/src/sap/ui/codeeditor/js/ace/mode-django.js +377 -317
  95. package/src/sap/ui/codeeditor/js/ace/mode-dockerfile.js +3 -3
  96. package/src/sap/ui/codeeditor/js/ace/mode-dot.js +6 -6
  97. package/src/sap/ui/codeeditor/js/ace/mode-drools.js +18 -18
  98. package/src/sap/ui/codeeditor/js/ace/mode-edifact.js +4 -4
  99. package/src/sap/ui/codeeditor/js/ace/mode-eiffel.js +4 -4
  100. package/src/sap/ui/codeeditor/js/ace/mode-ejs.js +402 -342
  101. package/src/sap/ui/codeeditor/js/ace/mode-elixir.js +0 -0
  102. package/src/sap/ui/codeeditor/js/ace/mode-elm.js +0 -0
  103. package/src/sap/ui/codeeditor/js/ace/mode-erlang.js +15 -15
  104. package/src/sap/ui/codeeditor/js/ace/mode-flix.js +7 -7
  105. package/src/sap/ui/codeeditor/js/ace/mode-forth.js +0 -0
  106. package/src/sap/ui/codeeditor/js/ace/mode-fortran.js +12 -12
  107. package/src/sap/ui/codeeditor/js/ace/mode-fsharp.js +0 -0
  108. package/src/sap/ui/codeeditor/js/ace/mode-ftl.js +54 -57
  109. package/src/sap/ui/codeeditor/js/ace/mode-gcode.js +4 -4
  110. package/src/sap/ui/codeeditor/js/ace/mode-gherkin.js +3 -3
  111. package/src/sap/ui/codeeditor/js/ace/mode-gitignore.js +1 -1
  112. package/src/sap/ui/codeeditor/js/ace/mode-glsl.js +13 -13
  113. package/src/sap/ui/codeeditor/js/ace/mode-gobstones.js +371 -65
  114. package/src/sap/ui/codeeditor/js/ace/mode-golang.js +10 -10
  115. package/src/sap/ui/codeeditor/js/ace/mode-graphqlschema.js +0 -0
  116. package/src/sap/ui/codeeditor/js/ace/mode-groovy.js +381 -75
  117. package/src/sap/ui/codeeditor/js/ace/mode-haml.js +84 -87
  118. package/src/sap/ui/codeeditor/js/ace/mode-handlebars.js +379 -319
  119. package/src/sap/ui/codeeditor/js/ace/mode-haskell.js +0 -0
  120. package/src/sap/ui/codeeditor/js/ace/mode-haskell_cabal.js +1 -1
  121. package/src/sap/ui/codeeditor/js/ace/mode-haxe.js +10 -10
  122. package/src/sap/ui/codeeditor/js/ace/mode-hjson.js +0 -0
  123. package/src/sap/ui/codeeditor/js/ace/mode-html.js +377 -317
  124. package/src/sap/ui/codeeditor/js/ace/mode-html_elixir.js +472 -412
  125. package/src/sap/ui/codeeditor/js/ace/mode-html_ruby.js +484 -424
  126. package/src/sap/ui/codeeditor/js/ace/mode-ini.js +0 -0
  127. package/src/sap/ui/codeeditor/js/ace/mode-io.js +0 -0
  128. package/src/sap/ui/codeeditor/js/ace/mode-jack.js +2 -2
  129. package/src/sap/ui/codeeditor/js/ace/mode-jade.js +67 -70
  130. package/src/sap/ui/codeeditor/js/ace/mode-java.js +383 -77
  131. package/src/sap/ui/codeeditor/js/ace/mode-javascript.js +371 -65
  132. package/src/sap/ui/codeeditor/js/ace/mode-jexl.js +7 -7
  133. package/src/sap/ui/codeeditor/js/ace/mode-json.js +8 -8
  134. package/src/sap/ui/codeeditor/js/ace/mode-json5.js +8 -8
  135. package/src/sap/ui/codeeditor/js/ace/mode-jsoniq.js +4 -5
  136. package/src/sap/ui/codeeditor/js/ace/mode-jsp.js +67 -70
  137. package/src/sap/ui/codeeditor/js/ace/mode-jssm.js +0 -0
  138. package/src/sap/ui/codeeditor/js/ace/mode-jsx.js +960 -89
  139. package/src/sap/ui/codeeditor/js/ace/mode-julia.js +0 -0
  140. package/src/sap/ui/codeeditor/js/ace/mode-kotlin.js +0 -0
  141. package/src/sap/ui/codeeditor/js/ace/mode-latex.js +0 -0
  142. package/src/sap/ui/codeeditor/js/ace/mode-latte.js +381 -321
  143. package/src/sap/ui/codeeditor/js/ace/mode-less.js +12 -9
  144. package/src/sap/ui/codeeditor/js/ace/mode-liquid.js +385 -325
  145. package/src/sap/ui/codeeditor/js/ace/mode-lisp.js +2 -2
  146. package/src/sap/ui/codeeditor/js/ace/mode-livescript.js +0 -0
  147. package/src/sap/ui/codeeditor/js/ace/mode-logiql.js +0 -0
  148. package/src/sap/ui/codeeditor/js/ace/mode-logtalk.js +6 -9
  149. package/src/sap/ui/codeeditor/js/ace/mode-lsl.js +0 -0
  150. package/src/sap/ui/codeeditor/js/ace/mode-lua.js +5 -5
  151. package/src/sap/ui/codeeditor/js/ace/mode-luapage.js +382 -322
  152. package/src/sap/ui/codeeditor/js/ace/mode-lucene.js +0 -0
  153. package/src/sap/ui/codeeditor/js/ace/mode-makefile.js +3 -3
  154. package/src/sap/ui/codeeditor/js/ace/mode-markdown.js +474 -414
  155. package/src/sap/ui/codeeditor/js/ace/mode-mask.js +53 -56
  156. package/src/sap/ui/codeeditor/js/ace/mode-matlab.js +1 -1
  157. package/src/sap/ui/codeeditor/js/ace/mode-maze.js +0 -0
  158. package/src/sap/ui/codeeditor/js/ace/mode-mel.js +0 -0
  159. package/src/sap/ui/codeeditor/js/ace/mode-mips.js +1 -1
  160. package/src/sap/ui/codeeditor/js/ace/mode-mixal.js +0 -0
  161. package/src/sap/ui/codeeditor/js/ace/mode-mushcode.js +7 -7
  162. package/src/sap/ui/codeeditor/js/ace/mode-mysql.js +7 -7
  163. package/src/sap/ui/codeeditor/js/ace/mode-nix.js +16 -16
  164. package/src/sap/ui/codeeditor/js/ace/mode-nsis.js +0 -0
  165. package/src/sap/ui/codeeditor/js/ace/mode-nunjucks.js +379 -319
  166. package/src/sap/ui/codeeditor/js/ace/mode-objectivec.js +15 -15
  167. package/src/sap/ui/codeeditor/js/ace/mode-ocaml.js +7 -7
  168. package/src/sap/ui/codeeditor/js/ace/mode-odin.js +10 -10
  169. package/src/sap/ui/codeeditor/js/ace/mode-pascal.js +0 -0
  170. package/src/sap/ui/codeeditor/js/ace/mode-perl.js +6 -6
  171. package/src/sap/ui/codeeditor/js/ace/mode-pgsql.js +98 -104
  172. package/src/sap/ui/codeeditor/js/ace/mode-php.js +797 -616
  173. package/src/sap/ui/codeeditor/js/ace/mode-php_laravel_blade.js +797 -616
  174. package/src/sap/ui/codeeditor/js/ace/mode-pig.js +0 -0
  175. package/src/sap/ui/codeeditor/js/ace/mode-plain_text.js +0 -0
  176. package/src/sap/ui/codeeditor/js/ace/mode-plsql.js +3 -3
  177. package/src/sap/ui/codeeditor/js/ace/mode-powershell.js +6 -6
  178. package/src/sap/ui/codeeditor/js/ace/mode-praat.js +0 -0
  179. package/src/sap/ui/codeeditor/js/ace/mode-prolog.js +0 -0
  180. package/src/sap/ui/codeeditor/js/ace/mode-properties.js +0 -0
  181. package/src/sap/ui/codeeditor/js/ace/mode-protobuf.js +18 -18
  182. package/src/sap/ui/codeeditor/js/ace/mode-prql.js +7 -4
  183. package/src/sap/ui/codeeditor/js/ace/mode-puppet.js +0 -0
  184. package/src/sap/ui/codeeditor/js/ace/mode-python.js +17 -17
  185. package/src/sap/ui/codeeditor/js/ace/mode-qml.js +5 -5
  186. package/src/sap/ui/codeeditor/js/ace/mode-r.js +13 -13
  187. package/src/sap/ui/codeeditor/js/ace/mode-raku.js +8 -8
  188. package/src/sap/ui/codeeditor/js/ace/mode-razor.js +386 -326
  189. package/src/sap/ui/codeeditor/js/ace/mode-rdoc.js +6 -6
  190. package/src/sap/ui/codeeditor/js/ace/mode-red.js +0 -0
  191. package/src/sap/ui/codeeditor/js/ace/mode-redshift.js +32 -32
  192. package/src/sap/ui/codeeditor/js/ace/mode-rhtml.js +390 -330
  193. package/src/sap/ui/codeeditor/js/ace/mode-rst.js +0 -0
  194. package/src/sap/ui/codeeditor/js/ace/mode-ruby.js +25 -25
  195. package/src/sap/ui/codeeditor/js/ace/mode-rust.js +39 -32
  196. package/src/sap/ui/codeeditor/js/ace/mode-sac.js +13 -13
  197. package/src/sap/ui/codeeditor/js/ace/mode-sass.js +14 -11
  198. package/src/sap/ui/codeeditor/js/ace/mode-scad.js +14 -14
  199. package/src/sap/ui/codeeditor/js/ace/mode-scala.js +381 -75
  200. package/src/sap/ui/codeeditor/js/ace/mode-scheme.js +2 -2
  201. package/src/sap/ui/codeeditor/js/ace/mode-scrypt.js +10 -10
  202. package/src/sap/ui/codeeditor/js/ace/mode-scss.js +14 -11
  203. package/src/sap/ui/codeeditor/js/ace/mode-sh.js +3 -3
  204. package/src/sap/ui/codeeditor/js/ace/mode-sjs.js +371 -65
  205. package/src/sap/ui/codeeditor/js/ace/mode-slim.js +521 -461
  206. package/src/sap/ui/codeeditor/js/ace/mode-smarty.js +377 -317
  207. package/src/sap/ui/codeeditor/js/ace/mode-snippets.js +0 -0
  208. package/src/sap/ui/codeeditor/js/ace/mode-soy_template.js +377 -317
  209. package/src/sap/ui/codeeditor/js/ace/mode-space.js +0 -0
  210. package/src/sap/ui/codeeditor/js/ace/mode-sparql.js +0 -0
  211. package/src/sap/ui/codeeditor/js/ace/mode-sql.js +12 -6
  212. package/src/sap/ui/codeeditor/js/ace/mode-sqlserver.js +5 -5
  213. package/src/sap/ui/codeeditor/js/ace/mode-stylus.js +10 -7
  214. package/src/sap/ui/codeeditor/js/ace/mode-svg.js +132 -75
  215. package/src/sap/ui/codeeditor/js/ace/mode-swift.js +5 -4
  216. package/src/sap/ui/codeeditor/js/ace/mode-tcl.js +7 -7
  217. package/src/sap/ui/codeeditor/js/ace/mode-terraform.js +0 -0
  218. package/src/sap/ui/codeeditor/js/ace/mode-tex.js +6 -6
  219. package/src/sap/ui/codeeditor/js/ace/mode-text.js +0 -0
  220. package/src/sap/ui/codeeditor/js/ace/mode-textile.js +0 -0
  221. package/src/sap/ui/codeeditor/js/ace/mode-toml.js +0 -0
  222. package/src/sap/ui/codeeditor/js/ace/mode-tsx.js +492 -182
  223. package/src/sap/ui/codeeditor/js/ace/mode-turtle.js +0 -0
  224. package/src/sap/ui/codeeditor/js/ace/mode-twig.js +379 -319
  225. package/src/sap/ui/codeeditor/js/ace/mode-typescript.js +371 -65
  226. package/src/sap/ui/codeeditor/js/ace/mode-vala.js +0 -0
  227. package/src/sap/ui/codeeditor/js/ace/mode-vbscript.js +0 -0
  228. package/src/sap/ui/codeeditor/js/ace/mode-velocity.js +387 -327
  229. package/src/sap/ui/codeeditor/js/ace/mode-verilog.js +1 -1
  230. package/src/sap/ui/codeeditor/js/ace/mode-vhdl.js +4 -4
  231. package/src/sap/ui/codeeditor/js/ace/mode-visualforce.js +377 -317
  232. package/src/sap/ui/codeeditor/js/ace/mode-vue.js +3834 -0
  233. package/src/sap/ui/codeeditor/js/ace/mode-wollok.js +382 -76
  234. package/src/sap/ui/codeeditor/js/ace/mode-xml.js +18 -10
  235. package/src/sap/ui/codeeditor/js/ace/mode-xquery.js +4 -5
  236. package/src/sap/ui/codeeditor/js/ace/mode-yaml.js +5 -5
  237. package/src/sap/ui/codeeditor/js/ace/mode-zeek.js +2 -2
  238. package/src/sap/ui/codeeditor/js/ace/mode-zig.js +585 -0
  239. package/src/sap/ui/codeeditor/js/ace/snippets/abap.js +0 -0
  240. package/src/sap/ui/codeeditor/js/ace/snippets/abc.js +0 -0
  241. package/src/sap/ui/codeeditor/js/ace/snippets/actionscript.js +0 -0
  242. package/src/sap/ui/codeeditor/js/ace/snippets/ada.js +0 -0
  243. package/src/sap/ui/codeeditor/js/ace/snippets/apache_conf.js +0 -0
  244. package/src/sap/ui/codeeditor/js/ace/snippets/applescript.js +0 -0
  245. package/src/sap/ui/codeeditor/js/ace/snippets/asciidoc.js +0 -0
  246. package/src/sap/ui/codeeditor/js/ace/snippets/asl.js +0 -0
  247. package/src/sap/ui/codeeditor/js/ace/snippets/assembly_arm32.js +9 -0
  248. package/src/sap/ui/codeeditor/js/ace/snippets/assembly_x86.js +0 -0
  249. package/src/sap/ui/codeeditor/js/ace/snippets/autohotkey.js +0 -0
  250. package/src/sap/ui/codeeditor/js/ace/snippets/basic.js +9 -0
  251. package/src/sap/ui/codeeditor/js/ace/snippets/batchfile.js +0 -0
  252. package/src/sap/ui/codeeditor/js/ace/snippets/c9search.js +0 -0
  253. package/src/sap/ui/codeeditor/js/ace/snippets/c_cpp.js +0 -0
  254. package/src/sap/ui/codeeditor/js/ace/snippets/cirru.js +0 -0
  255. package/src/sap/ui/codeeditor/js/ace/snippets/clojure.js +0 -0
  256. package/src/sap/ui/codeeditor/js/ace/snippets/cobol.js +0 -0
  257. package/src/sap/ui/codeeditor/js/ace/snippets/coffee.js +0 -0
  258. package/src/sap/ui/codeeditor/js/ace/snippets/coldfusion.js +0 -0
  259. package/src/sap/ui/codeeditor/js/ace/snippets/csharp.js +0 -0
  260. package/src/sap/ui/codeeditor/js/ace/snippets/csound_document.js +0 -0
  261. package/src/sap/ui/codeeditor/js/ace/snippets/csound_orchestra.js +0 -0
  262. package/src/sap/ui/codeeditor/js/ace/snippets/csound_score.js +0 -0
  263. package/src/sap/ui/codeeditor/js/ace/snippets/csp.js +0 -0
  264. package/src/sap/ui/codeeditor/js/ace/snippets/css.js +0 -0
  265. package/src/sap/ui/codeeditor/js/ace/snippets/curly.js +0 -0
  266. package/src/sap/ui/codeeditor/js/ace/snippets/d.js +0 -0
  267. package/src/sap/ui/codeeditor/js/ace/snippets/dart.js +0 -0
  268. package/src/sap/ui/codeeditor/js/ace/snippets/diff.js +0 -0
  269. package/src/sap/ui/codeeditor/js/ace/snippets/django.js +0 -0
  270. package/src/sap/ui/codeeditor/js/ace/snippets/dockerfile.js +0 -0
  271. package/src/sap/ui/codeeditor/js/ace/snippets/dot.js +0 -0
  272. package/src/sap/ui/codeeditor/js/ace/snippets/drools.js +0 -0
  273. package/src/sap/ui/codeeditor/js/ace/snippets/edifact.js +0 -0
  274. package/src/sap/ui/codeeditor/js/ace/snippets/eiffel.js +0 -0
  275. package/src/sap/ui/codeeditor/js/ace/snippets/ejs.js +0 -0
  276. package/src/sap/ui/codeeditor/js/ace/snippets/elixir.js +0 -0
  277. package/src/sap/ui/codeeditor/js/ace/snippets/elm.js +0 -0
  278. package/src/sap/ui/codeeditor/js/ace/snippets/erlang.js +0 -0
  279. package/src/sap/ui/codeeditor/js/ace/snippets/forth.js +0 -0
  280. package/src/sap/ui/codeeditor/js/ace/snippets/fortran.js +0 -0
  281. package/src/sap/ui/codeeditor/js/ace/snippets/fsharp.js +0 -0
  282. package/src/sap/ui/codeeditor/js/ace/snippets/ftl.js +0 -0
  283. package/src/sap/ui/codeeditor/js/ace/snippets/gcode.js +0 -0
  284. package/src/sap/ui/codeeditor/js/ace/snippets/gherkin.js +0 -0
  285. package/src/sap/ui/codeeditor/js/ace/snippets/gitignore.js +0 -0
  286. package/src/sap/ui/codeeditor/js/ace/snippets/glsl.js +0 -0
  287. package/src/sap/ui/codeeditor/js/ace/snippets/gobstones.js +0 -0
  288. package/src/sap/ui/codeeditor/js/ace/snippets/golang.js +0 -0
  289. package/src/sap/ui/codeeditor/js/ace/snippets/graphqlschema.js +0 -0
  290. package/src/sap/ui/codeeditor/js/ace/snippets/groovy.js +0 -0
  291. package/src/sap/ui/codeeditor/js/ace/snippets/haml.js +0 -0
  292. package/src/sap/ui/codeeditor/js/ace/snippets/handlebars.js +0 -0
  293. package/src/sap/ui/codeeditor/js/ace/snippets/haskell.js +0 -0
  294. package/src/sap/ui/codeeditor/js/ace/snippets/haskell_cabal.js +0 -0
  295. package/src/sap/ui/codeeditor/js/ace/snippets/haxe.js +0 -0
  296. package/src/sap/ui/codeeditor/js/ace/snippets/hjson.js +0 -0
  297. package/src/sap/ui/codeeditor/js/ace/snippets/html.js +0 -0
  298. package/src/sap/ui/codeeditor/js/ace/snippets/html_elixir.js +0 -0
  299. package/src/sap/ui/codeeditor/js/ace/snippets/html_ruby.js +0 -0
  300. package/src/sap/ui/codeeditor/js/ace/snippets/ini.js +0 -0
  301. package/src/sap/ui/codeeditor/js/ace/snippets/io.js +0 -0
  302. package/src/sap/ui/codeeditor/js/ace/snippets/jack.js +0 -0
  303. package/src/sap/ui/codeeditor/js/ace/snippets/jade.js +0 -0
  304. package/src/sap/ui/codeeditor/js/ace/snippets/java.js +0 -0
  305. package/src/sap/ui/codeeditor/js/ace/snippets/javascript.js +0 -0
  306. package/src/sap/ui/codeeditor/js/ace/snippets/json.js +0 -0
  307. package/src/sap/ui/codeeditor/js/ace/snippets/jsoniq.js +0 -0
  308. package/src/sap/ui/codeeditor/js/ace/snippets/jsp.js +0 -0
  309. package/src/sap/ui/codeeditor/js/ace/snippets/jssm.js +0 -0
  310. package/src/sap/ui/codeeditor/js/ace/snippets/jsx.js +0 -0
  311. package/src/sap/ui/codeeditor/js/ace/snippets/julia.js +0 -0
  312. package/src/sap/ui/codeeditor/js/ace/snippets/kotlin.js +0 -0
  313. package/src/sap/ui/codeeditor/js/ace/snippets/latex.js +0 -0
  314. package/src/sap/ui/codeeditor/js/ace/snippets/less.js +0 -0
  315. package/src/sap/ui/codeeditor/js/ace/snippets/liquid.js +0 -0
  316. package/src/sap/ui/codeeditor/js/ace/snippets/lisp.js +0 -0
  317. package/src/sap/ui/codeeditor/js/ace/snippets/livescript.js +0 -0
  318. package/src/sap/ui/codeeditor/js/ace/snippets/logiql.js +0 -0
  319. package/src/sap/ui/codeeditor/js/ace/snippets/lsl.js +0 -0
  320. package/src/sap/ui/codeeditor/js/ace/snippets/lua.js +0 -0
  321. package/src/sap/ui/codeeditor/js/ace/snippets/luapage.js +0 -0
  322. package/src/sap/ui/codeeditor/js/ace/snippets/lucene.js +0 -0
  323. package/src/sap/ui/codeeditor/js/ace/snippets/makefile.js +0 -0
  324. package/src/sap/ui/codeeditor/js/ace/snippets/markdown.js +0 -0
  325. package/src/sap/ui/codeeditor/js/ace/snippets/mask.js +0 -0
  326. package/src/sap/ui/codeeditor/js/ace/snippets/matlab.js +0 -0
  327. package/src/sap/ui/codeeditor/js/ace/snippets/maze.js +0 -0
  328. package/src/sap/ui/codeeditor/js/ace/snippets/mel.js +0 -0
  329. package/src/sap/ui/codeeditor/js/ace/snippets/mixal.js +0 -0
  330. package/src/sap/ui/codeeditor/js/ace/snippets/mushcode.js +0 -0
  331. package/src/sap/ui/codeeditor/js/ace/snippets/mysql.js +0 -0
  332. package/src/sap/ui/codeeditor/js/ace/snippets/nix.js +0 -0
  333. package/src/sap/ui/codeeditor/js/ace/snippets/nsis.js +0 -0
  334. package/src/sap/ui/codeeditor/js/ace/snippets/objectivec.js +0 -0
  335. package/src/sap/ui/codeeditor/js/ace/snippets/ocaml.js +0 -0
  336. package/src/sap/ui/codeeditor/js/ace/snippets/pascal.js +0 -0
  337. package/src/sap/ui/codeeditor/js/ace/snippets/perl.js +0 -0
  338. package/src/sap/ui/codeeditor/js/ace/snippets/pgsql.js +0 -0
  339. package/src/sap/ui/codeeditor/js/ace/snippets/php.js +0 -0
  340. package/src/sap/ui/codeeditor/js/ace/snippets/php_laravel_blade.js +0 -0
  341. package/src/sap/ui/codeeditor/js/ace/snippets/pig.js +0 -0
  342. package/src/sap/ui/codeeditor/js/ace/snippets/plain_text.js +0 -0
  343. package/src/sap/ui/codeeditor/js/ace/snippets/powershell.js +0 -0
  344. package/src/sap/ui/codeeditor/js/ace/snippets/praat.js +0 -0
  345. package/src/sap/ui/codeeditor/js/ace/snippets/prolog.js +0 -0
  346. package/src/sap/ui/codeeditor/js/ace/snippets/properties.js +0 -0
  347. package/src/sap/ui/codeeditor/js/ace/snippets/protobuf.js +0 -0
  348. package/src/sap/ui/codeeditor/js/ace/snippets/puppet.js +0 -0
  349. package/src/sap/ui/codeeditor/js/ace/snippets/python.js +0 -0
  350. package/src/sap/ui/codeeditor/js/ace/snippets/r.js +0 -0
  351. package/src/sap/ui/codeeditor/js/ace/snippets/razor.js +0 -0
  352. package/src/sap/ui/codeeditor/js/ace/snippets/rdoc.js +0 -0
  353. package/src/sap/ui/codeeditor/js/ace/snippets/red.js +0 -0
  354. package/src/sap/ui/codeeditor/js/ace/snippets/redshift.js +0 -0
  355. package/src/sap/ui/codeeditor/js/ace/snippets/rhtml.js +0 -0
  356. package/src/sap/ui/codeeditor/js/ace/snippets/rst.js +0 -0
  357. package/src/sap/ui/codeeditor/js/ace/snippets/ruby.js +0 -0
  358. package/src/sap/ui/codeeditor/js/ace/snippets/rust.js +0 -0
  359. package/src/sap/ui/codeeditor/js/ace/snippets/sass.js +0 -0
  360. package/src/sap/ui/codeeditor/js/ace/snippets/scad.js +0 -0
  361. package/src/sap/ui/codeeditor/js/ace/snippets/scala.js +0 -0
  362. package/src/sap/ui/codeeditor/js/ace/snippets/scheme.js +0 -0
  363. package/src/sap/ui/codeeditor/js/ace/snippets/scss.js +0 -0
  364. package/src/sap/ui/codeeditor/js/ace/snippets/sh.js +0 -0
  365. package/src/sap/ui/codeeditor/js/ace/snippets/sjs.js +0 -0
  366. package/src/sap/ui/codeeditor/js/ace/snippets/slim.js +0 -0
  367. package/src/sap/ui/codeeditor/js/ace/snippets/smarty.js +0 -0
  368. package/src/sap/ui/codeeditor/js/ace/snippets/snippets.js +0 -0
  369. package/src/sap/ui/codeeditor/js/ace/snippets/soy_template.js +0 -0
  370. package/src/sap/ui/codeeditor/js/ace/snippets/space.js +0 -0
  371. package/src/sap/ui/codeeditor/js/ace/snippets/sparql.js +0 -0
  372. package/src/sap/ui/codeeditor/js/ace/snippets/sql.js +0 -0
  373. package/src/sap/ui/codeeditor/js/ace/snippets/sqlserver.js +0 -0
  374. package/src/sap/ui/codeeditor/js/ace/snippets/stylus.js +0 -0
  375. package/src/sap/ui/codeeditor/js/ace/snippets/svg.js +0 -0
  376. package/src/sap/ui/codeeditor/js/ace/snippets/swift.js +0 -0
  377. package/src/sap/ui/codeeditor/js/ace/snippets/tcl.js +0 -0
  378. package/src/sap/ui/codeeditor/js/ace/snippets/terraform.js +0 -0
  379. package/src/sap/ui/codeeditor/js/ace/snippets/tex.js +0 -0
  380. package/src/sap/ui/codeeditor/js/ace/snippets/text.js +0 -0
  381. package/src/sap/ui/codeeditor/js/ace/snippets/textile.js +0 -0
  382. package/src/sap/ui/codeeditor/js/ace/snippets/toml.js +0 -0
  383. package/src/sap/ui/codeeditor/js/ace/snippets/tsx.js +0 -0
  384. package/src/sap/ui/codeeditor/js/ace/snippets/turtle.js +0 -0
  385. package/src/sap/ui/codeeditor/js/ace/snippets/twig.js +0 -0
  386. package/src/sap/ui/codeeditor/js/ace/snippets/typescript.js +0 -0
  387. package/src/sap/ui/codeeditor/js/ace/snippets/vala.js +0 -0
  388. package/src/sap/ui/codeeditor/js/ace/snippets/vbscript.js +0 -0
  389. package/src/sap/ui/codeeditor/js/ace/snippets/velocity.js +0 -0
  390. package/src/sap/ui/codeeditor/js/ace/snippets/verilog.js +0 -0
  391. package/src/sap/ui/codeeditor/js/ace/snippets/vhdl.js +0 -0
  392. package/src/sap/ui/codeeditor/js/ace/snippets/vue.js +9 -0
  393. package/src/sap/ui/codeeditor/js/ace/snippets/wollok.js +0 -0
  394. package/src/sap/ui/codeeditor/js/ace/snippets/xml.js +0 -0
  395. package/src/sap/ui/codeeditor/js/ace/snippets/xquery.js +0 -0
  396. package/src/sap/ui/codeeditor/js/ace/snippets/yaml.js +0 -0
  397. package/src/sap/ui/codeeditor/js/ace/snippets/zig.js +9 -0
  398. package/src/sap/ui/codeeditor/js/ace/theme-ambiance.js +0 -0
  399. package/src/sap/ui/codeeditor/js/ace/theme-chaos.js +0 -0
  400. package/src/sap/ui/codeeditor/js/ace/theme-chrome.js +0 -0
  401. package/src/sap/ui/codeeditor/js/ace/theme-cloud_editor.js +18 -0
  402. package/src/sap/ui/codeeditor/js/ace/theme-cloud_editor_dark.js +18 -0
  403. package/src/sap/ui/codeeditor/js/ace/theme-clouds.js +0 -0
  404. package/src/sap/ui/codeeditor/js/ace/theme-clouds_midnight.js +0 -0
  405. package/src/sap/ui/codeeditor/js/ace/theme-cobalt.js +0 -0
  406. package/src/sap/ui/codeeditor/js/ace/theme-crimson_editor.js +0 -0
  407. package/src/sap/ui/codeeditor/js/ace/theme-dawn.js +0 -0
  408. package/src/sap/ui/codeeditor/js/ace/theme-dracula.js +0 -0
  409. package/src/sap/ui/codeeditor/js/ace/theme-dreamweaver.js +0 -0
  410. package/src/sap/ui/codeeditor/js/ace/theme-eclipse.js +0 -0
  411. package/src/sap/ui/codeeditor/js/ace/theme-github.js +0 -0
  412. package/src/sap/ui/codeeditor/js/ace/theme-github_light_default.js +18 -0
  413. package/src/sap/ui/codeeditor/js/ace/theme-gob.js +0 -0
  414. package/src/sap/ui/codeeditor/js/ace/theme-gruvbox.js +0 -0
  415. package/src/sap/ui/codeeditor/js/ace/theme-idle_fingers.js +0 -0
  416. package/src/sap/ui/codeeditor/js/ace/theme-iplastic.js +0 -0
  417. package/src/sap/ui/codeeditor/js/ace/theme-katzenmilch.js +0 -0
  418. package/src/sap/ui/codeeditor/js/ace/theme-kr_theme.js +0 -0
  419. package/src/sap/ui/codeeditor/js/ace/theme-kuroir.js +0 -0
  420. package/src/sap/ui/codeeditor/js/ace/theme-merbivore.js +0 -0
  421. package/src/sap/ui/codeeditor/js/ace/theme-merbivore_soft.js +0 -0
  422. package/src/sap/ui/codeeditor/js/ace/theme-mono_industrial.js +0 -0
  423. package/src/sap/ui/codeeditor/js/ace/theme-monokai.js +0 -0
  424. package/src/sap/ui/codeeditor/js/ace/theme-pastel_on_dark.js +0 -0
  425. package/src/sap/ui/codeeditor/js/ace/theme-solarized_dark.js +1 -1
  426. package/src/sap/ui/codeeditor/js/ace/theme-solarized_light.js +0 -0
  427. package/src/sap/ui/codeeditor/js/ace/theme-sqlserver.js +0 -0
  428. package/src/sap/ui/codeeditor/js/ace/theme-terminal.js +0 -0
  429. package/src/sap/ui/codeeditor/js/ace/theme-textmate.js +0 -0
  430. package/src/sap/ui/codeeditor/js/ace/theme-tomorrow.js +0 -0
  431. package/src/sap/ui/codeeditor/js/ace/theme-tomorrow_night.js +0 -0
  432. package/src/sap/ui/codeeditor/js/ace/theme-tomorrow_night_blue.js +0 -0
  433. package/src/sap/ui/codeeditor/js/ace/theme-tomorrow_night_bright.js +0 -0
  434. package/src/sap/ui/codeeditor/js/ace/theme-tomorrow_night_eighties.js +0 -0
  435. package/src/sap/ui/codeeditor/js/ace/theme-twilight.js +0 -0
  436. package/src/sap/ui/codeeditor/js/ace/theme-vibrant_ink.js +0 -0
  437. package/src/sap/ui/codeeditor/js/ace/theme-xcode.js +0 -0
  438. package/src/sap/ui/codeeditor/js/ace/worker-base.js +3 -13
  439. package/src/sap/ui/codeeditor/js/ace/worker-coffee.js +3 -13
  440. package/src/sap/ui/codeeditor/js/ace/worker-css.js +3 -13
  441. package/src/sap/ui/codeeditor/js/ace/worker-html.js +3 -13
  442. package/src/sap/ui/codeeditor/js/ace/worker-javascript.js +3 -13
  443. package/src/sap/ui/codeeditor/js/ace/worker-json.js +3 -13
  444. package/src/sap/ui/codeeditor/js/ace/worker-lua.js +3 -13
  445. package/src/sap/ui/codeeditor/js/ace/worker-php.js +3 -13
  446. package/src/sap/ui/codeeditor/js/ace/worker-xml.js +8 -15
  447. package/src/sap/ui/codeeditor/js/ace/worker-xquery.js +3 -13
  448. package/src/sap/ui/codeeditor/js/ace/worker-yaml.js +6 -16
  449. package/src/sap/ui/codeeditor/library.js +2 -2
  450. package/LICENSES/LicenseRef-tzdata-PublicDomain.txt +0 -5
@@ -196,7 +196,7 @@ CodeMirror.lookupKey = function lookupKey(key, map, handle) {
196
196
  if (!map)
197
197
  map = "default";
198
198
  if (typeof map == "string")
199
- map = CodeMirror.keyMap[map];
199
+ map = CodeMirror.keyMap[map] || CodeMirror.keyMap['default'];
200
200
  var found = typeof map == "function" ? map(key) : map[key];
201
201
  if (found === false)
202
202
  return "nothing";
@@ -240,6 +240,9 @@ CodeMirror.isWordChar = function (ch) {
240
240
  return this.ace.inVirtualSelectionMode && this.ace.selection.index;
241
241
  };
242
242
  this.onChange = function (delta) {
243
+ if (this.$lineHandleChanges) {
244
+ this.$lineHandleChanges.push(delta);
245
+ }
243
246
  var change = { text: delta.action[0] == 'i' ? delta.lines : [] };
244
247
  var curOp = this.curOp = this.curOp || {};
245
248
  if (!curOp.changeHandlers)
@@ -412,7 +415,10 @@ CodeMirror.isWordChar = function (ch) {
412
415
  }
413
416
  if (cmp === 0) {
414
417
  if (isInsert) {
415
- if (point.bias == 1) {
418
+ if (!point.$insertRight) {
419
+ cmp = 1;
420
+ }
421
+ else if (point.bias == 1) {
416
422
  cmp = 1;
417
423
  }
418
424
  else {
@@ -578,9 +584,10 @@ CodeMirror.isWordChar = function (ch) {
578
584
  };
579
585
  this.replaceSelection =
580
586
  this.replaceSelections = function (p) {
587
+ var strings = Array.isArray(p) && p;
581
588
  var sel = this.ace.selection;
582
589
  if (this.ace.inVirtualSelectionMode) {
583
- this.ace.session.replace(sel.getRange(), p[0] || "");
590
+ this.ace.session.replace(sel.getRange(), strings ? p[0] || "" : p);
584
591
  return;
585
592
  }
586
593
  sel.inVirtualSelectionMode = true;
@@ -588,7 +595,7 @@ CodeMirror.isWordChar = function (ch) {
588
595
  if (!ranges.length)
589
596
  ranges = [this.ace.multiSelect.getRange()];
590
597
  for (var i = ranges.length; i--;)
591
- this.ace.session.replace(ranges[i], p[i] || "");
598
+ this.ace.session.replace(ranges[i], strings ? p[i] || "" : p);
592
599
  sel.inVirtualSelectionMode = false;
593
600
  };
594
601
  this.getSelection = function () {
@@ -749,6 +756,9 @@ CodeMirror.isWordChar = function (ch) {
749
756
  }
750
757
  else {
751
758
  var m = this.ace.session.$findOpeningBracket(re.slice(-2, -1), { row: pos.line, column: pos.ch + 1 }, tokenRe);
759
+ if (!m && options.bracketRegex && options.bracketRegex.test(this.getLine(pos.line)[pos.ch - 1])) {
760
+ m = { row: pos.line, column: pos.ch - 1 };
761
+ }
752
762
  }
753
763
  return m && { pos: toCmPos(m) };
754
764
  };
@@ -766,11 +776,42 @@ CodeMirror.isWordChar = function (ch) {
766
776
  console.log(name + " is not implemented");
767
777
  };
768
778
  this.getLineNumber = function (handle) {
769
- return handle.row;
779
+ var deltas = this.$lineHandleChanges;
780
+ if (!deltas)
781
+ return null;
782
+ var row = handle.row;
783
+ for (var i = 0; i < deltas.length; i++) {
784
+ var delta = deltas[i];
785
+ if (delta.start.row != delta.end.row) {
786
+ if (delta.action[0] == "i") {
787
+ if (delta.start.row < row)
788
+ row += delta.end.row - delta.start.row;
789
+ }
790
+ else {
791
+ if (delta.start.row < row) {
792
+ if (row < delta.end.row || row == delta.end.row && delta.start.column > 0) {
793
+ return null;
794
+ }
795
+ row -= delta.end.row - delta.start.row;
796
+ }
797
+ }
798
+ }
799
+ }
800
+ return row;
770
801
  };
771
802
  this.getLineHandle = function (row) {
803
+ if (!this.$lineHandleChanges)
804
+ this.$lineHandleChanges = [];
772
805
  return { text: this.ace.session.getLine(row), row: row };
773
806
  };
807
+ this.releaseLineHandles = function () {
808
+ this.$lineHandleChanges = undefined;
809
+ };
810
+ this.getLastEditEnd = function () {
811
+ var undoManager = this.ace.session.$undoManager;
812
+ if (undoManager && undoManager.$lastDelta)
813
+ return toCmPos(undoManager.$lastDelta.end);
814
+ };
774
815
  }).call(CodeMirror.prototype);
775
816
  function toAcePos(cmPos) {
776
817
  return { row: cmPos.line, column: cmPos.ch };
@@ -986,24 +1027,6 @@ domLib.importCssString(".normal-mode .ace_cursor{\n border: none;\n backgr
986
1027
  });
987
1028
  })();
988
1029
  var Pos = CodeMirror.Pos;
989
- function transformCursor(cm, range) {
990
- var vim = cm.state.vim;
991
- if (!vim || vim.insertMode)
992
- return range.head;
993
- var head = vim.sel.head;
994
- if (!head)
995
- return range.head;
996
- if (vim.visualBlock) {
997
- if (range.head.line != head.line) {
998
- return;
999
- }
1000
- }
1001
- if (range.from() == range.anchor && !range.empty()) {
1002
- if (range.head.line == head.line && range.head.ch != head.ch)
1003
- return new Pos(range.head.line, range.head.ch - 1);
1004
- }
1005
- return range.head;
1006
- }
1007
1030
  function updateSelectionForSurrogateCharacters(cm, curStart, curEnd) {
1008
1031
  if (curStart.line === curEnd.line && curStart.ch >= curEnd.ch - 1) {
1009
1032
  var text = cm.getLine(curStart.line);
@@ -1022,19 +1045,19 @@ var defaultKeymap = [
1022
1045
  { keys: 'g<Up>', type: 'keyToKey', toKeys: 'gk' },
1023
1046
  { keys: 'g<Down>', type: 'keyToKey', toKeys: 'gj' },
1024
1047
  { keys: '<Space>', type: 'keyToKey', toKeys: 'l' },
1025
- { keys: '<BS>', type: 'keyToKey', toKeys: 'h', context: 'normal' },
1026
- { keys: '<Del>', type: 'keyToKey', toKeys: 'x', context: 'normal' },
1048
+ { keys: '<BS>', type: 'keyToKey', toKeys: 'h' },
1049
+ { keys: '<Del>', type: 'keyToKey', toKeys: 'x' },
1027
1050
  { keys: '<C-Space>', type: 'keyToKey', toKeys: 'W' },
1028
- { keys: '<C-BS>', type: 'keyToKey', toKeys: 'B', context: 'normal' },
1051
+ { keys: '<C-BS>', type: 'keyToKey', toKeys: 'B' },
1029
1052
  { keys: '<S-Space>', type: 'keyToKey', toKeys: 'w' },
1030
- { keys: '<S-BS>', type: 'keyToKey', toKeys: 'b', context: 'normal' },
1053
+ { keys: '<S-BS>', type: 'keyToKey', toKeys: 'b' },
1031
1054
  { keys: '<C-n>', type: 'keyToKey', toKeys: 'j' },
1032
1055
  { keys: '<C-p>', type: 'keyToKey', toKeys: 'k' },
1033
1056
  { keys: '<C-[>', type: 'keyToKey', toKeys: '<Esc>' },
1034
1057
  { keys: '<C-c>', type: 'keyToKey', toKeys: '<Esc>' },
1035
1058
  { keys: '<C-[>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
1036
1059
  { keys: '<C-c>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
1037
- { keys: '<C-Esc>', type: 'keyToKey', toKeys: '<Esc>' },
1060
+ { keys: '<C-Esc>', type: 'keyToKey', toKeys: '<Esc>' }, // ipad keyboard sends C-Esc instead of C-[
1038
1061
  { keys: '<C-Esc>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
1039
1062
  { keys: 's', type: 'keyToKey', toKeys: 'cl', context: 'normal' },
1040
1063
  { keys: 's', type: 'keyToKey', toKeys: 'c', context: 'visual' },
@@ -1090,8 +1113,8 @@ var defaultKeymap = [
1090
1113
  { keys: 'T<character>', type: 'motion', motion: 'moveTillCharacter', motionArgs: { forward: false } },
1091
1114
  { keys: ';', type: 'motion', motion: 'repeatLastCharacterSearch', motionArgs: { forward: true } },
1092
1115
  { keys: ',', type: 'motion', motion: 'repeatLastCharacterSearch', motionArgs: { forward: false } },
1093
- { keys: '\'<character>', type: 'motion', motion: 'goToMark', motionArgs: { toJumplist: true, linewise: true } },
1094
- { keys: '`<character>', type: 'motion', motion: 'goToMark', motionArgs: { toJumplist: true } },
1116
+ { keys: '\'<register>', type: 'motion', motion: 'goToMark', motionArgs: { toJumplist: true, linewise: true } },
1117
+ { keys: '`<register>', type: 'motion', motion: 'goToMark', motionArgs: { toJumplist: true } },
1095
1118
  { keys: ']`', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true } },
1096
1119
  { keys: '[`', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false } },
1097
1120
  { keys: ']\'', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true, linewise: true } },
@@ -1116,6 +1139,8 @@ var defaultKeymap = [
1116
1139
  { keys: 'N', type: 'motion', motion: 'findNext', motionArgs: { forward: false, toJumplist: true } },
1117
1140
  { keys: 'gn', type: 'motion', motion: 'findAndSelectNextInclusive', motionArgs: { forward: true } },
1118
1141
  { keys: 'gN', type: 'motion', motion: 'findAndSelectNextInclusive', motionArgs: { forward: false } },
1142
+ { keys: 'gq', type: 'operator', operator: 'hardWrap' },
1143
+ { keys: 'gw', type: 'operator', operator: 'hardWrap', operatorArgs: { keepCursor: true } },
1119
1144
  { keys: 'x', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: true }, operatorMotionArgs: { visualLine: false } },
1120
1145
  { keys: 'X', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: false }, operatorMotionArgs: { visualLine: true } },
1121
1146
  { keys: 'D', type: 'operatorMotion', operator: 'delete', motion: 'moveToEol', motionArgs: { inclusive: true }, context: 'normal' },
@@ -1153,16 +1178,18 @@ var defaultKeymap = [
1153
1178
  { keys: 'p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: true, isEdit: true } },
1154
1179
  { keys: 'P', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: false, isEdit: true } },
1155
1180
  { keys: 'r<character>', type: 'action', action: 'replace', isEdit: true },
1156
- { keys: '@<character>', type: 'action', action: 'replayMacro' },
1157
- { keys: 'q<character>', type: 'action', action: 'enterMacroRecordMode' },
1181
+ { keys: '@<register>', type: 'action', action: 'replayMacro' },
1182
+ { keys: 'q<register>', type: 'action', action: 'enterMacroRecordMode' },
1158
1183
  { keys: 'R', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { replace: true }, context: 'normal' },
1159
1184
  { keys: 'R', type: 'operator', operator: 'change', operatorArgs: { linewise: true, fullLine: true }, context: 'visual', exitVisualBlock: true },
1160
1185
  { keys: 'u', type: 'action', action: 'undo', context: 'normal' },
1161
1186
  { keys: 'u', type: 'operator', operator: 'changeCase', operatorArgs: { toLower: true }, context: 'visual', isEdit: true },
1162
1187
  { keys: 'U', type: 'operator', operator: 'changeCase', operatorArgs: { toLower: false }, context: 'visual', isEdit: true },
1163
1188
  { keys: '<C-r>', type: 'action', action: 'redo' },
1164
- { keys: 'm<character>', type: 'action', action: 'setMark' },
1165
- { keys: '"<character>', type: 'action', action: 'setRegister' },
1189
+ { keys: 'm<register>', type: 'action', action: 'setMark' },
1190
+ { keys: '"<register>', type: 'action', action: 'setRegister' },
1191
+ { keys: '<C-r><register>', type: 'action', action: 'insertRegister', context: 'insert', isEdit: true },
1192
+ { keys: '<C-o>', type: 'action', action: 'oneNormalCommand', context: 'insert' },
1166
1193
  { keys: 'zz', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' } },
1167
1194
  { keys: 'z.', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' }, motion: 'moveToFirstNonWhiteSpaceCharacter' },
1168
1195
  { keys: 'zt', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' } },
@@ -1174,8 +1201,8 @@ var defaultKeymap = [
1174
1201
  { keys: '<C-x>', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: { increase: false, backtrack: false } },
1175
1202
  { keys: '<C-t>', type: 'action', action: 'indent', actionArgs: { indentRight: true }, context: 'insert' },
1176
1203
  { keys: '<C-d>', type: 'action', action: 'indent', actionArgs: { indentRight: false }, context: 'insert' },
1177
- { keys: 'a<character>', type: 'motion', motion: 'textObjectManipulation' },
1178
- { keys: 'i<character>', type: 'motion', motion: 'textObjectManipulation', motionArgs: { textObjectInner: true } },
1204
+ { keys: 'a<register>', type: 'motion', motion: 'textObjectManipulation' },
1205
+ { keys: 'i<register>', type: 'motion', motion: 'textObjectManipulation', motionArgs: { textObjectInner: true } },
1179
1206
  { keys: '/', type: 'search', searchArgs: { forward: true, querySrc: 'prompt', toJumplist: true } },
1180
1207
  { keys: '?', type: 'search', searchArgs: { forward: false, querySrc: 'prompt', toJumplist: true } },
1181
1208
  { keys: '*', type: 'search', searchArgs: { forward: true, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true } },
@@ -1191,7 +1218,18 @@ var defaultExCommandMap = [
1191
1218
  { name: 'imap', shortName: 'im' },
1192
1219
  { name: 'nmap', shortName: 'nm' },
1193
1220
  { name: 'vmap', shortName: 'vm' },
1221
+ { name: 'omap', shortName: 'om' },
1222
+ { name: 'noremap', shortName: 'no' },
1223
+ { name: 'nnoremap', shortName: 'nn' },
1224
+ { name: 'vnoremap', shortName: 'vn' },
1225
+ { name: 'inoremap', shortName: 'ino' },
1226
+ { name: 'onoremap', shortName: 'ono' },
1194
1227
  { name: 'unmap' },
1228
+ { name: 'mapclear', shortName: 'mapc' },
1229
+ { name: 'nmapclear', shortName: 'nmapc' },
1230
+ { name: 'vmapclear', shortName: 'vmapc' },
1231
+ { name: 'imapclear', shortName: 'imapc' },
1232
+ { name: 'omapclear', shortName: 'omapc' },
1195
1233
  { name: 'write', shortName: 'w' },
1196
1234
  { name: 'undo', shortName: 'u' },
1197
1235
  { name: 'redo', shortName: 'red' },
@@ -1200,13 +1238,18 @@ var defaultExCommandMap = [
1200
1238
  { name: 'setglobal', shortName: 'setg' },
1201
1239
  { name: 'sort', shortName: 'sor' },
1202
1240
  { name: 'substitute', shortName: 's', possiblyAsync: true },
1241
+ { name: 'startinsert', shortName: 'start' },
1203
1242
  { name: 'nohlsearch', shortName: 'noh' },
1204
1243
  { name: 'yank', shortName: 'y' },
1205
1244
  { name: 'delmarks', shortName: 'delm' },
1206
1245
  { name: 'registers', shortName: 'reg', excludeFromCommandHistory: true },
1207
1246
  { name: 'vglobal', shortName: 'v' },
1247
+ { name: 'delete', shortName: 'd' },
1248
+ { name: 'join', shortName: 'j' },
1249
+ { name: 'normal', shortName: 'norm' },
1208
1250
  { name: 'global', shortName: 'g' }
1209
1251
  ];
1252
+ var langmap = parseLangmap('');
1210
1253
  function enterVimMode(cm) {
1211
1254
  cm.setOption('disableInput', true);
1212
1255
  cm.setOption('showCursorWhenSelecting', false);
@@ -1223,82 +1266,6 @@ function leaveVimMode(cm) {
1223
1266
  if (highlightTimeout)
1224
1267
  clearTimeout(highlightTimeout);
1225
1268
  }
1226
- function detachVimMap(cm, next) {
1227
- if (this == CodeMirror.keyMap.vim) {
1228
- cm.options.$customCursor = null;
1229
- CodeMirror.rmClass(cm.getWrapperElement(), "cm-fat-cursor");
1230
- }
1231
- if (!next || next.attach != attachVimMap)
1232
- leaveVimMode(cm);
1233
- }
1234
- function attachVimMap(cm, prev) {
1235
- if (this == CodeMirror.keyMap.vim) {
1236
- if (cm.curOp)
1237
- cm.curOp.selectionChanged = true;
1238
- cm.options.$customCursor = transformCursor;
1239
- CodeMirror.addClass(cm.getWrapperElement(), "cm-fat-cursor");
1240
- }
1241
- if (!prev || prev.attach != attachVimMap)
1242
- enterVimMode(cm);
1243
- }
1244
- CodeMirror.defineOption('vimMode', false, function (cm, val, prev) {
1245
- if (val && cm.getOption("keyMap") != "vim")
1246
- cm.setOption("keyMap", "vim");
1247
- else if (!val && prev != CodeMirror.Init && /^vim/.test(cm.getOption("keyMap")))
1248
- cm.setOption("keyMap", "default");
1249
- });
1250
- function cmKey(key, cm) {
1251
- if (!cm) {
1252
- return undefined;
1253
- }
1254
- if (this[key]) {
1255
- return this[key];
1256
- }
1257
- var vimKey = cmKeyToVimKey(key);
1258
- if (!vimKey) {
1259
- return false;
1260
- }
1261
- var cmd = vimApi.findKey(cm, vimKey);
1262
- if (typeof cmd == 'function') {
1263
- CodeMirror.signal(cm, 'vim-keypress', vimKey);
1264
- }
1265
- return cmd;
1266
- }
1267
- var modifiers = { Shift: 'S', Ctrl: 'C', Alt: 'A', Cmd: 'D', Mod: 'A', CapsLock: '' };
1268
- var specialKeys = { Enter: 'CR', Backspace: 'BS', Delete: 'Del', Insert: 'Ins' };
1269
- function cmKeyToVimKey(key) {
1270
- if (key.charAt(0) == '\'') {
1271
- return key.charAt(1);
1272
- }
1273
- var pieces = key.split(/-(?!$)/);
1274
- var lastPiece = pieces[pieces.length - 1];
1275
- if (pieces.length == 1 && pieces[0].length == 1) {
1276
- return false;
1277
- }
1278
- else if (pieces.length == 2 && pieces[0] == 'Shift' && lastPiece.length == 1) {
1279
- return false;
1280
- }
1281
- var hasCharacter = false;
1282
- for (var i = 0; i < pieces.length; i++) {
1283
- var piece = pieces[i];
1284
- if (piece in modifiers) {
1285
- pieces[i] = modifiers[piece];
1286
- }
1287
- else {
1288
- hasCharacter = true;
1289
- }
1290
- if (piece in specialKeys) {
1291
- pieces[i] = specialKeys[piece];
1292
- }
1293
- }
1294
- if (!hasCharacter) {
1295
- return false;
1296
- }
1297
- if (isUpperCase(lastPiece)) {
1298
- pieces[pieces.length - 1] = lastPiece.toLowerCase();
1299
- }
1300
- return '<' + pieces.join('-') + '>';
1301
- }
1302
1269
  function getOnPasteFn(cm) {
1303
1270
  var vim = cm.state.vim;
1304
1271
  if (!vim.onPasteFn) {
@@ -1317,18 +1284,9 @@ var wordCharTest = [CodeMirror.isWordChar, function (ch) {
1317
1284
  }], bigWordCharTest = [function (ch) {
1318
1285
  return /\S/.test(ch);
1319
1286
  }];
1320
- function makeKeyRange(start, size) {
1321
- var keys = [];
1322
- for (var i = start; i < start + size; i++) {
1323
- keys.push(String.fromCharCode(i));
1324
- }
1325
- return keys;
1326
- }
1327
- var upperCaseAlphabet = makeKeyRange(65, 26);
1328
- var lowerCaseAlphabet = makeKeyRange(97, 26);
1329
- var numbers = makeKeyRange(48, 10);
1330
- var validMarks = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['<', '>']);
1331
- var validRegisters = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['-', '"', '.', ':', '_', '/', '+']);
1287
+ var validMarks = ['<', '>'];
1288
+ var validRegisters = ['-', '"', '.', ':', '_', '/', '+'];
1289
+ var latinCharRegex = /^\w$/;
1332
1290
  var upperCaseChars;
1333
1291
  try {
1334
1292
  upperCaseChars = new RegExp("^[\\p{Lu}]$", "u");
@@ -1454,6 +1412,21 @@ defineOption('filetype', undefined, 'string', ['ft'], function (name, cm) {
1454
1412
  cm.setOption('mode', mode);
1455
1413
  }
1456
1414
  });
1415
+ defineOption('textwidth', 80, 'number', ['tw'], function (width, cm) {
1416
+ if (cm === undefined) {
1417
+ return;
1418
+ }
1419
+ if (width === undefined) {
1420
+ var value = cm.getOption('textwidth');
1421
+ return value;
1422
+ }
1423
+ else {
1424
+ var column = Math.round(width);
1425
+ if (column > 1) {
1426
+ cm.setOption('textwidth', column);
1427
+ }
1428
+ }
1429
+ });
1457
1430
  var createCircularJumpList = function () {
1458
1431
  var size = 100;
1459
1432
  var pointer = -1;
@@ -1519,7 +1492,7 @@ var createCircularJumpList = function () {
1519
1492
  return mark && mark.find();
1520
1493
  }
1521
1494
  return {
1522
- cachedCursor: undefined,
1495
+ cachedCursor: undefined, //used for # and * jumps
1523
1496
  add: add,
1524
1497
  find: find,
1525
1498
  move: move
@@ -1578,6 +1551,7 @@ function maybeInitVimState(cm) {
1578
1551
  lastMotion: null,
1579
1552
  marks: {},
1580
1553
  insertMode: false,
1554
+ insertModeReturn: false,
1581
1555
  insertModeRepeat: undefined,
1582
1556
  visualMode: false,
1583
1557
  visualLine: false,
@@ -1585,7 +1559,8 @@ function maybeInitVimState(cm) {
1585
1559
  lastSelection: null,
1586
1560
  lastPastedText: null,
1587
1561
  sel: {},
1588
- options: {}
1562
+ options: {},
1563
+ expectLiteralNext: false
1589
1564
  };
1590
1565
  }
1591
1566
  return cm.state.vim;
@@ -1631,30 +1606,7 @@ var vimApi = {
1631
1606
  return exCommandDispatcher.unmap(lhs, ctx);
1632
1607
  },
1633
1608
  noremap: function (lhs, rhs, ctx) {
1634
- function toCtxArray(ctx) {
1635
- return ctx ? [ctx] : ['normal', 'insert', 'visual'];
1636
- }
1637
- var ctxsToMap = toCtxArray(ctx);
1638
- var actualLength = defaultKeymap.length, origLength = defaultKeymapLength;
1639
- for (var i = actualLength - origLength; i < actualLength && ctxsToMap.length; i++) {
1640
- var mapping = defaultKeymap[i];
1641
- if (mapping.keys == rhs &&
1642
- (!ctx || !mapping.context || mapping.context === ctx) &&
1643
- mapping.type.substr(0, 2) !== 'ex' &&
1644
- mapping.type.substr(0, 3) !== 'key') {
1645
- var newMapping = {};
1646
- for (var key in mapping) {
1647
- newMapping[key] = mapping[key];
1648
- }
1649
- newMapping.keys = lhs;
1650
- if (ctx && !newMapping.context) {
1651
- newMapping.context = ctx;
1652
- }
1653
- this._mapCommand(newMapping);
1654
- var mappedCtxs = toCtxArray(mapping.context);
1655
- ctxsToMap = ctxsToMap.filter(function (el) { return mappedCtxs.indexOf(el) === -1; });
1656
- }
1657
- }
1609
+ exCommandDispatcher.map(lhs, rhs, ctx, true);
1658
1610
  },
1659
1611
  mapclear: function (ctx) {
1660
1612
  var actualLength = defaultKeymap.length, origLength = defaultKeymapLength;
@@ -1684,6 +1636,8 @@ var vimApi = {
1684
1636
  }
1685
1637
  }
1686
1638
  },
1639
+ langmap: updateLangmap,
1640
+ vimKeyFromEvent: vimKeyFromEvent,
1687
1641
  setOption: setOption,
1688
1642
  getOption: getOption,
1689
1643
  defineOption: defineOption,
@@ -1734,61 +1688,64 @@ var vimApi = {
1734
1688
  return true;
1735
1689
  }
1736
1690
  }
1737
- function doKeyToKey(keys) {
1738
- var match;
1739
- while (keys) {
1740
- match = (/<\w+-.+?>|<\w+>|./).exec(keys);
1741
- key = match[0];
1742
- keys = keys.substring(match.index + key.length);
1743
- vimApi.handleKey(cm, key, 'mapping');
1744
- }
1745
- }
1746
1691
  function handleKeyInsertMode() {
1747
1692
  if (handleEsc()) {
1748
1693
  return true;
1749
1694
  }
1750
- var keys = vim.inputState.keyBuffer = vim.inputState.keyBuffer + key;
1695
+ vim.inputState.keyBuffer.push(key);
1696
+ var keys = vim.inputState.keyBuffer.join("");
1751
1697
  var keysAreChars = key.length == 1;
1752
1698
  var match = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert');
1753
- while (keys.length > 1 && match.type != 'full') {
1754
- var keys = vim.inputState.keyBuffer = keys.slice(1);
1755
- var thisMatch = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert');
1756
- if (thisMatch.type != 'none') {
1757
- match = thisMatch;
1758
- }
1759
- }
1699
+ var changeQueue = vim.inputState.changeQueue;
1760
1700
  if (match.type == 'none') {
1761
1701
  clearInputState(cm);
1762
1702
  return false;
1763
1703
  }
1764
1704
  else if (match.type == 'partial') {
1705
+ if (match.expectLiteralNext)
1706
+ vim.expectLiteralNext = true;
1765
1707
  if (lastInsertModeKeyTimer) {
1766
1708
  window.clearTimeout(lastInsertModeKeyTimer);
1767
1709
  }
1768
- lastInsertModeKeyTimer = window.setTimeout(function () { if (vim.insertMode && vim.inputState.keyBuffer) {
1710
+ lastInsertModeKeyTimer = keysAreChars && window.setTimeout(function () { if (vim.insertMode && vim.inputState.keyBuffer.length) {
1769
1711
  clearInputState(cm);
1770
1712
  } }, getOption('insertModeEscKeysTimeout'));
1713
+ if (keysAreChars) {
1714
+ var selections = cm.listSelections();
1715
+ if (!changeQueue || changeQueue.removed.length != selections.length)
1716
+ changeQueue = vim.inputState.changeQueue = new ChangeQueue;
1717
+ changeQueue.inserted += key;
1718
+ for (var i = 0; i < selections.length; i++) {
1719
+ var from = cursorMin(selections[i].anchor, selections[i].head);
1720
+ var to = cursorMax(selections[i].anchor, selections[i].head);
1721
+ var text = cm.getRange(from, cm.state.overwrite ? offsetCursor(to, 0, 1) : to);
1722
+ changeQueue.removed[i] = (changeQueue.removed[i] || "") + text;
1723
+ }
1724
+ }
1771
1725
  return !keysAreChars;
1772
1726
  }
1727
+ vim.expectLiteralNext = false;
1773
1728
  if (lastInsertModeKeyTimer) {
1774
1729
  window.clearTimeout(lastInsertModeKeyTimer);
1775
1730
  }
1776
- if (keysAreChars) {
1731
+ if (match.command && changeQueue) {
1777
1732
  var selections = cm.listSelections();
1778
1733
  for (var i = 0; i < selections.length; i++) {
1779
1734
  var here = selections[i].head;
1780
- cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
1735
+ cm.replaceRange(changeQueue.removed[i] || "", offsetCursor(here, 0, -changeQueue.inserted.length), here, '+input');
1781
1736
  }
1782
1737
  vimGlobalState.macroModeState.lastInsertModeChanges.changes.pop();
1783
1738
  }
1784
- clearInputState(cm);
1739
+ if (!match.command)
1740
+ clearInputState(cm);
1785
1741
  return match.command;
1786
1742
  }
1787
1743
  function handleKeyNonInsertMode() {
1788
1744
  if (handleMacroRecording() || handleEsc()) {
1789
1745
  return true;
1790
1746
  }
1791
- var keys = vim.inputState.keyBuffer = vim.inputState.keyBuffer + key;
1747
+ vim.inputState.keyBuffer.push(key);
1748
+ var keys = vim.inputState.keyBuffer.join("");
1792
1749
  if (/^[1-9]\d*$/.test(keys)) {
1793
1750
  return true;
1794
1751
  }
@@ -1809,13 +1766,16 @@ var vimApi = {
1809
1766
  return false;
1810
1767
  }
1811
1768
  else if (match.type == 'partial') {
1769
+ if (match.expectLiteralNext)
1770
+ vim.expectLiteralNext = true;
1812
1771
  return true;
1813
1772
  }
1814
1773
  else if (match.type == 'clear') {
1815
1774
  clearInputState(cm);
1816
1775
  return true;
1817
1776
  }
1818
- vim.inputState.keyBuffer = '';
1777
+ vim.expectLiteralNext = false;
1778
+ vim.inputState.keyBuffer.length = 0;
1819
1779
  keysMatcher = /^(\d*)(.*)$/.exec(keys);
1820
1780
  if (keysMatcher[1] && keysMatcher[1] != '0') {
1821
1781
  vim.inputState.pushRepeatDigit(keysMatcher[1]);
@@ -1830,7 +1790,7 @@ var vimApi = {
1830
1790
  command = handleKeyNonInsertMode();
1831
1791
  }
1832
1792
  if (command === false) {
1833
- return undefined; //ace_patch
1793
+ return !vim.insertMode && key.length === 1 ? function () { return true; } : undefined;
1834
1794
  }
1835
1795
  else if (command === true) {
1836
1796
  return function () { return true; };
@@ -1843,7 +1803,7 @@ var vimApi = {
1843
1803
  cm.curOp.isVimOp = true;
1844
1804
  try {
1845
1805
  if (command.type == 'keyToKey') {
1846
- doKeyToKey(command.toKeys);
1806
+ doKeyToKey(cm, command.toKeys, command);
1847
1807
  }
1848
1808
  else {
1849
1809
  commandDispatcher.processCommand(cm, vim, command);
@@ -1874,6 +1834,210 @@ var vimApi = {
1874
1834
  exitVisualMode: exitVisualMode,
1875
1835
  exitInsertMode: exitInsertMode
1876
1836
  };
1837
+ var keyToKeyStack = [];
1838
+ var noremap = false;
1839
+ var virtualPrompt;
1840
+ function sendKeyToPrompt(key) {
1841
+ if (key[0] == "<") {
1842
+ var lowerKey = key.toLowerCase().slice(1, -1);
1843
+ var parts = lowerKey.split('-');
1844
+ lowerKey = parts.pop() || '';
1845
+ if (lowerKey == 'lt')
1846
+ key = '<';
1847
+ else if (lowerKey == 'space')
1848
+ key = ' ';
1849
+ else if (lowerKey == 'cr')
1850
+ key = '\n';
1851
+ else if (vimToCmKeyMap[lowerKey]) {
1852
+ var value = virtualPrompt.value;
1853
+ var event = {
1854
+ key: vimToCmKeyMap[lowerKey],
1855
+ target: {
1856
+ value: value,
1857
+ selectionEnd: value.length,
1858
+ selectionStart: value.length
1859
+ }
1860
+ };
1861
+ if (virtualPrompt.onKeyDown) {
1862
+ virtualPrompt.onKeyDown(event, virtualPrompt.value, close);
1863
+ }
1864
+ if (virtualPrompt && virtualPrompt.onKeyUp) {
1865
+ virtualPrompt.onKeyUp(event, virtualPrompt.value, close);
1866
+ }
1867
+ return;
1868
+ }
1869
+ }
1870
+ if (key == '\n') {
1871
+ var prompt = virtualPrompt;
1872
+ virtualPrompt = null;
1873
+ prompt.onClose && prompt.onClose(prompt.value);
1874
+ }
1875
+ else {
1876
+ virtualPrompt.value = (virtualPrompt.value || '') + key;
1877
+ }
1878
+ function close(value) {
1879
+ if (typeof value == 'string') {
1880
+ virtualPrompt.value = value;
1881
+ }
1882
+ else {
1883
+ virtualPrompt = null;
1884
+ }
1885
+ }
1886
+ }
1887
+ function doKeyToKey(cm, keys, fromKey) {
1888
+ var noremapBefore = noremap;
1889
+ if (fromKey) {
1890
+ if (keyToKeyStack.indexOf(fromKey) != -1)
1891
+ return;
1892
+ keyToKeyStack.push(fromKey);
1893
+ noremap = fromKey.noremap != false;
1894
+ }
1895
+ try {
1896
+ var vim = maybeInitVimState(cm);
1897
+ var keyRe = /<(?:[CSMA]-)*\w+>|./gi;
1898
+ var match;
1899
+ while ((match = keyRe.exec(keys))) {
1900
+ var key = match[0];
1901
+ var wasInsert = vim.insertMode;
1902
+ if (virtualPrompt) {
1903
+ sendKeyToPrompt(key);
1904
+ continue;
1905
+ }
1906
+ var result = vimApi.handleKey(cm, key, 'mapping');
1907
+ if (!result && wasInsert && vim.insertMode) {
1908
+ if (key[0] == "<") {
1909
+ var lowerKey = key.toLowerCase().slice(1, -1);
1910
+ var parts = lowerKey.split('-');
1911
+ lowerKey = parts.pop() || '';
1912
+ if (lowerKey == 'lt')
1913
+ key = '<';
1914
+ else if (lowerKey == 'space')
1915
+ key = ' ';
1916
+ else if (lowerKey == 'cr')
1917
+ key = '\n';
1918
+ else if (vimToCmKeyMap.hasOwnProperty(lowerKey)) {
1919
+ key = vimToCmKeyMap[lowerKey];
1920
+ sendCmKey(cm, key);
1921
+ continue;
1922
+ }
1923
+ else {
1924
+ key = key[0];
1925
+ keyRe.lastIndex = match.index + 1;
1926
+ }
1927
+ }
1928
+ cm.replaceSelection(key);
1929
+ }
1930
+ }
1931
+ }
1932
+ finally {
1933
+ keyToKeyStack.pop();
1934
+ noremap = keyToKeyStack.length ? noremapBefore : false;
1935
+ if (!keyToKeyStack.length && virtualPrompt) {
1936
+ var promptOptions = virtualPrompt;
1937
+ virtualPrompt = null;
1938
+ showPrompt(cm, promptOptions);
1939
+ }
1940
+ }
1941
+ }
1942
+ var specialKey = {
1943
+ Return: 'CR', Backspace: 'BS', 'Delete': 'Del', Escape: 'Esc', Insert: 'Ins',
1944
+ ArrowLeft: 'Left', ArrowRight: 'Right', ArrowUp: 'Up', ArrowDown: 'Down',
1945
+ Enter: 'CR', ' ': 'Space'
1946
+ };
1947
+ var ignoredKeys = { Shift: 1, Alt: 1, Command: 1, Control: 1,
1948
+ CapsLock: 1, AltGraph: 1, Dead: 1, Unidentified: 1 };
1949
+ var vimToCmKeyMap = {};
1950
+ 'Left|Right|Up|Down|End|Home'.split('|').concat(Object.keys(specialKey)).forEach(function (x) {
1951
+ vimToCmKeyMap[(specialKey[x] || '').toLowerCase()]
1952
+ = vimToCmKeyMap[x.toLowerCase()] = x;
1953
+ });
1954
+ function vimKeyFromEvent(e, vim) {
1955
+ var key = e.key;
1956
+ if (ignoredKeys[key])
1957
+ return;
1958
+ if (key.length > 1 && key[0] == "n") {
1959
+ key = key.replace("Numpad", "");
1960
+ }
1961
+ key = specialKey[key] || key;
1962
+ var name = '';
1963
+ if (e.ctrlKey) {
1964
+ name += 'C-';
1965
+ }
1966
+ if (e.altKey) {
1967
+ name += 'A-';
1968
+ }
1969
+ if (e.metaKey) {
1970
+ name += 'M-';
1971
+ }
1972
+ if (CodeMirror.isMac && e.altKey && !e.metaKey && !e.ctrlKey) {
1973
+ name = name.slice(2);
1974
+ }
1975
+ if ((name || key.length > 1) && e.shiftKey) {
1976
+ name += 'S-';
1977
+ }
1978
+ if (vim && !vim.expectLiteralNext && key.length == 1) {
1979
+ if (langmap.keymap && key in langmap.keymap) {
1980
+ if (langmap.remapCtrl != false || !name)
1981
+ key = langmap.keymap[key];
1982
+ }
1983
+ else if (key.charCodeAt(0) > 255) {
1984
+ var code = e.code && e.code.slice(-1) || "";
1985
+ if (!e.shiftKey)
1986
+ code = code.toLowerCase();
1987
+ if (code)
1988
+ key = code;
1989
+ }
1990
+ }
1991
+ name += key;
1992
+ if (name.length > 1) {
1993
+ name = '<' + name + '>';
1994
+ }
1995
+ return name;
1996
+ }
1997
+ ;
1998
+ function updateLangmap(langmapString, remapCtrl) {
1999
+ if (langmap.string !== langmapString) {
2000
+ langmap = parseLangmap(langmapString);
2001
+ }
2002
+ langmap.remapCtrl = remapCtrl;
2003
+ }
2004
+ function parseLangmap(langmapString) {
2005
+ var keymap = {};
2006
+ if (!langmapString)
2007
+ return { keymap: keymap, string: '' };
2008
+ function getEscaped(list) {
2009
+ return list.split(/\\?(.)/).filter(Boolean);
2010
+ }
2011
+ langmapString.split(/((?:[^\\,]|\\.)+),/).map(function (part) {
2012
+ if (!part)
2013
+ return;
2014
+ var semicolon = part.split(/((?:[^\\;]|\\.)+);/);
2015
+ if (semicolon.length == 3) {
2016
+ var from = getEscaped(semicolon[1]);
2017
+ var to = getEscaped(semicolon[2]);
2018
+ if (from.length !== to.length)
2019
+ return; // skip over malformed part
2020
+ for (var i = 0; i < from.length; ++i)
2021
+ keymap[from[i]] = to[i];
2022
+ }
2023
+ else if (semicolon.length == 1) {
2024
+ var pairs = getEscaped(part);
2025
+ if (pairs.length % 2 !== 0)
2026
+ return; // skip over malformed part
2027
+ for (var i = 0; i < pairs.length; i += 2)
2028
+ keymap[pairs[i]] = pairs[i + 1];
2029
+ }
2030
+ });
2031
+ return { keymap: keymap, string: langmapString };
2032
+ }
2033
+ defineOption('langmap', undefined, 'string', ['lmap'], function (name, cm) {
2034
+ if (name === undefined) {
2035
+ return langmap.string;
2036
+ }
2037
+ else {
2038
+ updateLangmap(name);
2039
+ }
2040
+ });
1877
2041
  function InputState() {
1878
2042
  this.prefixRepeat = [];
1879
2043
  this.motionRepeat = [];
@@ -1883,6 +2047,7 @@ function InputState() {
1883
2047
  this.motionArgs = null;
1884
2048
  this.keyBuffer = []; // For matching multi-key commands.
1885
2049
  this.registerName = null; // Defaults to the unnamed register.
2050
+ this.changeQueue = null; // For restoring text used by insert mode keybindings
1886
2051
  }
1887
2052
  InputState.prototype.pushRepeatDigit = function (n) {
1888
2053
  if (!this.operator) {
@@ -1907,8 +2072,13 @@ InputState.prototype.getRepeat = function () {
1907
2072
  };
1908
2073
  function clearInputState(cm, reason) {
1909
2074
  cm.state.vim.inputState = new InputState();
2075
+ cm.state.vim.expectLiteralNext = false;
1910
2076
  CodeMirror.signal(cm, 'vim-command-done', reason);
1911
2077
  }
2078
+ function ChangeQueue() {
2079
+ this.removed = [];
2080
+ this.inserted = "";
2081
+ }
1912
2082
  function Register(text, linewise, blockwise) {
1913
2083
  this.clear();
1914
2084
  this.keyBuffer = [text || ''];
@@ -2017,7 +2187,7 @@ RegisterController.prototype = {
2017
2187
  return this.registers[name];
2018
2188
  },
2019
2189
  isValidRegister: function (name) {
2020
- return name && inArray(name, validRegisters);
2190
+ return name && (inArray(name, validRegisters) || latinCharRegex.test(name));
2021
2191
  },
2022
2192
  shiftNumericRegisters_: function () {
2023
2193
  for (var i = 9; i >= 2; i--) {
@@ -2071,7 +2241,10 @@ var commandDispatcher = {
2071
2241
  return { type: 'none' };
2072
2242
  }
2073
2243
  else if (!matches.full && matches.partial) {
2074
- return { type: 'partial' };
2244
+ return {
2245
+ type: 'partial',
2246
+ expectLiteralNext: matches.partial.length == 1 && matches.partial[0].keys.slice(-11) == '<character>' // langmap literal logic
2247
+ };
2075
2248
  }
2076
2249
  var bestMatch;
2077
2250
  for (var i = 0; i < matches.full.length; i++) {
@@ -2080,7 +2253,7 @@ var commandDispatcher = {
2080
2253
  bestMatch = match;
2081
2254
  }
2082
2255
  }
2083
- if (bestMatch.keys.slice(-11) == '<character>') {
2256
+ if (bestMatch.keys.slice(-11) == '<character>' || bestMatch.keys.slice(-10) == '<register>') {
2084
2257
  var character = lastChar(keys);
2085
2258
  if (!character || character.length > 1)
2086
2259
  return { type: 'clear' };
@@ -2220,18 +2393,17 @@ var commandDispatcher = {
2220
2393
  }
2221
2394
  }
2222
2395
  function onPromptKeyUp(e, query, close) {
2223
- var keyName = CodeMirror.keyName(e), up, offset;
2224
- if (keyName == 'Up' || keyName == 'Down') {
2225
- up = keyName == 'Up' ? true : false;
2396
+ var keyName = vimKeyFromEvent(e), up, offset;
2397
+ if (keyName == '<Up>' || keyName == '<Down>') {
2398
+ up = keyName == '<Up>' ? true : false;
2226
2399
  offset = e.target ? e.target.selectionEnd : 0;
2227
2400
  query = vimGlobalState.searchHistoryController.nextMatch(query, up) || '';
2228
2401
  close(query);
2229
2402
  if (offset && e.target)
2230
2403
  e.target.selectionEnd = e.target.selectionStart = Math.min(offset, e.target.value.length);
2231
2404
  }
2232
- else {
2233
- if (keyName != 'Left' && keyName != 'Right' && keyName != 'Ctrl' && keyName != 'Alt' && keyName != 'Shift')
2234
- vimGlobalState.searchHistoryController.reset();
2405
+ else if (keyName && keyName != '<Left>' && keyName != '<Right>') {
2406
+ vimGlobalState.searchHistoryController.reset();
2235
2407
  }
2236
2408
  var parsedQuery;
2237
2409
  try {
@@ -2248,9 +2420,9 @@ var commandDispatcher = {
2248
2420
  }
2249
2421
  }
2250
2422
  function onPromptKeyDown(e, query, close) {
2251
- var keyName = CodeMirror.keyName(e);
2252
- if (keyName == 'Esc' || keyName == 'Ctrl-C' || keyName == 'Ctrl-[' ||
2253
- (keyName == 'Backspace' && query == '')) {
2423
+ var keyName = vimKeyFromEvent(e);
2424
+ if (keyName == '<Esc>' || keyName == '<C-c>' || keyName == '<C-[>' ||
2425
+ (keyName == '<BS>' && query == '')) {
2254
2426
  vimGlobalState.searchHistoryController.pushInput(query);
2255
2427
  vimGlobalState.searchHistoryController.reset();
2256
2428
  updateSearchQuery(cm, originalQuery);
@@ -2261,10 +2433,10 @@ var commandDispatcher = {
2261
2433
  close();
2262
2434
  cm.focus();
2263
2435
  }
2264
- else if (keyName == 'Up' || keyName == 'Down') {
2436
+ else if (keyName == '<Up>' || keyName == '<Down>') {
2265
2437
  CodeMirror.e_stop(e);
2266
2438
  }
2267
- else if (keyName == 'Ctrl-U') {
2439
+ else if (keyName == '<C-u>') {
2268
2440
  CodeMirror.e_stop(e);
2269
2441
  close('');
2270
2442
  }
@@ -2287,13 +2459,15 @@ var commandDispatcher = {
2287
2459
  }
2288
2460
  break;
2289
2461
  case 'wordUnderCursor':
2290
- var word = expandWordUnderCursor(cm, false /** inclusive */, true /** forward */, false /** bigWord */, true /** noSymbol */);
2462
+ var word = expandWordUnderCursor(cm, { noSymbol: true });
2291
2463
  var isKeyword = true;
2292
2464
  if (!word) {
2293
- word = expandWordUnderCursor(cm, false /** inclusive */, true /** forward */, false /** bigWord */, false /** noSymbol */);
2465
+ word = expandWordUnderCursor(cm, { noSymbol: false });
2294
2466
  isKeyword = false;
2295
2467
  }
2296
2468
  if (!word) {
2469
+ showConfirm(cm, 'No word under cursor');
2470
+ clearInputState(cm);
2297
2471
  return;
2298
2472
  }
2299
2473
  var query = cm.getLine(word.start.line).substring(word.start.ch, word.end.ch);
@@ -2318,9 +2492,9 @@ var commandDispatcher = {
2318
2492
  clearInputState(cm);
2319
2493
  }
2320
2494
  function onPromptKeyDown(e, input, close) {
2321
- var keyName = CodeMirror.keyName(e), up, offset;
2322
- if (keyName == 'Esc' || keyName == 'Ctrl-C' || keyName == 'Ctrl-[' ||
2323
- (keyName == 'Backspace' && input == '')) {
2495
+ var keyName = vimKeyFromEvent(e), up, offset;
2496
+ if (keyName == '<Esc>' || keyName == '<C-c>' || keyName == '<C-[>' ||
2497
+ (keyName == '<BS>' && input == '')) {
2324
2498
  vimGlobalState.exCommandHistoryController.pushInput(input);
2325
2499
  vimGlobalState.exCommandHistoryController.reset();
2326
2500
  CodeMirror.e_stop(e);
@@ -2328,22 +2502,21 @@ var commandDispatcher = {
2328
2502
  close();
2329
2503
  cm.focus();
2330
2504
  }
2331
- if (keyName == 'Up' || keyName == 'Down') {
2505
+ if (keyName == '<Up>' || keyName == '<Down>') {
2332
2506
  CodeMirror.e_stop(e);
2333
- up = keyName == 'Up' ? true : false;
2507
+ up = keyName == '<Up>' ? true : false;
2334
2508
  offset = e.target ? e.target.selectionEnd : 0;
2335
2509
  input = vimGlobalState.exCommandHistoryController.nextMatch(input, up) || '';
2336
2510
  close(input);
2337
2511
  if (offset && e.target)
2338
2512
  e.target.selectionEnd = e.target.selectionStart = Math.min(offset, e.target.value.length);
2339
2513
  }
2340
- else if (keyName == 'Ctrl-U') {
2514
+ else if (keyName == '<C-u>') {
2341
2515
  CodeMirror.e_stop(e);
2342
2516
  close('');
2343
2517
  }
2344
- else {
2345
- if (keyName != 'Left' && keyName != 'Right' && keyName != 'Ctrl' && keyName != 'Alt' && keyName != 'Shift')
2346
- vimGlobalState.exCommandHistoryController.reset();
2518
+ else if (keyName && keyName != '<Left>' && keyName != '<Right>') {
2519
+ vimGlobalState.exCommandHistoryController.reset();
2347
2520
  }
2348
2521
  }
2349
2522
  if (command.type == 'keyToEx') {
@@ -2794,9 +2967,9 @@ var motions = {
2794
2967
  moveByWords: function (cm, head, motionArgs) {
2795
2968
  return moveToWord(cm, head, motionArgs.repeat, !!motionArgs.forward, !!motionArgs.wordEnd, !!motionArgs.bigWord);
2796
2969
  },
2797
- moveTillCharacter: function (cm, _head, motionArgs) {
2970
+ moveTillCharacter: function (cm, head, motionArgs) {
2798
2971
  var repeat = motionArgs.repeat;
2799
- var curEnd = moveToCharacter(cm, repeat, motionArgs.forward, motionArgs.selectedCharacter);
2972
+ var curEnd = moveToCharacter(cm, repeat, motionArgs.forward, motionArgs.selectedCharacter, head);
2800
2973
  var increment = motionArgs.forward ? -1 : 1;
2801
2974
  recordLastCharacterSearch(increment, motionArgs);
2802
2975
  if (!curEnd)
@@ -2807,7 +2980,7 @@ var motions = {
2807
2980
  moveToCharacter: function (cm, head, motionArgs) {
2808
2981
  var repeat = motionArgs.repeat;
2809
2982
  recordLastCharacterSearch(0, motionArgs);
2810
- return moveToCharacter(cm, repeat, motionArgs.forward, motionArgs.selectedCharacter) || head;
2983
+ return moveToCharacter(cm, repeat, motionArgs.forward, motionArgs.selectedCharacter, head) || head;
2811
2984
  },
2812
2985
  moveToSymbol: function (cm, head, motionArgs) {
2813
2986
  var repeat = motionArgs.repeat;
@@ -2885,18 +3058,37 @@ var motions = {
2885
3058
  character = '{';
2886
3059
  }
2887
3060
  var inclusive = !motionArgs.textObjectInner;
2888
- var tmp;
3061
+ var tmp, move;
2889
3062
  if (mirroredPairs[character]) {
3063
+ move = true;
2890
3064
  tmp = selectCompanionObject(cm, head, character, inclusive);
3065
+ if (!tmp) {
3066
+ var sc = cm.getSearchCursor(new RegExp("\\" + character, "g"), head);
3067
+ if (sc.find()) {
3068
+ tmp = selectCompanionObject(cm, sc.from(), character, inclusive);
3069
+ }
3070
+ }
2891
3071
  }
2892
3072
  else if (selfPaired[character]) {
3073
+ move = true;
2893
3074
  tmp = findBeginningAndEnd(cm, head, character, inclusive);
2894
3075
  }
2895
- else if (character === 'W') {
2896
- tmp = expandWordUnderCursor(cm, inclusive, true /** forward */, true /** bigWord */);
2897
- }
2898
- else if (character === 'w') {
2899
- tmp = expandWordUnderCursor(cm, inclusive, true /** forward */, false /** bigWord */);
3076
+ else if (character === 'W' || character === 'w') {
3077
+ var repeat = motionArgs.repeat || 1;
3078
+ while (repeat-- > 0) {
3079
+ var repeated = expandWordUnderCursor(cm, {
3080
+ inclusive: inclusive,
3081
+ innerWord: !inclusive,
3082
+ bigWord: character === 'W',
3083
+ noSymbol: character === 'W',
3084
+ multiline: true
3085
+ }, tmp && tmp.end);
3086
+ if (repeated) {
3087
+ if (!tmp)
3088
+ tmp = repeated;
3089
+ tmp.end = repeated.end;
3090
+ }
3091
+ }
2900
3092
  }
2901
3093
  else if (character === 'p') {
2902
3094
  tmp = findParagraph(cm, head, motionArgs.repeat, 0, inclusive);
@@ -2930,14 +3122,14 @@ var motions = {
2930
3122
  }
2931
3123
  tmp = { start: start, end: end };
2932
3124
  }
2933
- else {
3125
+ if (!tmp) {
2934
3126
  return null;
2935
3127
  }
2936
3128
  if (!cm.state.vim.visualMode) {
2937
3129
  return [tmp.start, tmp.end];
2938
3130
  }
2939
3131
  else {
2940
- return expandSelection(cm, tmp.start, tmp.end);
3132
+ return expandSelection(cm, tmp.start, tmp.end, move);
2941
3133
  }
2942
3134
  },
2943
3135
  repeatLastCharacterSearch: function (cm, head, motionArgs) {
@@ -2981,21 +3173,13 @@ var operators = {
2981
3173
  text = text.slice(0, -match[0].length);
2982
3174
  }
2983
3175
  }
2984
- var prevLineEnd = new Pos(anchor.line - 1, Number.MAX_VALUE);
2985
- var wasLastLine = cm.firstLine() == cm.lastLine();
2986
- if (head.line > cm.lastLine() && args.linewise && !wasLastLine) {
2987
- cm.replaceRange('', prevLineEnd, head);
2988
- }
2989
- else {
2990
- cm.replaceRange('', anchor, head);
2991
- }
2992
3176
  if (args.linewise) {
2993
- if (!wasLastLine) {
2994
- cm.setCursor(prevLineEnd);
2995
- CodeMirror.commands.newlineAndIndent(cm);
3177
+ anchor = new Pos(anchor.line, findFirstNonWhiteSpaceCharacter(cm.getLine(anchor.line)));
3178
+ if (head.line > anchor.line) {
3179
+ head = new Pos(head.line - 1, Number.MAX_VALUE);
2996
3180
  }
2997
- anchor.ch = Number.MAX_VALUE;
2998
3181
  }
3182
+ cm.replaceRange('', anchor, head);
2999
3183
  finalHead = anchor;
3000
3184
  }
3001
3185
  else if (args.fullLine) {
@@ -3076,12 +3260,21 @@ var operators = {
3076
3260
  return motions.moveToFirstNonWhiteSpaceCharacter(cm, ranges[0].anchor);
3077
3261
  },
3078
3262
  indentAuto: function (cm, _args, ranges) {
3079
- if (ranges.length > 1) { // ace_patch
3080
- cm.setSelection(ranges[0].anchor, ranges[ranges.length - 1].head);
3081
- }
3082
3263
  cm.execCommand("indentAuto");
3083
3264
  return motions.moveToFirstNonWhiteSpaceCharacter(cm, ranges[0].anchor);
3084
3265
  },
3266
+ hardWrap: function (cm, operatorArgs, ranges, oldAnchor, newHead) {
3267
+ if (!cm.hardWrap)
3268
+ return;
3269
+ var from = ranges[0].anchor.line;
3270
+ var to = ranges[0].head.line;
3271
+ if (operatorArgs.linewise)
3272
+ to--;
3273
+ var endRow = cm.hardWrap({ from: from, to: to });
3274
+ if (endRow > from && operatorArgs.linewise)
3275
+ endRow--;
3276
+ return operatorArgs.keepCursor ? oldAnchor : new Pos(endRow, 0);
3277
+ },
3085
3278
  changeCase: function (cm, args, ranges, oldAnchor, newHead) {
3086
3279
  var selections = cm.getSelections();
3087
3280
  var swapped = [];
@@ -3310,6 +3503,9 @@ var actions = {
3310
3503
  }
3311
3504
  if (!vimGlobalState.macroModeState.isPlaying) {
3312
3505
  cm.on('change', onChange);
3506
+ if (vim.insertEnd)
3507
+ vim.insertEnd.clear();
3508
+ vim.insertEnd = cm.setBookmark(head, { insertLeft: true });
3313
3509
  CodeMirror.on(cm.getInputField(), 'keydown', onKeyEventTargetKeyDown);
3314
3510
  }
3315
3511
  if (vim.visualMode) {
@@ -3516,7 +3712,6 @@ var actions = {
3516
3712
  cur.ch += actionArgs.after ? 1 : 0;
3517
3713
  }
3518
3714
  var curPosFinal;
3519
- var idx;
3520
3715
  if (vim.visualMode) {
3521
3716
  vim.lastPastedText = text;
3522
3717
  var lastSelectionCurEnd;
@@ -3575,19 +3770,15 @@ var actions = {
3575
3770
  }
3576
3771
  else {
3577
3772
  cm.replaceRange(text, cur);
3578
- if (linewise && actionArgs.after) {
3579
- curPosFinal = new Pos(cur.line + 1, findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line + 1)));
3580
- }
3581
- else if (linewise && !actionArgs.after) {
3582
- curPosFinal = new Pos(cur.line, findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line)));
3583
- }
3584
- else if (!linewise && actionArgs.after) {
3585
- idx = cm.indexFromPos(cur);
3586
- curPosFinal = cm.posFromIndex(idx + text.length - 1);
3773
+ if (linewise) {
3774
+ var line = actionArgs.after ? cur.line + 1 : cur.line;
3775
+ curPosFinal = new Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line)));
3587
3776
  }
3588
3777
  else {
3589
- idx = cm.indexFromPos(cur);
3590
- curPosFinal = cm.posFromIndex(idx + text.length);
3778
+ curPosFinal = copyCursor(cur);
3779
+ if (!/\n/.test(text)) {
3780
+ curPosFinal.ch += text.length - (actionArgs.after ? 1 : 0);
3781
+ }
3591
3782
  }
3592
3783
  }
3593
3784
  }
@@ -3608,6 +3799,29 @@ var actions = {
3608
3799
  setRegister: function (_cm, actionArgs, vim) {
3609
3800
  vim.inputState.registerName = actionArgs.selectedCharacter;
3610
3801
  },
3802
+ insertRegister: function (cm, actionArgs, vim) {
3803
+ var registerName = actionArgs.selectedCharacter;
3804
+ var register = vimGlobalState.registerController.getRegister(registerName);
3805
+ var text = register && register.toString();
3806
+ if (text) {
3807
+ cm.replaceSelection(text);
3808
+ }
3809
+ },
3810
+ oneNormalCommand: function (cm, actionArgs, vim) {
3811
+ exitInsertMode(cm, true);
3812
+ vim.insertModeReturn = true;
3813
+ CodeMirror.on(cm, 'vim-command-done', function handler() {
3814
+ if (vim.visualMode)
3815
+ return;
3816
+ if (vim.insertModeReturn) {
3817
+ vim.insertModeReturn = false;
3818
+ if (!vim.insertMode) {
3819
+ actions.enterInsertMode(cm, {}, vim);
3820
+ }
3821
+ }
3822
+ CodeMirror.off(cm, 'vim-command-done', handler);
3823
+ });
3824
+ },
3611
3825
  setMark: function (cm, actionArgs, vim) {
3612
3826
  var markName = actionArgs.selectedCharacter;
3613
3827
  updateMark(cm, vim, markName, cm.getCursor());
@@ -3729,15 +3943,13 @@ function clipCursorToContent(cm, cur, oldCur) {
3729
3943
  var includeLineBreak = vim.insertMode || vim.visualMode;
3730
3944
  var line = Math.min(Math.max(cm.firstLine(), cur.line), cm.lastLine());
3731
3945
  var text = cm.getLine(line);
3732
- var maxCh = text.length - 1 + !!includeLineBreak;
3946
+ var maxCh = text.length - 1 + Number(!!includeLineBreak);
3733
3947
  var ch = Math.min(Math.max(0, cur.ch), maxCh);
3734
3948
  var charCode = text.charCodeAt(ch);
3735
- if (0xDC00 < charCode && charCode < 0xDFFF) {
3949
+ if (0xDC00 <= charCode && charCode <= 0xDFFF) {
3736
3950
  var direction = 1;
3737
- if (oldCur && oldCur.line == line) {
3738
- if (oldCur.ch > ch) {
3739
- direction = -1;
3740
- }
3951
+ if (oldCur && oldCur.line == line && oldCur.ch > ch) {
3952
+ direction = -1;
3741
3953
  }
3742
3954
  ch += direction;
3743
3955
  if (ch > maxCh)
@@ -3762,11 +3974,14 @@ function offsetCursor(cur, offsetLine, offsetCh) {
3762
3974
  return new Pos(cur.line + offsetLine, cur.ch + offsetCh);
3763
3975
  }
3764
3976
  function commandMatches(keys, keyMap, context, inputState) {
3977
+ if (inputState.operator)
3978
+ context = "operatorPending";
3765
3979
  var match, partial = [], full = [];
3766
- for (var i = 0; i < keyMap.length; i++) {
3980
+ var startIndex = noremap ? keyMap.length - defaultKeymapLength : 0;
3981
+ for (var i = startIndex; i < keyMap.length; i++) {
3767
3982
  var command = keyMap[i];
3768
3983
  if (context == 'insert' && command.context != 'insert' ||
3769
- command.context && command.context != context ||
3984
+ (command.context && command.context != context) ||
3770
3985
  inputState.operator && command.type == 'action' ||
3771
3986
  !(match = commandMatch(keys, command.keys))) {
3772
3987
  continue;
@@ -3784,8 +3999,10 @@ function commandMatches(keys, keyMap, context, inputState) {
3784
3999
  };
3785
4000
  }
3786
4001
  function commandMatch(pressed, mapped) {
3787
- if (mapped.slice(-11) == '<character>') {
3788
- var prefixLen = mapped.length - 11;
4002
+ var isLastCharacter = mapped.slice(-11) == '<character>';
4003
+ var isLastRegister = mapped.slice(-10) == '<register>';
4004
+ if (isLastCharacter || isLastRegister) {
4005
+ var prefixLen = mapped.length - (isLastCharacter ? 11 : 10);
3789
4006
  var pressedPrefix = pressed.slice(0, prefixLen);
3790
4007
  var mappedPrefix = mapped.slice(0, prefixLen);
3791
4008
  return pressedPrefix == mappedPrefix && pressed.length > prefixLen ? 'full' :
@@ -3992,10 +4209,10 @@ function updateLastSelection(cm, vim) {
3992
4209
  'visualLine': vim.visualLine,
3993
4210
  'visualBlock': vim.visualBlock };
3994
4211
  }
3995
- function expandSelection(cm, start, end) {
4212
+ function expandSelection(cm, start, end, move) {
3996
4213
  var sel = cm.state.vim.sel;
3997
- var head = sel.head;
3998
- var anchor = sel.anchor;
4214
+ var head = move ? start : sel.head;
4215
+ var anchor = move ? start : sel.anchor;
3999
4216
  var tmp;
4000
4217
  if (cursorIsBefore(end, start)) {
4001
4218
  tmp = end;
@@ -4129,50 +4346,76 @@ function findFirstNonWhiteSpaceCharacter(text) {
4129
4346
  var firstNonWS = text.search(/\S/);
4130
4347
  return firstNonWS == -1 ? text.length : firstNonWS;
4131
4348
  }
4132
- function expandWordUnderCursor(cm, inclusive, _forward, bigWord, noSymbol) {
4133
- var cur = getHead(cm);
4349
+ function expandWordUnderCursor(cm, _a, cursor) {
4350
+ var inclusive = _a.inclusive, innerWord = _a.innerWord, bigWord = _a.bigWord, noSymbol = _a.noSymbol, multiline = _a.multiline;
4351
+ var cur = cursor || getHead(cm);
4134
4352
  var line = cm.getLine(cur.line);
4353
+ var endLine = line;
4354
+ var startLineNumber = cur.line;
4355
+ var endLineNumber = startLineNumber;
4135
4356
  var idx = cur.ch;
4357
+ var wordOnNextLine;
4136
4358
  var test = noSymbol ? wordCharTest[0] : bigWordCharTest[0];
4137
- while (!test(line.charAt(idx))) {
4138
- idx++;
4139
- if (idx >= line.length) {
4140
- return null;
4141
- }
4142
- }
4143
- if (bigWord) {
4144
- test = bigWordCharTest[0];
4359
+ if (innerWord && /\s/.test(line.charAt(idx))) {
4360
+ test = function (ch) { return /\s/.test(ch); };
4145
4361
  }
4146
4362
  else {
4147
- test = wordCharTest[0];
4148
- if (!test(line.charAt(idx))) {
4149
- test = wordCharTest[1];
4363
+ while (!test(line.charAt(idx))) {
4364
+ idx++;
4365
+ if (idx >= line.length) {
4366
+ if (!multiline)
4367
+ return null;
4368
+ idx--;
4369
+ wordOnNextLine = findWord(cm, cur, true, bigWord, true);
4370
+ break;
4371
+ }
4372
+ }
4373
+ if (bigWord) {
4374
+ test = bigWordCharTest[0];
4375
+ }
4376
+ else {
4377
+ test = wordCharTest[0];
4378
+ if (!test(line.charAt(idx))) {
4379
+ test = wordCharTest[1];
4380
+ }
4150
4381
  }
4151
4382
  }
4152
4383
  var end = idx, start = idx;
4153
- while (test(line.charAt(end)) && end < line.length) {
4154
- end++;
4155
- }
4156
4384
  while (test(line.charAt(start)) && start >= 0) {
4157
4385
  start--;
4158
4386
  }
4159
4387
  start++;
4388
+ if (wordOnNextLine) {
4389
+ end = wordOnNextLine.to;
4390
+ endLineNumber = wordOnNextLine.line;
4391
+ endLine = cm.getLine(endLineNumber);
4392
+ if (!endLine && end == 0)
4393
+ end++;
4394
+ }
4395
+ else {
4396
+ while (test(line.charAt(end)) && end < line.length) {
4397
+ end++;
4398
+ }
4399
+ }
4160
4400
  if (inclusive) {
4161
4401
  var wordEnd = end;
4162
- while (/\s/.test(line.charAt(end)) && end < line.length) {
4163
- end++;
4402
+ var startsWithSpace = cur.ch <= start && /\s/.test(line.charAt(cur.ch));
4403
+ if (!startsWithSpace) {
4404
+ while (/\s/.test(endLine.charAt(end)) && end < endLine.length) {
4405
+ end++;
4406
+ }
4164
4407
  }
4165
- if (wordEnd == end) {
4408
+ if (wordEnd == end || startsWithSpace) {
4166
4409
  var wordStart = start;
4167
4410
  while (/\s/.test(line.charAt(start - 1)) && start > 0) {
4168
4411
  start--;
4169
4412
  }
4170
- if (!start) {
4413
+ if (!start && !startsWithSpace) {
4171
4414
  start = wordStart;
4172
4415
  }
4173
4416
  }
4174
4417
  }
4175
- return { start: new Pos(cur.line, start), end: new Pos(cur.line, end) };
4418
+ return { start: new Pos(startLineNumber, start), end: new Pos(endLineNumber, end) };
4176
4419
  }
4177
4420
  function expandTagUnderCursor(cm, head, inclusive) {
4178
4421
  var cur = head;
@@ -4431,8 +4674,8 @@ function moveToEol(cm, head, motionArgs, vim, keepHPos) {
4431
4674
  }
4432
4675
  return retval;
4433
4676
  }
4434
- function moveToCharacter(cm, repeat, forward, character) {
4435
- var cur = cm.getCursor();
4677
+ function moveToCharacter(cm, repeat, forward, character, head) {
4678
+ var cur = head || cm.getCursor();
4436
4679
  var start = cur.ch;
4437
4680
  var idx;
4438
4681
  for (var i = 0; i < repeat; i++) {
@@ -4450,7 +4693,7 @@ function moveToColumn(cm, repeat) {
4450
4693
  return clipCursorToContent(cm, new Pos(line, repeat - 1));
4451
4694
  }
4452
4695
  function updateMark(cm, vim, markName, pos) {
4453
- if (!inArray(markName, validMarks)) {
4696
+ if (!inArray(markName, validMarks) && !latinCharRegex.test(markName)) {
4454
4697
  return;
4455
4698
  }
4456
4699
  if (vim.marks[markName]) {
@@ -4775,9 +5018,8 @@ function selectCompanionObject(cm, head, symb, inclusive) {
4775
5018
  var offset = curChar === openSym ? 1 : 0;
4776
5019
  start = cm.scanForBracket(new Pos(cur.line, cur.ch + offset), -1, undefined, { 'bracketRegex': bracketRegexp });
4777
5020
  end = cm.scanForBracket(new Pos(cur.line, cur.ch + offset), 1, undefined, { 'bracketRegex': bracketRegexp });
4778
- if (!start || !end) {
4779
- return { start: cur, end: cur };
4780
- }
5021
+ if (!start || !end)
5022
+ return null;
4781
5023
  start = start.pos;
4782
5024
  end = end.pos;
4783
5025
  if ((start.line == end.line && start.ch > end.ch)
@@ -4804,8 +5046,13 @@ function findBeginningAndEnd(cm, head, symb, inclusive) {
4804
5046
  cur.ch = firstIndex;
4805
5047
  }
4806
5048
  else if (firstIndex < cur.ch && chars[cur.ch] == symb) {
4807
- end = cur.ch; // assign end to the current cursor
4808
- --cur.ch; // make sure to look backwards
5049
+ var stringAfter = /string/.test(cm.getTokenTypeAt(offsetCursor(head, 0, 1)));
5050
+ var stringBefore = /string/.test(cm.getTokenTypeAt(head));
5051
+ var isStringStart = stringAfter && !stringBefore;
5052
+ if (!isStringStart) {
5053
+ end = cur.ch; // assign end to the current cursor
5054
+ --cur.ch; // make sure to look backwards
5055
+ }
4809
5056
  }
4810
5057
  if (chars[cur.ch] == symb && !end) {
4811
5058
  start = cur.ch + 1; // assign start to ahead of the cursor
@@ -5057,10 +5304,16 @@ function showConfirm(cm, template) {
5057
5304
  }
5058
5305
  }
5059
5306
  function makePrompt(prefix, desc) {
5060
- return dom(document.createDocumentFragment(), dom('span', { $fontFamily: 'monospace', $whiteSpace: 'pre' }, prefix, dom('input', { type: 'text', autocorrect: 'off',
5061
- autocapitalize: 'off', spellcheck: 'false' })), desc && dom('span', { $color: '#888' }, desc));
5307
+ return dom('div', { $display: 'flex' }, dom('span', { $fontFamily: 'monospace', $whiteSpace: 'pre', $flex: 1 }, prefix, dom('input', { type: 'text', autocorrect: 'off',
5308
+ autocapitalize: 'off', spellcheck: 'false', $width: '100%' })), desc && dom('span', { $color: '#888' }, desc));
5062
5309
  }
5063
5310
  function showPrompt(cm, options) {
5311
+ if (keyToKeyStack.length) {
5312
+ if (!options.value)
5313
+ options.value = '';
5314
+ virtualPrompt = options;
5315
+ return;
5316
+ }
5064
5317
  var template = makePrompt(options.prefix, options.desc);
5065
5318
  if (cm.openDialog) {
5066
5319
  cm.openDialog(template, options.onClose, {
@@ -5144,10 +5397,13 @@ function searchOverlay(query) {
5144
5397
  var highlightTimeout = 0;
5145
5398
  function highlightSearchMatches(cm, query) {
5146
5399
  clearTimeout(highlightTimeout);
5400
+ var searchState = getSearchState(cm);
5401
+ searchState.highlightTimeout = highlightTimeout;
5147
5402
  highlightTimeout = setTimeout(function () {
5148
5403
  if (!cm.state.vim)
5149
5404
  return;
5150
5405
  var searchState = getSearchState(cm);
5406
+ searchState.highlightTimeout = null;
5151
5407
  var overlay = searchState.getOverlay();
5152
5408
  if (!overlay || query != overlay.query) {
5153
5409
  if (overlay) {
@@ -5217,6 +5473,10 @@ function findNextFromAndToInclusive(cm, prev, query, repeat, vim) {
5217
5473
  }
5218
5474
  function clearSearchHighlight(cm) {
5219
5475
  var state = getSearchState(cm);
5476
+ if (state.highlightTimeout) {
5477
+ clearTimeout(state.highlightTimeout);
5478
+ state.highlightTimeout = null;
5479
+ }
5220
5480
  cm.removeOverlay(getSearchState(cm).getOverlay());
5221
5481
  state.setOverlay(null);
5222
5482
  if (state.getScrollbarAnnotate()) {
@@ -5258,9 +5518,15 @@ function getMarkPos(cm, vim, markName) {
5258
5518
  return mark && mark.find();
5259
5519
  }
5260
5520
  function getLastEditPos(cm) {
5261
- var undoManager = cm.ace.session.$undoManager;
5262
- if (undoManager && undoManager.$lastDelta)
5263
- return toCmPos(undoManager.$lastDelta.end);
5521
+ if (cm.getLastEditEnd) {
5522
+ return cm.getLastEditEnd();
5523
+ }
5524
+ var done = cm.doc.history.done;
5525
+ for (var i = done.length; i--;) {
5526
+ if (done[i].changes) {
5527
+ return copyCursor(done[i].changes[0].to);
5528
+ }
5529
+ }
5264
5530
  }
5265
5531
  var ExCommandDispatcher = function () {
5266
5532
  this.buildCommandMap_();
@@ -5277,9 +5543,6 @@ ExCommandDispatcher.prototype = {
5277
5543
  var vim = cm.state.vim;
5278
5544
  var commandHistoryRegister = vimGlobalState.registerController.getRegister(':');
5279
5545
  var previousCommand = commandHistoryRegister.toString();
5280
- if (vim.visualMode) {
5281
- exitVisualMode(cm);
5282
- }
5283
5546
  var inputStream = new CodeMirror.StringStream(input);
5284
5547
  commandHistoryRegister.setText(input);
5285
5548
  var params = opt_params || {};
@@ -5291,6 +5554,9 @@ ExCommandDispatcher.prototype = {
5291
5554
  showConfirm(cm, e.toString());
5292
5555
  throw e;
5293
5556
  }
5557
+ if (vim.visualMode) {
5558
+ exitVisualMode(cm);
5559
+ }
5294
5560
  var command;
5295
5561
  var commandName;
5296
5562
  if (!params.commandName) {
@@ -5307,9 +5573,7 @@ ExCommandDispatcher.prototype = {
5307
5573
  }
5308
5574
  this.parseCommandArgs_(inputStream, params, command);
5309
5575
  if (command.type == 'exToKey') {
5310
- for (var i = 0; i < command.toKeys.length; i++) {
5311
- vimApi.handleKey(cm, command.toKeys[i], 'mapping');
5312
- }
5576
+ doKeyToKey(cm, command.toKeys, command);
5313
5577
  return;
5314
5578
  }
5315
5579
  else if (command.type == 'exToEx') {
@@ -5345,6 +5609,21 @@ ExCommandDispatcher.prototype = {
5345
5609
  result.lineEnd = this.parseLineSpec_(cm, inputStream);
5346
5610
  }
5347
5611
  }
5612
+ if (result.line == undefined) {
5613
+ if (cm.state.vim.visualMode) {
5614
+ var pos = getMarkPos(cm, cm.state.vim, '<');
5615
+ result.selectionLine = pos && pos.line;
5616
+ pos = getMarkPos(cm, cm.state.vim, '>');
5617
+ result.selectionLineEnd = pos && pos.line;
5618
+ }
5619
+ else {
5620
+ result.selectionLine = cm.getCursor().line;
5621
+ }
5622
+ }
5623
+ else {
5624
+ result.selectionLine = result.line;
5625
+ result.selectionLineEnd = result.lineEnd;
5626
+ }
5348
5627
  var commandMatch = inputStream.match(/^(\w+|!!|@@|[!#&*<=>@~])/);
5349
5628
  if (commandMatch) {
5350
5629
  result.commandName = commandMatch[1];
@@ -5423,7 +5702,7 @@ ExCommandDispatcher.prototype = {
5423
5702
  this.commandMap_[key] = command;
5424
5703
  }
5425
5704
  },
5426
- map: function (lhs, rhs, ctx) {
5705
+ map: function (lhs, rhs, ctx, noremap) {
5427
5706
  if (lhs != ':' && lhs.charAt(0) == ':') {
5428
5707
  if (ctx) {
5429
5708
  throw Error('Mode not supported for ex mappings');
@@ -5447,28 +5726,16 @@ ExCommandDispatcher.prototype = {
5447
5726
  }
5448
5727
  }
5449
5728
  else {
5450
- if (rhs != ':' && rhs.charAt(0) == ':') {
5451
- var mapping = {
5452
- keys: lhs,
5453
- type: 'keyToEx',
5454
- exArgs: { input: rhs.substring(1) }
5455
- };
5456
- if (ctx) {
5457
- mapping.context = ctx;
5458
- }
5459
- defaultKeymap.unshift(mapping);
5460
- }
5461
- else {
5462
- var mapping = {
5463
- keys: lhs,
5464
- type: 'keyToKey',
5465
- toKeys: rhs
5466
- };
5467
- if (ctx) {
5468
- mapping.context = ctx;
5469
- }
5470
- defaultKeymap.unshift(mapping);
5729
+ var mapping = {
5730
+ keys: lhs,
5731
+ type: 'keyToKey',
5732
+ toKeys: rhs,
5733
+ noremap: !!noremap
5734
+ };
5735
+ if (ctx) {
5736
+ mapping.context = ctx;
5471
5737
  }
5738
+ defaultKeymap.unshift(mapping);
5472
5739
  }
5473
5740
  },
5474
5741
  unmap: function (lhs, ctx) {
@@ -5502,7 +5769,7 @@ var exCommands = {
5502
5769
  }
5503
5770
  cm.setOption('theme', params.args[0]);
5504
5771
  },
5505
- map: function (cm, params, ctx) {
5772
+ map: function (cm, params, ctx, defaultOnly) {
5506
5773
  var mapArgs = params.args;
5507
5774
  if (!mapArgs || mapArgs.length < 2) {
5508
5775
  if (cm) {
@@ -5510,11 +5777,17 @@ var exCommands = {
5510
5777
  }
5511
5778
  return;
5512
5779
  }
5513
- exCommandDispatcher.map(mapArgs[0], mapArgs[1], ctx);
5780
+ exCommandDispatcher.map(mapArgs[0], mapArgs[1], ctx, defaultOnly);
5514
5781
  },
5515
5782
  imap: function (cm, params) { this.map(cm, params, 'insert'); },
5516
5783
  nmap: function (cm, params) { this.map(cm, params, 'normal'); },
5517
5784
  vmap: function (cm, params) { this.map(cm, params, 'visual'); },
5785
+ omap: function (cm, params) { this.map(cm, params, 'operatorPending'); },
5786
+ noremap: function (cm, params) { this.map(cm, params, undefined, true); },
5787
+ inoremap: function (cm, params) { this.map(cm, params, 'insert', true); },
5788
+ nnoremap: function (cm, params) { this.map(cm, params, 'normal', true); },
5789
+ vnoremap: function (cm, params) { this.map(cm, params, 'visual', true); },
5790
+ onoremap: function (cm, params) { this.map(cm, params, 'operatorPending', true); },
5518
5791
  unmap: function (cm, params, ctx) {
5519
5792
  var mapArgs = params.args;
5520
5793
  if (!mapArgs || mapArgs.length < 1 || !exCommandDispatcher.unmap(mapArgs[0], ctx)) {
@@ -5523,6 +5796,11 @@ var exCommands = {
5523
5796
  }
5524
5797
  }
5525
5798
  },
5799
+ mapclear: function (cm, params) { vimApi.mapclear(); },
5800
+ imapclear: function (cm, params) { vimApi.mapclear('insert'); },
5801
+ nmapclear: function (cm, params) { vimApi.mapclear('normal'); },
5802
+ vmapclear: function (cm, params) { vimApi.mapclear('visual'); },
5803
+ omapclear: function (cm, params) { vimApi.mapclear('operatorPending'); },
5526
5804
  move: function (cm, params) {
5527
5805
  commandDispatcher.processCommand(cm, cm.state.vim, {
5528
5806
  type: 'motion',
@@ -5545,6 +5823,7 @@ var exCommands = {
5545
5823
  var optionName = expr[0];
5546
5824
  var value = expr[1];
5547
5825
  var forceGet = false;
5826
+ var forceToggle = false;
5548
5827
  if (optionName.charAt(optionName.length - 1) == '?') {
5549
5828
  if (value) {
5550
5829
  throw Error('Trailing characters: ' + params.argString);
@@ -5552,13 +5831,22 @@ var exCommands = {
5552
5831
  optionName = optionName.substring(0, optionName.length - 1);
5553
5832
  forceGet = true;
5554
5833
  }
5834
+ else if (optionName.charAt(optionName.length - 1) == '!') {
5835
+ optionName = optionName.substring(0, optionName.length - 1);
5836
+ forceToggle = true;
5837
+ }
5555
5838
  if (value === undefined && optionName.substring(0, 2) == 'no') {
5556
5839
  optionName = optionName.substring(2);
5557
5840
  value = false;
5558
5841
  }
5559
5842
  var optionIsBoolean = options[optionName] && options[optionName].type == 'boolean';
5560
- if (optionIsBoolean && value == undefined) {
5561
- value = true;
5843
+ if (optionIsBoolean) {
5844
+ if (forceToggle) {
5845
+ value = !getOption(optionName, cm, setCfg);
5846
+ }
5847
+ else if (value == undefined) {
5848
+ value = true;
5849
+ }
5562
5850
  }
5563
5851
  if (!optionIsBoolean && value === undefined || forceGet) {
5564
5852
  var oldValue = getOption(optionName, cm, setCfg);
@@ -5742,6 +6030,35 @@ var exCommands = {
5742
6030
  vglobal: function (cm, params) {
5743
6031
  this.global(cm, params);
5744
6032
  },
6033
+ normal: function (cm, params) {
6034
+ var argString = params.argString;
6035
+ if (argString && argString[0] == '!') {
6036
+ argString = argString.slice(1);
6037
+ noremap = true;
6038
+ }
6039
+ argString = argString.trimStart();
6040
+ if (!argString) {
6041
+ showConfirm(cm, 'Argument is required.');
6042
+ return;
6043
+ }
6044
+ var line = params.line;
6045
+ if (typeof line == 'number') {
6046
+ var lineEnd = isNaN(params.lineEnd) ? line : params.lineEnd;
6047
+ for (var i = line; i <= lineEnd; i++) {
6048
+ cm.setCursor(i, 0);
6049
+ doKeyToKey(cm, params.argString.trimStart());
6050
+ if (cm.state.vim.insertMode) {
6051
+ exitInsertMode(cm, true);
6052
+ }
6053
+ }
6054
+ }
6055
+ else {
6056
+ doKeyToKey(cm, params.argString.trimStart());
6057
+ if (cm.state.vim.insertMode) {
6058
+ exitInsertMode(cm, true);
6059
+ }
6060
+ }
6061
+ },
5745
6062
  global: function (cm, params) {
5746
6063
  var argString = params.argString;
5747
6064
  if (!argString) {
@@ -5749,6 +6066,10 @@ var exCommands = {
5749
6066
  return;
5750
6067
  }
5751
6068
  var inverted = params.commandName[0] === 'v';
6069
+ if (argString[0] === '!' && params.commandName[0] === 'g') {
6070
+ inverted = true;
6071
+ argString = argString.slice(1);
6072
+ }
5752
6073
  var lineStart = (params.line !== undefined) ? params.line : cm.firstLine();
5753
6074
  var lineEnd = params.lineEnd || params.line || cm.lastLine();
5754
6075
  var tokens = splitBySlash(argString);
@@ -5769,10 +6090,10 @@ var exCommands = {
5769
6090
  var query = getSearchState(cm).getQuery();
5770
6091
  var matchedLines = [];
5771
6092
  for (var i = lineStart; i <= lineEnd; i++) {
5772
- var line = cm.getLineHandle(i);
5773
- var matched = query.test(line.text);
6093
+ var line = cm.getLine(i);
6094
+ var matched = query.test(line);
5774
6095
  if (matched !== inverted) {
5775
- matchedLines.push(cmd ? line : line.text);
6096
+ matchedLines.push(cmd ? cm.getLineHandle(i) : line);
5776
6097
  }
5777
6098
  }
5778
6099
  if (!cmd) {
@@ -5782,8 +6103,8 @@ var exCommands = {
5782
6103
  var index = 0;
5783
6104
  var nextCommand = function () {
5784
6105
  if (index < matchedLines.length) {
5785
- var line = matchedLines[index++];
5786
- var lineNum = cm.getLineNumber(line);
6106
+ var lineHandle = matchedLines[index++];
6107
+ var lineNum = cm.getLineNumber(lineHandle);
5787
6108
  if (lineNum == null) {
5788
6109
  nextCommand();
5789
6110
  return;
@@ -5793,6 +6114,9 @@ var exCommands = {
5793
6114
  callback: nextCommand
5794
6115
  });
5795
6116
  }
6117
+ else if (cm.releaseLineHandles) {
6118
+ cm.releaseLineHandles();
6119
+ }
5796
6120
  };
5797
6121
  nextCommand();
5798
6122
  },
@@ -5877,6 +6201,9 @@ var exCommands = {
5877
6201
  var cursor = cm.getSearchCursor(query, startPos);
5878
6202
  doReplace(cm, confirm, global, lineStart, lineEnd, cursor, query, replacePart, params.callback);
5879
6203
  },
6204
+ startinsert: function (cm, params) {
6205
+ doKeyToKey(cm, params.argString == '!' ? 'A' : 'i', {});
6206
+ },
5880
6207
  redo: CodeMirror.commands.redo,
5881
6208
  undo: CodeMirror.commands.undo,
5882
6209
  write: function (cm) {
@@ -5896,6 +6223,20 @@ var exCommands = {
5896
6223
  var lineText = cm.getLine(line);
5897
6224
  vimGlobalState.registerController.pushText('0', 'yank', lineText, true, true);
5898
6225
  },
6226
+ delete: function (cm, params) {
6227
+ var line = params.selectionLine;
6228
+ var lineEnd = isNaN(params.selectionLineEnd) ? line : params.selectionLineEnd;
6229
+ operators.delete(cm, { linewise: true }, [
6230
+ { anchor: new Pos(line, 0),
6231
+ head: new Pos(lineEnd + 1, 0) }
6232
+ ]);
6233
+ },
6234
+ join: function (cm, params) {
6235
+ var line = params.selectionLine;
6236
+ var lineEnd = isNaN(params.selectionLineEnd) ? line : params.selectionLineEnd;
6237
+ cm.setCursor(new Pos(line, 0));
6238
+ actions.joinLines(cm, { repeat: lineEnd - line }, cm.state.vim);
6239
+ },
5899
6240
  delmarks: function (cm, params) {
5900
6241
  if (!params.argString || !trim(params.argString)) {
5901
6242
  showConfirm(cm, 'Argument required');
@@ -6004,27 +6345,27 @@ function doReplace(cm, confirm, global, lineStart, lineEnd, searchCursor, query,
6004
6345
  }
6005
6346
  function onPromptKeyDown(e, _value, close) {
6006
6347
  CodeMirror.e_stop(e);
6007
- var keyName = CodeMirror.keyName(e);
6348
+ var keyName = vimKeyFromEvent(e);
6008
6349
  switch (keyName) {
6009
- case 'Y':
6350
+ case 'y':
6010
6351
  replace();
6011
6352
  next();
6012
6353
  break;
6013
- case 'N':
6354
+ case 'n':
6014
6355
  next();
6015
6356
  break;
6016
- case 'A':
6357
+ case 'a':
6017
6358
  var savedCallback = callback;
6018
6359
  callback = undefined;
6019
6360
  cm.operation(replaceAll);
6020
6361
  callback = savedCallback;
6021
6362
  break;
6022
- case 'L':
6363
+ case 'l':
6023
6364
  replace();
6024
- case 'Q':
6025
- case 'Esc':
6026
- case 'Ctrl-C':
6027
- case 'Ctrl-[':
6365
+ case 'q':
6366
+ case '<Esc>':
6367
+ case '<C-c>':
6368
+ case '<C-[>':
6028
6369
  stop(close);
6029
6370
  break;
6030
6371
  }
@@ -6050,12 +6391,7 @@ function doReplace(cm, confirm, global, lineStart, lineEnd, searchCursor, query,
6050
6391
  onKeyDown: onPromptKeyDown
6051
6392
  });
6052
6393
  }
6053
- CodeMirror.keyMap.vim = {
6054
- attach: attachVimMap,
6055
- detach: detachVimMap,
6056
- call: cmKey
6057
- };
6058
- function exitInsertMode(cm) {
6394
+ function exitInsertMode(cm, keepCursor) {
6059
6395
  var vim = cm.state.vim;
6060
6396
  var macroModeState = vimGlobalState.macroModeState;
6061
6397
  var insertModeChangeRegister = vimGlobalState.registerController.getRegister('.');
@@ -6063,6 +6399,9 @@ function exitInsertMode(cm) {
6063
6399
  var lastChange = macroModeState.lastInsertModeChanges;
6064
6400
  if (!isPlaying) {
6065
6401
  cm.off('change', onChange);
6402
+ if (vim.insertEnd)
6403
+ vim.insertEnd.clear();
6404
+ vim.insertEnd = null;
6066
6405
  CodeMirror.off(cm.getInputField(), 'keydown', onKeyEventTargetKeyDown);
6067
6406
  }
6068
6407
  if (!isPlaying && vim.insertModeRepeat > 1) {
@@ -6071,7 +6410,9 @@ function exitInsertMode(cm) {
6071
6410
  }
6072
6411
  delete vim.insertModeRepeat;
6073
6412
  vim.insertMode = false;
6074
- cm.setCursor(cm.getCursor().line, cm.getCursor().ch - 1);
6413
+ if (!keepCursor) {
6414
+ cm.setCursor(cm.getCursor().line, cm.getCursor().ch - 1);
6415
+ }
6075
6416
  cm.setOption('keyMap', 'vim');
6076
6417
  cm.setOption('disableInput', true);
6077
6418
  cm.toggleOverwrite(false); // exit replace mode if we were in it.
@@ -6093,19 +6434,6 @@ function mapCommand(keys, type, name, args, extra) {
6093
6434
  _mapCommand(command);
6094
6435
  }
6095
6436
  defineOption('insertModeEscKeysTimeout', 200, 'number');
6096
- CodeMirror.keyMap['vim-insert'] = {
6097
- fallthrough: ['default'],
6098
- attach: attachVimMap,
6099
- detach: detachVimMap,
6100
- call: cmKey
6101
- };
6102
- CodeMirror.keyMap['vim-replace'] = {
6103
- 'Backspace': 'goCharLeft',
6104
- fallthrough: ['vim-insert'],
6105
- attach: attachVimMap,
6106
- detach: detachVimMap,
6107
- call: cmKey
6108
- };
6109
6437
  function executeMacroRegister(cm, vim, macroModeState, registerName) {
6110
6438
  var register = vimGlobalState.registerController.getRegister(registerName);
6111
6439
  if (registerName == ':') {
@@ -6172,6 +6500,7 @@ function onChange(cm, changeObj) {
6172
6500
  var macroModeState = vimGlobalState.macroModeState;
6173
6501
  var lastChange = macroModeState.lastInsertModeChanges;
6174
6502
  if (!macroModeState.isPlaying) {
6503
+ var vim = cm.state.vim;
6175
6504
  while (changeObj) {
6176
6505
  lastChange.expectCursorActivityForChange = true;
6177
6506
  if (lastChange.ignoreCount > 1) {
@@ -6192,7 +6521,19 @@ function onChange(cm, changeObj) {
6192
6521
  lastChange.changes.push([text]);
6193
6522
  }
6194
6523
  else {
6195
- lastChange.changes.push(text);
6524
+ if (text.length > 1) {
6525
+ var insertEnd = vim && vim.insertEnd && vim.insertEnd.find();
6526
+ var cursor = cm.getCursor();
6527
+ if (insertEnd && insertEnd.line == cursor.line) {
6528
+ var offset = insertEnd.ch - cursor.ch;
6529
+ if (offset > 0 && offset < text.length) {
6530
+ lastChange.changes.push([text, offset]);
6531
+ text = '';
6532
+ }
6533
+ }
6534
+ }
6535
+ if (text)
6536
+ lastChange.changes.push(text);
6196
6537
  }
6197
6538
  }
6198
6539
  }
@@ -6213,6 +6554,9 @@ function onCursorActivity(cm) {
6213
6554
  }
6214
6555
  else {
6215
6556
  lastChange.maybeReset = true;
6557
+ if (vim.insertEnd)
6558
+ vim.insertEnd.clear();
6559
+ vim.insertEnd = cm.setBookmark(cm.getCursor(), { insertLeft: true });
6216
6560
  }
6217
6561
  }
6218
6562
  else if (!cm.curOp.isVimOp) {
@@ -6246,26 +6590,27 @@ function handleExternalSelection(cm, vim, keepHPos) {
6246
6590
  vim.lastHPos = cm.getCursor().ch;
6247
6591
  }
6248
6592
  }
6249
- function InsertModeKey(keyName) {
6593
+ function InsertModeKey(keyName, e) {
6250
6594
  this.keyName = keyName;
6595
+ this.key = e.key;
6596
+ this.ctrlKey = e.ctrlKey;
6597
+ this.altKey = e.altKey;
6598
+ this.metaKey = e.metaKey;
6599
+ this.shiftKey = e.shiftKey;
6251
6600
  }
6252
6601
  function onKeyEventTargetKeyDown(e) {
6253
6602
  var macroModeState = vimGlobalState.macroModeState;
6254
6603
  var lastChange = macroModeState.lastInsertModeChanges;
6255
- var keyName = CodeMirror.keyName(e);
6604
+ var keyName = CodeMirror.keyName ? CodeMirror.keyName(e) : e.key;
6256
6605
  if (!keyName) {
6257
6606
  return;
6258
6607
  }
6259
- function onKeyFound() {
6608
+ if (keyName.indexOf('Delete') != -1 || keyName.indexOf('Backspace') != -1) {
6260
6609
  if (lastChange.maybeReset) {
6261
6610
  lastChange.changes = [];
6262
6611
  lastChange.maybeReset = false;
6263
6612
  }
6264
- lastChange.changes.push(new InsertModeKey(keyName));
6265
- return true;
6266
- }
6267
- if (keyName.indexOf('Delete') != -1 || keyName.indexOf('Backspace') != -1) {
6268
- CodeMirror.lookupKey(keyName, 'vim-insert', onKeyFound);
6613
+ lastChange.changes.push(new InsertModeKey(keyName, e));
6269
6614
  }
6270
6615
  }
6271
6616
  function repeatLastEdit(cm, vim, repeat, repeatForInsert) {
@@ -6307,8 +6652,8 @@ function repeatLastEdit(cm, vim, repeat, repeatForInsert) {
6307
6652
  }
6308
6653
  macroModeState.isPlaying = false;
6309
6654
  }
6310
- function repeatInsertModeChanges(cm, changes, repeat) {
6311
- function keyHandler(binding) {
6655
+ function sendCmKey(cm, key) {
6656
+ CodeMirror.lookupKey(key, 'vim-insert', function keyHandler(binding) {
6312
6657
  if (typeof binding == 'string') {
6313
6658
  CodeMirror.commands[binding](cm);
6314
6659
  }
@@ -6316,7 +6661,9 @@ function repeatInsertModeChanges(cm, changes, repeat) {
6316
6661
  binding(cm);
6317
6662
  }
6318
6663
  return true;
6319
- }
6664
+ });
6665
+ }
6666
+ function repeatInsertModeChanges(cm, changes, repeat) {
6320
6667
  var head = cm.getCursor('head');
6321
6668
  var visualBlock = vimGlobalState.macroModeState.lastInsertModeChanges.visualBlock;
6322
6669
  if (visualBlock) {
@@ -6331,15 +6678,15 @@ function repeatInsertModeChanges(cm, changes, repeat) {
6331
6678
  for (var j = 0; j < changes.length; j++) {
6332
6679
  var change = changes[j];
6333
6680
  if (change instanceof InsertModeKey) {
6334
- CodeMirror.lookupKey(change.keyName, 'vim-insert', keyHandler);
6681
+ sendCmKey(cm, change.keyName, change);
6335
6682
  }
6336
6683
  else if (typeof change == "string") {
6337
6684
  cm.replaceSelection(change);
6338
6685
  }
6339
6686
  else {
6340
6687
  var start = cm.getCursor();
6341
- var end = offsetCursor(start, 0, change[0].length);
6342
- cm.replaceRange(change[0], start, end);
6688
+ var end = offsetCursor(start, 0, change[0].length - (change[1] || 0));
6689
+ cm.replaceRange(change[0], start, change[1] ? start : end);
6343
6690
  cm.setCursor(end);
6344
6691
  }
6345
6692
  }
@@ -6348,17 +6695,16 @@ function repeatInsertModeChanges(cm, changes, repeat) {
6348
6695
  cm.setCursor(offsetCursor(head, 0, 1));
6349
6696
  }
6350
6697
  }
6351
- resetVimGlobalState();
6352
6698
  CodeMirror.Vim = vimApi;
6353
- var specialKey = { 'return': 'CR', backspace: 'BS', 'delete': 'Del', esc: 'Esc',
6699
+ var specialKeyAce = { 'return': 'CR', backspace: 'BS', 'delete': 'Del', esc: 'Esc',
6354
6700
  left: 'Left', right: 'Right', up: 'Up', down: 'Down', space: 'Space', insert: 'Ins',
6355
6701
  home: 'Home', end: 'End', pageup: 'PageUp', pagedown: 'PageDown', enter: 'CR'
6356
6702
  };
6357
- function lookupKey(hashId, key, e) {
6703
+ function lookupKey(hashId, key, e, vim) {
6358
6704
  if (key.length > 1 && key[0] == "n") {
6359
6705
  key = key.replace("numpad", "");
6360
6706
  }
6361
- key = specialKey[key] || key;
6707
+ key = specialKeyAce[key] || key;
6362
6708
  var name = '';
6363
6709
  if (e.ctrlKey) {
6364
6710
  name += 'C-';
@@ -6369,6 +6715,19 @@ function lookupKey(hashId, key, e) {
6369
6715
  if ((name || key.length > 1) && e.shiftKey) {
6370
6716
  name += 'S-';
6371
6717
  }
6718
+ if (vim && !vim.expectLiteralNext && key.length == 1) {
6719
+ if (langmap.keymap && key in langmap.keymap) {
6720
+ if (langmap.remapCtrl !== false || !name)
6721
+ key = langmap.keymap[key];
6722
+ }
6723
+ else if (key.charCodeAt(0) > 255) {
6724
+ var code = e.code && e.code.slice(-1) || "";
6725
+ if (!e.shiftKey)
6726
+ code = code.toLowerCase();
6727
+ if (code)
6728
+ key = code;
6729
+ }
6730
+ }
6372
6731
  name += key;
6373
6732
  if (name.length > 1) {
6374
6733
  name = '<' + name + '>';
@@ -6384,6 +6743,8 @@ vimApi.handleKey = function (cm, key, origin) {
6384
6743
  function cloneVimState(state) {
6385
6744
  var n = new state.constructor();
6386
6745
  Object.keys(state).forEach(function (key) {
6746
+ if (key == "insertEnd")
6747
+ return;
6387
6748
  var o = state[key];
6388
6749
  if (Array.isArray(o))
6389
6750
  o = o.slice();
@@ -6418,10 +6779,14 @@ function multiSelectHandleKey(cm, key, origin) {
6418
6779
  }
6419
6780
  else {
6420
6781
  var old = cloneVimState(vim);
6782
+ var changeQueueList = vim.inputState.changeQueueList || [];
6421
6783
  cm.operation(function () {
6784
+ cm.curOp.isVimOp = true;
6785
+ var index = 0;
6422
6786
  cm.ace.forEachSelection(function () {
6423
6787
  var sel = cm.ace.selection;
6424
6788
  cm.state.vim.lastHPos = sel.$desiredColumn == null ? sel.lead.column : sel.$desiredColumn;
6789
+ cm.state.vim.inputState.changeQueue = changeQueueList[index];
6425
6790
  var head = cm.getCursor("head");
6426
6791
  var anchor = cm.getCursor("anchor");
6427
6792
  var headOffset = !cursorIsBefore(head, anchor) ? -1 : 0;
@@ -6432,12 +6797,20 @@ function multiSelectHandleKey(cm, key, origin) {
6432
6797
  cm.state.vim.sel.anchor = anchor;
6433
6798
  isHandled = handleKey(cm, key, origin);
6434
6799
  sel.$desiredColumn = cm.state.vim.lastHPos == -1 ? null : cm.state.vim.lastHPos;
6800
+ if (cm.ace.inVirtualSelectionMode) {
6801
+ changeQueueList[index] = cm.state.vim.inputState.changeQueue;
6802
+ }
6435
6803
  if (cm.virtualSelectionMode()) {
6436
6804
  cm.state.vim = cloneVimState(old);
6437
6805
  }
6806
+ index++;
6438
6807
  });
6439
6808
  if (cm.curOp.cursorActivity && !isHandled)
6440
6809
  cm.curOp.cursorActivity = false;
6810
+ vim.status = cm.state.vim.status;
6811
+ cm.state.vim = vim;
6812
+ vim.inputState.changeQueueList = changeQueueList;
6813
+ vim.inputState.changeQueue = null;
6441
6814
  }, true);
6442
6815
  }
6443
6816
  if (isHandled && !vim.visualMode && !vim.insert && vim.visualMode != cm.somethingSelected()) {
@@ -6445,6 +6818,7 @@ function multiSelectHandleKey(cm, key, origin) {
6445
6818
  }
6446
6819
  return isHandled;
6447
6820
  }
6821
+ resetVimGlobalState();
6448
6822
  exports.CodeMirror = CodeMirror;
6449
6823
  var getVim = vimApi.maybeInitVimState_;
6450
6824
  exports.handler = {
@@ -6531,7 +6905,7 @@ exports.handler = {
6531
6905
  }
6532
6906
  if (hashId == -1 || hashId & 1 || hashId === 0 && key.length > 1) {
6533
6907
  var insertMode = vim.insertMode;
6534
- var name = lookupKey(hashId, key, e || {});
6908
+ var name = lookupKey(hashId, key, e || {}, vim);
6535
6909
  if (vim.status == null)
6536
6910
  vim.status = "";
6537
6911
  var isHandled = multiSelectHandleKey(cm, name, 'user');
@@ -6552,7 +6926,7 @@ exports.handler = {
6552
6926
  var cm = new CodeMirror(editor);
6553
6927
  editor.state.cm = cm;
6554
6928
  editor.$vimModeHandler = this;
6555
- CodeMirror.keyMap.vim.attach(cm);
6929
+ enterVimMode(cm);
6556
6930
  getVim(cm).status = null;
6557
6931
  cm.on('vim-command-done', function () {
6558
6932
  if (cm.virtualSelectionMode())
@@ -6583,7 +6957,7 @@ exports.handler = {
6583
6957
  },
6584
6958
  detach: function (editor) {
6585
6959
  var cm = editor.state.cm;
6586
- CodeMirror.keyMap.vim.detach(cm);
6960
+ leaveVimMode(cm);
6587
6961
  cm.destroy();
6588
6962
  editor.state.cm = null;
6589
6963
  editor.$vimModeHandler = null;
@@ -6670,6 +7044,7 @@ actions.fold = function (cm, actionArgs, vim) {
6670
7044
  cm.ace.execCommand(['toggleFoldWidget', 'toggleFoldWidget', 'foldOther', 'unfoldall'
6671
7045
  ][(actionArgs.all ? 2 : 0) + (actionArgs.open ? 1 : 0)]);
6672
7046
  };
7047
+ defaultKeymapLength = defaultKeymap.length; // ace_patch
6673
7048
  exports.handler.defaultKeymap = defaultKeymap;
6674
7049
  exports.handler.actions = actions;
6675
7050
  exports.Vim = vimApi;