gollum 3.1.2 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gollum might be problematic. Click here for more details.

Files changed (911) hide show
  1. checksums.yaml +13 -5
  2. data/README.md +4 -5
  3. data/gollum.gemspec +560 -28
  4. data/lib/gollum.rb +1 -1
  5. data/lib/gollum/app.rb +16 -10
  6. data/lib/gollum/public/gollum/javascript/editor/gollum.editor.js +1 -1
  7. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ace.js +33 -11
  8. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/anchor.js +77 -80
  9. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/anchor_test.js +46 -0
  10. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/autocomplete.js +497 -0
  11. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/autocomplete/popup.js +341 -0
  12. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/autocomplete/text_completer.js +78 -0
  13. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/autocomplete/util.js +74 -0
  14. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/background_tokenizer.js +28 -32
  15. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/background_tokenizer_test.js +5 -5
  16. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/commands/command_manager.js +17 -20
  17. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/commands/command_manager_test.js +1 -1
  18. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/commands/default_commands.js +312 -58
  19. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/commands/incremental_search_commands.js +232 -0
  20. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/commands/multi_select_commands.js +17 -1
  21. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/commands/occur_commands.js +110 -0
  22. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/config.js +70 -7
  23. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/config_test.js +67 -3
  24. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/css/editor.css +123 -69
  25. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/document.js +118 -71
  26. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/edit_session.js +507 -392
  27. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/edit_session/bracket_match.js +4 -2
  28. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/edit_session/fold.js +37 -5
  29. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/edit_session/fold_line.js +30 -29
  30. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/edit_session/folding.js +210 -102
  31. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/edit_session_test.js +82 -8
  32. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/editor.js +1006 -465
  33. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/editor_highlight_selected_word_test.js +2 -2
  34. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/editor_text_edit_test.js +36 -34
  35. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/beautify.js +57 -0
  36. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/beautify/php_rules.js +366 -0
  37. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/chromevox.js +980 -0
  38. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/elastic_tabstops_lite.js +319 -0
  39. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/emmet.js +434 -0
  40. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/error_marker.js +214 -0
  41. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/keybinding_menu.js +86 -0
  42. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/language_tools.js +226 -0
  43. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/linking.js +78 -0
  44. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/menu_tools/add_editor_menu_options.js +109 -0
  45. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/menu_tools/element_generator.js +148 -0
  46. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/menu_tools/generate_settings_menu.js +264 -0
  47. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/menu_tools/get_editor_keyboard_shortcuts.js +91 -0
  48. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/menu_tools/get_set_functions.js +141 -0
  49. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/menu_tools/overlay_page.js +116 -0
  50. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/menu_tools/settings_menu.css +48 -0
  51. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/modelist.js +195 -0
  52. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/old_ie.js +114 -0
  53. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/old_ie_test.js +77 -0
  54. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/searchbox.css +153 -0
  55. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/searchbox.js +308 -0
  56. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/settings_menu.js +76 -0
  57. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/spellcheck.js +69 -0
  58. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/{keyboard/vim/registers.js → ext/split.js} +8 -10
  59. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/static.css +18 -9
  60. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/static_highlight.js +128 -26
  61. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/static_highlight_test.js +56 -36
  62. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/statusbar.js +48 -0
  63. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/textarea.js +112 -117
  64. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/themelist.js +100 -0
  65. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/whitespace.js +213 -0
  66. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/ext/whitespace_test.js +116 -0
  67. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/incremental_search.js +317 -0
  68. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/incremental_search_test.js +213 -0
  69. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/keyboard/emacs.js +369 -92
  70. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/keyboard/emacs_test.js +151 -0
  71. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/keyboard/hash_handler.js +109 -41
  72. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/keyboard/keybinding.js +35 -24
  73. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/keyboard/keybinding_test.js +69 -0
  74. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/keyboard/state_handler.js +1 -2
  75. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/keyboard/textarea.js +82 -0
  76. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/keyboard/textinput.js +337 -208
  77. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/keyboard/vim.js +5987 -120
  78. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/keyboard/vim_test.js +3866 -0
  79. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/layer/cursor.js +48 -25
  80. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/layer/font_metrics.js +176 -0
  81. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/layer/gutter.js +110 -44
  82. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/layer/marker.js +29 -14
  83. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/layer/text.js +69 -150
  84. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/layer/text_test.js +11 -10
  85. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/app_config.js +157 -0
  86. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/dom.js +33 -31
  87. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/es5-shim.js +284 -304
  88. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/event.js +147 -95
  89. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/event_emitter.js +64 -23
  90. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/keys.js +35 -9
  91. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/lang.js +30 -13
  92. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/net.js +21 -39
  93. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/oop.js +12 -9
  94. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/useragent.js +8 -4
  95. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/line_widgets.js +297 -0
  96. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/Readme.md +9 -0
  97. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/highlight_rules_test.js +210 -0
  98. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/text_asciidoc.txt +111 -0
  99. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/text_coffee.txt +57 -0
  100. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/text_curly.txt +9 -0
  101. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/text_html.txt +10 -0
  102. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/text_javascript.txt +34 -0
  103. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/text_livescript.txt +1 -0
  104. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/text_lucene.txt +16 -0
  105. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/text_markdown.txt +22 -0
  106. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/text_php.txt +24 -0
  107. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/text_ruby.txt +34 -0
  108. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/text_xml.txt +7 -0
  109. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_abap.json +189 -0
  110. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_abc.json +2207 -0
  111. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_actionscript.json +263 -0
  112. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_ada.json +39 -0
  113. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_asciidoc.json +422 -0
  114. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_assembly_x86.json +114 -0
  115. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_autohotkey.json +261 -0
  116. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_batchfile.json +70 -0
  117. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_c9search.json +131 -175
  118. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_c_cpp.json +190 -124
  119. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_cirru.json +267 -0
  120. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_clojure.json +162 -248
  121. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_cobol.json +4 -0
  122. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_coffee.json +545 -188
  123. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_coldfusion.json +26 -41
  124. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_csharp.json +31 -42
  125. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_css.json +148 -231
  126. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_curly.json +56 -0
  127. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_d.json +111 -0
  128. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_dart.json +368 -0
  129. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_diff.json +262 -732
  130. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_dot.json +2254 -0
  131. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_eiffel.json +141 -0
  132. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_ejs.json +296 -0
  133. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_elixir.json +196 -0
  134. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_elm.json +198 -0
  135. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_erlang.json +166 -0
  136. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_forth.json +219 -0
  137. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_ftl.json +341 -0
  138. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_gcode.json +296 -0
  139. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_gherkin.json +142 -0
  140. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_gitignore.json +33 -0
  141. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_glsl.json +127 -185
  142. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_golang.json +256 -362
  143. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_groovy.json +410 -529
  144. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_haml.json +174 -0
  145. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_handlebars.json +81 -0
  146. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_haskell.json +156 -0
  147. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_haxe.json +143 -195
  148. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_html.json +63 -150
  149. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_html_ruby.json +257 -0
  150. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_ini.json +23 -0
  151. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_io.json +49 -0
  152. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_jack.json +1786 -0
  153. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_jade.json +188 -0
  154. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_java.json +95 -139
  155. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_javascript.json +593 -555
  156. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_json.json +412 -611
  157. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_jsoniq.json +4 -0
  158. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_jsp.json +435 -0
  159. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_jsx.json +51 -79
  160. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_julia.json +111 -0
  161. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_latex.json +127 -196
  162. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_less.json +204 -292
  163. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_liquid.json +551 -698
  164. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_lisp.json +248 -0
  165. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_livescript.json +6 -0
  166. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_logiql.json +190 -0
  167. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_lsl.json +503 -0
  168. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_lua.json +348 -451
  169. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_luapage.json +633 -824
  170. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_lucene.json +92 -0
  171. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_markdown.json +114 -1202
  172. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_mask.json +302 -0
  173. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_matlab.json +90 -0
  174. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_mel.json +257 -0
  175. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_mushcode.json +790 -0
  176. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_mysql.json +4 -0
  177. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_nix.json +360 -0
  178. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_objectivec.json +793 -0
  179. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_ocaml.json +200 -260
  180. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_pascal.json +297 -0
  181. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_perl.json +227 -311
  182. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_pgsql.json +889 -1020
  183. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_php.json +171 -238
  184. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_powershell.json +184 -255
  185. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_prolog.json +245 -0
  186. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_properties.json +68 -0
  187. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_protobuf.json +136 -0
  188. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_python.json +152 -205
  189. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_r.json +235 -0
  190. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_rdoc.json +441 -0
  191. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_rhtml.json +106 -0
  192. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_ruby.json +242 -104
  193. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_rust.json +136 -0
  194. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_sass.json +229 -0
  195. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_scad.json +194 -267
  196. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_scala.json +542 -748
  197. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_scheme.json +216 -0
  198. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_scss.json +123 -181
  199. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_sh.json +334 -434
  200. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_sjs.json +276 -0
  201. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_smarty.json +98 -0
  202. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_snippets.json +159 -0
  203. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_soy_template.json +286 -0
  204. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_space.json +322 -0
  205. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_sql.json +54 -73
  206. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_stylus.json +271 -0
  207. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_svg.json +684 -931
  208. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_tcl.json +385 -536
  209. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_tex.json +130 -0
  210. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_text.json +29 -58
  211. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_textile.json +113 -195
  212. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_toml.json +131 -0
  213. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_twig.json +288 -0
  214. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_typescript.json +559 -0
  215. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_vala.json +158 -0
  216. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_vbscript.json +205 -0
  217. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_velocity.json +285 -0
  218. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_verilog.json +113 -0
  219. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_vhdl.json +271 -0
  220. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_xml.json +43 -705
  221. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_xquery.json +44 -64
  222. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_yaml.json +150 -260
  223. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/abap.js +2 -2
  224. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/abap_highlight_rules.js +7 -6
  225. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/abc.js +58 -0
  226. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/abc_highlight_rules.js +114 -0
  227. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/actionscript.js +58 -0
  228. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/actionscript_highlight_rules.js +141 -0
  229. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/ada.js +54 -0
  230. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/ada_highlight_rules.js +93 -0
  231. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/apache_conf.js +62 -0
  232. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/apache_conf_highlight_rules.js +231 -0
  233. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/applescript.js +55 -0
  234. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/applescript_highlight_rules.js +139 -0
  235. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/asciidoc.js +3 -3
  236. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/asciidoc_highlight_rules.js +11 -11
  237. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/assembly_x86.js +56 -0
  238. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/assembly_x86_highlight_rules.js +114 -0
  239. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/autohotkey.js +57 -0
  240. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/autohotkey_highlight_rules.js +107 -0
  241. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/batchfile.js +61 -0
  242. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/batchfile_highlight_rules.js +97 -0
  243. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/behaviour_test.js +139 -0
  244. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/css.js +108 -0
  245. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/cstyle.js +164 -137
  246. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/html.js +4 -48
  247. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/xml.js +141 -44
  248. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/xquery.js +76 -52
  249. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/c9search.js +2 -2
  250. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/c9search_highlight_rules.js +127 -4
  251. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/c_cpp.js +7 -30
  252. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/c_cpp_highlight_rules.js +60 -51
  253. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/cirru.js +51 -0
  254. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/cirru_highlight_rules.js +125 -0
  255. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/clojure.js +62 -46
  256. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/clojure_highlight_rules.js +4 -21
  257. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/cobol.js +53 -0
  258. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/cobol_highlight_rules.js +100 -0
  259. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/coffee.js +28 -7
  260. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/coffee-script.js +13 -7
  261. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/helpers.js +160 -4
  262. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/lexer.js +228 -108
  263. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/nodes.js +778 -670
  264. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/parser.js +377 -347
  265. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/parser_test.js +33 -6
  266. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/rewriter.js +275 -135
  267. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/scope.js +5 -4
  268. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/coffee_highlight_rules.js +72 -167
  269. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/coffee_worker.js +12 -24
  270. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/coldfusion.js +11 -14
  271. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/coldfusion_highlight_rules.js +5 -84
  272. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/coldfusion_test.js +3 -3
  273. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/csharp.js +7 -4
  274. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/csharp_highlight_rules.js +13 -10
  275. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/css.js +7 -6
  276. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/css/csslint.js +2325 -1216
  277. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/css_highlight_rules.js +72 -102
  278. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/css_test.js +2 -2
  279. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/css_worker.js +11 -5
  280. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/curly.js +63 -0
  281. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/curly_highlight_rules.js +66 -0
  282. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/d.js +56 -0
  283. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/d_highlight_rules.js +334 -0
  284. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/dart.js +8 -8
  285. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/dart_highlight_rules.js +70 -76
  286. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/diff.js +2 -2
  287. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/diff_highlight_rules.js +24 -18
  288. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/django.js +119 -0
  289. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/doc_comment_highlight_rules.js +12 -19
  290. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/dockerfile.js +52 -0
  291. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/dockerfile_highlight_rules.js +57 -0
  292. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/dot.js +55 -0
  293. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/dot_highlight_rules.js +126 -0
  294. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/eiffel.js +52 -0
  295. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/eiffel_highlight_rules.js +136 -0
  296. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/ejs.js +109 -0
  297. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/elixir.js +58 -0
  298. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/elixir_highlight_rules.js +433 -0
  299. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/elm.js +58 -0
  300. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/elm_highlight_rules.js +162 -0
  301. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/erlang.js +57 -0
  302. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/erlang_highlight_rules.js +876 -0
  303. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/folding/c9search.js +12 -6
  304. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/folding/csharp.js +137 -0
  305. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/folding/cstyle.js +118 -6
  306. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/folding/cstyle_test.js +24 -0
  307. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/folding/fold_mode.js +1 -1
  308. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/folding/html.js +2 -33
  309. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/folding/html_test.js +30 -6
  310. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/folding/ini.js +80 -0
  311. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/folding/latex.js +9 -9
  312. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/folding/lua.js +4 -4
  313. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/folding/mixed.js +2 -0
  314. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/folding/velocity.js +120 -0
  315. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/folding/xml.js +110 -87
  316. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/forth.js +58 -0
  317. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/forth_highlight_rules.js +164 -0
  318. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/ftl.js +49 -0
  319. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/ftl_highlight_rules.js +195 -0
  320. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/gcode.js +51 -0
  321. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/gcode_highlight_rules.js +94 -0
  322. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/gherkin.js +80 -0
  323. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/gherkin_highlight_rules.js +113 -0
  324. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/gitignore.js +20 -0
  325. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/gitignore_highlight_rules.js +31 -0
  326. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/glsl.js +6 -2
  327. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/golang.js +42 -67
  328. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/golang_highlight_rules.js +25 -39
  329. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/groovy.js +2 -2
  330. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/groovy_highlight_rules.js +0 -2
  331. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/haml.js +5 -6
  332. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/haml_highlight_rules.js +43 -43
  333. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/handlebars.js +29 -0
  334. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/handlebars_highlight_rules.js +72 -0
  335. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/haskell.js +62 -0
  336. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/haskell_highlight_rules.js +246 -0
  337. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/haxe.js +7 -4
  338. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/haxe_highlight_rules.js +0 -2
  339. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/html.js +42 -12
  340. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/html/saxparser.js +10430 -0
  341. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/html_completions.js +305 -0
  342. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/html_highlight_rules.js +43 -85
  343. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/html_ruby.js +59 -0
  344. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/html_ruby_highlight_rules.js +84 -0
  345. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/html_test.js +3 -3
  346. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/{lib/browser_focus.js → mode/html_worker.js} +48 -51
  347. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/ini.js +53 -0
  348. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/ini_highlight_rules.js +112 -0
  349. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/io.js +58 -0
  350. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/io_highlight_rules.js +120 -0
  351. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/jack.js +79 -0
  352. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/jack_highlight_rules.js +142 -0
  353. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/jade.js +4 -5
  354. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/jade_highlight_rules.js +94 -100
  355. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/java.js +2 -3
  356. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/java_highlight_rules.js +0 -5
  357. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/javascript.js +15 -40
  358. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/javascript/jshint.js +10824 -4816
  359. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_highlight_rules.js +113 -97
  360. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_test.js +61 -6
  361. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_worker.js +5 -7
  362. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_worker_test.js +11 -2
  363. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/js_regex_highlight_rules.js +94 -0
  364. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/json.js +5 -5
  365. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/json_highlight_rules.js +3 -6
  366. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/json_worker.js +6 -35
  367. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/json_worker_test.js +12 -11
  368. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/jsoniq.js +203 -0
  369. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/jsp.js +2 -3
  370. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/jsp_highlight_rules.js +36 -30
  371. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/jsx.js +26 -23
  372. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/jsx_highlight_rules.js +113 -115
  373. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/julia.js +62 -0
  374. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/julia_highlight_rules.js +170 -0
  375. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js +5 -37
  376. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/latex_highlight_rules.js +44 -9
  377. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/less.js +8 -3
  378. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/less_highlight_rules.js +2 -2
  379. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/liquid.js +4 -31
  380. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/liquid_highlight_rules.js +15 -89
  381. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/lisp.js +5 -9
  382. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/lisp_highlight_rules.js +25 -28
  383. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/livescript.js +246 -0
  384. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/logiql.js +139 -0
  385. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/logiql_highlight_rules.js +119 -0
  386. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/logiql_test.js +98 -0
  387. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/lsl.js +92 -0
  388. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/lsl_highlight_rules.js +123 -0
  389. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/lua.js +27 -6
  390. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/lua/luaparse.js +1989 -0
  391. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/lua_highlight_rules.js +55 -272
  392. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/lua_worker.js +70 -0
  393. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/luapage.js +6 -4
  394. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/luapage_highlight_rules.js +21 -14
  395. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/lucene.js +5 -2
  396. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/makefile.js +6 -10
  397. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/makefile_highlight_rules.js +22 -22
  398. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/markdown.js +12 -11
  399. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/markdown_highlight_rules.js +130 -89
  400. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/mask.js +84 -0
  401. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/mask_highlight_rules.js +309 -0
  402. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/matching_brace_outdent.js +1 -6
  403. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/matlab.js +55 -0
  404. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/matlab_highlight_rules.js +262 -0
  405. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/mel.js +56 -0
  406. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/mel_highlight_rules.js +133 -0
  407. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/mushcode.js +116 -0
  408. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/mushcode_highlight_rules.js +569 -0
  409. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/mysql.js +51 -0
  410. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/mysql_highlight_rules.js +122 -0
  411. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/nix.js +62 -0
  412. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/nix_highlight_rules.js +119 -0
  413. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/objectivec.js +4 -5
  414. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/objectivec_highlight_rules.js +137 -149
  415. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/ocaml.js +4 -3
  416. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/ocaml_highlight_rules.js +0 -4
  417. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/pascal.js +67 -0
  418. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/pascal_highlight_rules.js +127 -0
  419. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/perl.js +10 -30
  420. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/perl_highlight_rules.js +17 -7
  421. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/pgsql.js +23 -51
  422. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/pgsql_highlight_rules.js +334 -302
  423. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/php.js +59 -38
  424. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/php/php.js +5031 -0
  425. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/php_highlight_rules.js +72 -52
  426. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/php_test.js +65 -0
  427. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/php_worker.js +77 -0
  428. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/plain_text.js +55 -0
  429. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/{keyboard/vim/maps/aliases.js → mode/plain_text_test.js} +21 -59
  430. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/powershell.js +7 -4
  431. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/powershell_highlight_rules.js +0 -3
  432. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/{xquery/JSONParseTreeHandler.js → praat.js} +45 -53
  433. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/praat_highlight_rules.js +262 -0
  434. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/prolog.js +62 -0
  435. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/prolog_highlight_rules.js +238 -0
  436. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/properties.js +48 -0
  437. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/properties_highlight_rules.js +86 -0
  438. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/protobuf.js +63 -0
  439. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/protobuf_highlight_rules.js +66 -0
  440. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/python.js +5 -31
  441. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/python_highlight_rules.js +50 -24
  442. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/r.js +37 -18
  443. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/r_highlight_rules.js +29 -11
  444. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/rdoc.js +36 -11
  445. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/rdoc_highlight_rules.js +27 -7
  446. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/rhtml.js +31 -11
  447. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/rhtml_highlight_rules.js +31 -14
  448. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/ruby.js +26 -36
  449. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/ruby_highlight_rules.js +153 -33
  450. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/{css_highlight_rules_test.js → ruby_test.js} +24 -39
  451. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/rust.js +58 -0
  452. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/rust_highlight_rules.js +158 -0
  453. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/sass.js +52 -0
  454. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/sass_highlight_rules.js +79 -0
  455. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/scad.js +5 -30
  456. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/scad_highlight_rules.js +0 -4
  457. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/scala.js +2 -2
  458. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/scala_highlight_rules.js +1 -6
  459. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/scheme.js +56 -0
  460. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/scheme_highlight_rules.js +123 -0
  461. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/scss.js +9 -4
  462. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/scss_highlight_rules.js +7 -8
  463. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/sh.js +10 -31
  464. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/sh_highlight_rules.js +85 -11
  465. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/sjs.js +56 -0
  466. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/sjs_highlight_rules.js +233 -0
  467. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/smarty.js +51 -0
  468. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/smarty_highlight_rules.js +139 -0
  469. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/snippets.js +113 -0
  470. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/soy_template.js +60 -0
  471. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/soy_template_highlight_rules.js +356 -0
  472. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/space.js +21 -0
  473. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/space_highlight_rules.js +56 -0
  474. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/sql.js +3 -30
  475. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/sql_highlight_rules.js +6 -1
  476. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/stylus.js +5 -5
  477. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/stylus_highlight_rules.js +32 -42
  478. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/svg.js +3 -5
  479. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/svg_highlight_rules.js +3 -18
  480. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/tcl.js +4 -30
  481. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/tcl_highlight_rules.js +5 -13
  482. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/tex.js +30 -10
  483. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/tex_highlight_rules.js +27 -7
  484. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/text.js +266 -29
  485. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/text_highlight_rules.js +129 -15
  486. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/text_test.js +2 -2
  487. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/textile.js +3 -2
  488. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/toml.js +56 -0
  489. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/toml_highlight_rules.js +103 -0
  490. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/twig.js +81 -0
  491. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/twig_highlight_rules.js +166 -0
  492. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/typescript.js +2 -8
  493. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/typescript_highlight_rules.js +16 -16
  494. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/vala.js +105 -0
  495. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/vala_highlight_rules.js +457 -0
  496. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/vbscript.js +60 -0
  497. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/vbscript_highlight_rules.js +246 -0
  498. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/velocity.js +58 -0
  499. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/velocity_highlight_rules.js +177 -0
  500. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/verilog.js +54 -0
  501. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/verilog_highlight_rules.js +101 -0
  502. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/vhdl.js +52 -0
  503. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/vhdl_highlight_rules.js +115 -0
  504. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xml.js +25 -8
  505. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xml/dom-parser.js +260 -0
  506. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xml/dom.js +1138 -0
  507. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xml/sax.js +592 -0
  508. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xml_highlight_rules.js +185 -45
  509. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xml_test.js +3 -3
  510. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xml_worker.js +92 -0
  511. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xquery.js +107 -88
  512. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/Readme.md +1 -6
  513. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/jsoniq_lexer.js +4453 -0
  514. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/xqlint.js +78911 -0
  515. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/xquery_lexer.js +4422 -0
  516. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xquery_worker.js +66 -29
  517. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/yaml.js +5 -3
  518. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/yaml_highlight_rules.js +2 -13
  519. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mouse/default_gutter_handler.js +50 -28
  520. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mouse/default_handlers.js +70 -137
  521. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mouse/dragdrop_handler.js +428 -0
  522. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mouse/fold_handler.js +6 -23
  523. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mouse/mouse_event.js +6 -9
  524. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mouse/mouse_handler.js +83 -39
  525. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/{mode/liquid_highlight_rules_test.js → mouse/mouse_handler_test.js} +27 -34
  526. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mouse/multi_select_handler.js +94 -38
  527. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/multi_select.js +192 -115
  528. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/multi_select_test.js +124 -18
  529. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/occur.js +193 -0
  530. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/occur_test.js +154 -0
  531. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/placeholder.js +9 -4
  532. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/placeholder_test.js +2 -1
  533. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/range.js +81 -102
  534. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/range_list.js +38 -21
  535. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/range_list_test.js +20 -1
  536. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/range_test.js +1 -1
  537. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/renderloop.js +1 -1
  538. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/requirejs/text.js +9 -8
  539. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/requirejs/text_build.js +60 -0
  540. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/scrollbar.js +163 -32
  541. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/search.js +38 -19
  542. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/search_highlight.js +1 -3
  543. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/search_test.js +33 -0
  544. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/selection.js +167 -83
  545. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/selection_test.js +22 -7
  546. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets.js +949 -0
  547. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/_.snippets +240 -0
  548. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/_all_modes.js +7 -0
  549. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/_all_modes.snippets +0 -0
  550. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/abap.js +7 -0
  551. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/abap.snippets +0 -0
  552. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/abc.js +7 -0
  553. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/abc.snippets +31 -0
  554. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/actionscript.js +7 -0
  555. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/actionscript.snippets +157 -0
  556. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/ada.js +7 -0
  557. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/ada.snippets +0 -0
  558. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/all_modes.js +7 -0
  559. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/all_modes.snippets +0 -0
  560. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/apache.snippets +35 -0
  561. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/apache_conf.js +7 -0
  562. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/apache_conf.snippets +0 -0
  563. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/applescript.js +7 -0
  564. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/applescript.snippets +0 -0
  565. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/asciidoc.js +7 -0
  566. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/asciidoc.snippets +0 -0
  567. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/assembly_x86.js +7 -0
  568. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/assembly_x86.snippets +0 -0
  569. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/autohotkey.js +7 -0
  570. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/autohotkey.snippets +0 -0
  571. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/autoit.snippets +66 -0
  572. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/batchfile.js +7 -0
  573. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/batchfile.snippets +0 -0
  574. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/c.snippets +235 -0
  575. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/c9search.js +7 -0
  576. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/c9search.snippets +0 -0
  577. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/c_cpp.js +7 -0
  578. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/c_cpp.snippets +131 -0
  579. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/chef.snippets +204 -0
  580. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/cirru.js +7 -0
  581. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/cirru.snippets +0 -0
  582. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/clojure.js +7 -0
  583. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/clojure.snippets +90 -0
  584. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/cmake.snippets +58 -0
  585. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/cobol.js +7 -0
  586. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/cobol.snippets +0 -0
  587. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/coffee.js +7 -0
  588. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/coffee.snippets +95 -0
  589. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/coldfusion.js +7 -0
  590. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/coldfusion.snippets +0 -0
  591. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/cs.snippets +374 -0
  592. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/csharp.js +7 -0
  593. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/csharp.snippets +0 -0
  594. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/css.js +7 -0
  595. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/css.snippets +967 -0
  596. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/curly.js +7 -0
  597. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/curly.snippets +0 -0
  598. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/d.js +7 -0
  599. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/d.snippets +0 -0
  600. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/dart.js +7 -0
  601. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/dart.snippets +83 -0
  602. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/diff.js +7 -0
  603. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/diff.snippets +11 -0
  604. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/django.js +7 -0
  605. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/django.snippets +108 -0
  606. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/dockerfile.js +7 -0
  607. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/dockerfile.snippets +0 -0
  608. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/dot.js +7 -0
  609. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/dot.snippets +0 -0
  610. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/dummy.js +7 -0
  611. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/dummy_syntax.js +7 -0
  612. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/eiffel.js +7 -0
  613. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/eiffel.snippets +0 -0
  614. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/ejs.js +7 -0
  615. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/ejs.snippets +0 -0
  616. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/elixir.js +7 -0
  617. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/elixir.snippets +0 -0
  618. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/elm.js +7 -0
  619. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/elm.snippets +0 -0
  620. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/erlang.js +7 -0
  621. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/erlang.snippets +160 -0
  622. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/eruby.snippets +113 -0
  623. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/falcon.snippets +71 -0
  624. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/forth.js +7 -0
  625. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/forth.snippets +0 -0
  626. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/ftl.js +7 -0
  627. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/ftl.snippets +0 -0
  628. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/gcode.js +7 -0
  629. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/gcode.snippets +0 -0
  630. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/gherkin.js +7 -0
  631. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/gherkin.snippets +0 -0
  632. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/gitignore.js +7 -0
  633. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/gitignore.snippets +0 -0
  634. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/glsl.js +7 -0
  635. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/glsl.snippets +0 -0
  636. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/go.snippets +201 -0
  637. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/golang.js +7 -0
  638. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/golang.snippets +0 -0
  639. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/groovy.js +7 -0
  640. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/groovy.snippets +0 -0
  641. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/haml.js +7 -0
  642. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/haml.snippets +20 -0
  643. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/handlebars.js +7 -0
  644. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/handlebars.snippets +0 -0
  645. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/haskell.js +7 -0
  646. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/haskell.snippets +82 -0
  647. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/haxe.js +7 -0
  648. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/haxe.snippets +0 -0
  649. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/html.js +7 -0
  650. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/html.snippets +828 -0
  651. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/html_ruby.js +7 -0
  652. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/html_ruby.snippets +0 -0
  653. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/htmldjango.snippets +136 -0
  654. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/htmltornado.snippets +55 -0
  655. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/ini.js +7 -0
  656. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/ini.snippets +0 -0
  657. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/io.js +69 -0
  658. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/io.snippets +0 -0
  659. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/jack.js +7 -0
  660. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/jack.snippets +0 -0
  661. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/jade.js +7 -0
  662. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/jade.snippets +0 -0
  663. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/java.js +7 -0
  664. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/java.snippets +240 -0
  665. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/javascript-jquery.snippets +589 -0
  666. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/javascript.js +7 -0
  667. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/javascript.snippets +195 -0
  668. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/json.js +7 -0
  669. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/json.snippets +0 -0
  670. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/jsoniq.js +7 -0
  671. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/jsoniq.snippets +61 -0
  672. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/jsp.js +7 -0
  673. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/jsp.snippets +99 -0
  674. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/jsx.js +7 -0
  675. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/jsx.snippets +0 -0
  676. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/julia.js +7 -0
  677. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/julia.snippets +0 -0
  678. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/latex.js +7 -0
  679. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/latex.snippets +0 -0
  680. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/ledger.snippets +5 -0
  681. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/less.js +7 -0
  682. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/less.snippets +0 -0
  683. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/liquid.js +7 -0
  684. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/liquid.snippets +0 -0
  685. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/lisp.js +7 -0
  686. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/lisp.snippets +0 -0
  687. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/livescript.js +7 -0
  688. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/livescript.snippets +0 -0
  689. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/logiql.js +7 -0
  690. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/logiql.snippets +0 -0
  691. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/lsl.js +7 -0
  692. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/lsl.snippets +1066 -0
  693. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/lua.js +7 -0
  694. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/lua.snippets +21 -0
  695. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/luapage.js +7 -0
  696. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/luapage.snippets +0 -0
  697. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/lucene.js +7 -0
  698. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/lucene.snippets +0 -0
  699. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/makefile.js +7 -0
  700. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/makefile.snippets +4 -0
  701. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/mako.snippets +54 -0
  702. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/markdown.js +7 -0
  703. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/markdown.snippets +88 -0
  704. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/matlab.js +7 -0
  705. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/matlab.snippets +0 -0
  706. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/mel.js +7 -0
  707. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/mel.snippets +0 -0
  708. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/mushcode.js +7 -0
  709. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/mushcode.snippets +0 -0
  710. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/mushcode_high_rules.js +7 -0
  711. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/mushcode_high_rules.snippets +0 -0
  712. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/mysql.js +7 -0
  713. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/mysql.snippets +0 -0
  714. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/nix.js +7 -0
  715. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/nix.snippets +0 -0
  716. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/objc.snippets +247 -0
  717. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/objectivec.js +7 -0
  718. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/objectivec.snippets +0 -0
  719. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/ocaml.js +7 -0
  720. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/ocaml.snippets +0 -0
  721. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/pascal.js +7 -0
  722. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/pascal.snippets +0 -0
  723. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/perl.js +7 -0
  724. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/perl.snippets +347 -0
  725. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/pgsql.js +7 -0
  726. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/pgsql.snippets +0 -0
  727. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/php.js +7 -0
  728. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/php.snippets +377 -0
  729. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/plain_text.js +7 -0
  730. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/plain_text.snippets +0 -0
  731. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/powershell.js +7 -0
  732. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/powershell.snippets +0 -0
  733. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/praat.js +7 -0
  734. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/praat.snippets +0 -0
  735. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/prolog.js +7 -0
  736. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/prolog.snippets +0 -0
  737. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/properties.js +7 -0
  738. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/properties.snippets +0 -0
  739. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/protobuf.js +7 -0
  740. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/protobuf.snippets +0 -0
  741. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/python.js +7 -0
  742. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/python.snippets +158 -0
  743. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/r.js +7 -0
  744. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/r.snippets +121 -0
  745. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/rdoc.js +7 -0
  746. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/rdoc.snippets +0 -0
  747. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/rhtml.js +7 -0
  748. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/rhtml.snippets +0 -0
  749. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/rst.snippets +22 -0
  750. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/ruby.js +7 -0
  751. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/ruby.snippets +928 -0
  752. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/rust.js +7 -0
  753. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/rust.snippets +0 -0
  754. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/sass.js +7 -0
  755. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/sass.snippets +0 -0
  756. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/scad.js +7 -0
  757. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/scad.snippets +0 -0
  758. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/scala.js +7 -0
  759. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/scala.snippets +0 -0
  760. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/scheme.js +7 -0
  761. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/scheme.snippets +0 -0
  762. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/scss.js +7 -0
  763. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/scss.snippets +0 -0
  764. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/sh.js +7 -0
  765. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/sh.snippets +83 -0
  766. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/sjs.js +7 -0
  767. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/sjs.snippets +0 -0
  768. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/smarty.js +7 -0
  769. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/smarty.snippets +0 -0
  770. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/snippets.js +7 -0
  771. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/snippets.snippets +9 -0
  772. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/soy_template.js +7 -0
  773. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/soy_template.snippets +0 -0
  774. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/space.js +7 -0
  775. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/space.snippets +0 -0
  776. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/sql.js +7 -0
  777. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/sql.snippets +26 -0
  778. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/stylus.js +7 -0
  779. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/stylus.snippets +0 -0
  780. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/svg.js +7 -0
  781. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/svg.snippets +0 -0
  782. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/tcl.js +7 -0
  783. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/tcl.snippets +92 -0
  784. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/tex.js +7 -0
  785. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/tex.snippets +191 -0
  786. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/text.js +7 -0
  787. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/text.snippets +0 -0
  788. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/textile.js +7 -0
  789. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/textile.snippets +30 -0
  790. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/tmsnippet.snippets +0 -0
  791. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/toml.js +7 -0
  792. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/toml.snippets +0 -0
  793. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/twig.js +7 -0
  794. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/twig.snippets +0 -0
  795. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/typescript.js +7 -0
  796. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/typescript.snippets +0 -0
  797. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/vala.js +195 -0
  798. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/vala.snippets +0 -0
  799. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/vbscript.js +7 -0
  800. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/vbscript.snippets +0 -0
  801. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/velocity.js +8 -0
  802. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/velocity.snippets +28 -0
  803. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/verilog.js +7 -0
  804. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/verilog.snippets +0 -0
  805. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/vhdl.js +7 -0
  806. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/vhdl.snippets +0 -0
  807. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/xml.js +7 -0
  808. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/xml.snippets +0 -0
  809. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/xquery.js +7 -0
  810. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/xquery.snippets +61 -0
  811. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/xslt.snippets +97 -0
  812. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/yaml.js +7 -0
  813. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets/yaml.snippets +0 -0
  814. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/snippets_test.js +131 -0
  815. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/split.js +3 -3
  816. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/test/all_browser.js +20 -7
  817. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/test/asyncjs/assert.js +2 -2
  818. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/test/mockrenderer.js +8 -0
  819. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/ambiance.css +6 -2
  820. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/chaos.css +154 -0
  821. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/chaos.js +33 -0
  822. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/chrome.css +5 -9
  823. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/clouds.css +3 -15
  824. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/clouds.js +1 -1
  825. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/clouds_midnight.css +4 -16
  826. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/clouds_midnight.js +1 -1
  827. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/cobalt.css +16 -26
  828. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/cobalt.js +1 -1
  829. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/crimson_editor.css +2 -10
  830. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/dawn.css +10 -20
  831. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/dawn.js +1 -1
  832. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/dreamweaver.css +9 -12
  833. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/eclipse.css +16 -9
  834. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/github.css +3 -10
  835. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/idle_fingers.css +5 -17
  836. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/idle_fingers.js +1 -1
  837. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/katzenmilch.css +140 -0
  838. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/katzenmilch.js +39 -0
  839. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/kr_theme.css +9 -20
  840. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/kr_theme.js +1 -1
  841. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/kuroir.css +67 -0
  842. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/kuroir.js +39 -0
  843. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore.css +4 -16
  844. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore.js +1 -1
  845. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore_soft.css +4 -16
  846. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore_soft.js +1 -1
  847. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/mono_industrial.css +5 -17
  848. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/mono_industrial.js +1 -1
  849. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/monokai.css +14 -20
  850. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/monokai.js +1 -1
  851. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/pastel_on_dark.css +4 -16
  852. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/pastel_on_dark.js +1 -1
  853. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_dark.css +8 -20
  854. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_dark.js +1 -1
  855. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_light.css +6 -18
  856. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_light.js +1 -1
  857. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/terminal.css +132 -0
  858. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/terminal.js +39 -0
  859. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/textmate.css +5 -9
  860. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow.css +4 -15
  861. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow.js +1 -1
  862. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night.css +5 -16
  863. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night.js +1 -1
  864. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_blue.css +6 -17
  865. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_blue.js +1 -1
  866. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_bright.css +21 -16
  867. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_bright.js +1 -1
  868. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_eighties.css +10 -17
  869. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_eighties.js +1 -1
  870. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/twilight.css +6 -16
  871. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/twilight.js +1 -1
  872. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/vibrant_ink.css +4 -12
  873. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/vibrant_ink.js +1 -1
  874. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/xcode.css +4 -12
  875. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/theme/xcode.js +1 -1
  876. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/token_iterator.js +4 -3
  877. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/tokenizer.js +246 -78
  878. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/tokenizer_dev.js +71 -93
  879. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/tokenizer_test.js +97 -0
  880. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/tooltip.js +138 -0
  881. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/undomanager.js +63 -30
  882. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/virtual_renderer.js +788 -403
  883. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/worker/mirror.js +9 -3
  884. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/worker/worker.js +92 -55
  885. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/worker/worker_client.js +90 -52
  886. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/worker/worker_test.js +125 -0
  887. data/lib/gollum/public/gollum/livepreview/js/livepreview.js +18 -12
  888. data/lib/gollum/public/gollum/livepreview/readme.md +1 -1
  889. data/lib/gollum/templates/layout.mustache +1 -1
  890. data/lib/gollum/{public/gollum/livepreview/index.html → templates/livepreview.mustache} +23 -1
  891. data/lib/gollum/views/livepreview.rb +13 -0
  892. metadata +569 -37
  893. data/lib/gollum/editing_auth.rb +0 -34
  894. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/keyboard/vim/commands.js +0 -561
  895. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/keyboard/vim/maps/motions.js +0 -593
  896. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/keyboard/vim/maps/operators.js +0 -196
  897. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/keyboard/vim/maps/util.js +0 -134
  898. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/_test/test_highlight_rules.js +0 -144
  899. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/coffee_highlight_rules_test.js +0 -266
  900. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/html_highlight_rules_test.js +0 -186
  901. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_highlight_rules_test.js +0 -218
  902. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/lucene_highlight_rules_test.js +0 -99
  903. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/markdown_highlight_rules_test.js +0 -100
  904. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/ruby_highlight_rules_test.js +0 -108
  905. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xml_highlight_rules_test.js +0 -208
  906. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xml_util.js +0 -112
  907. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/XQueryParser.js +0 -32982
  908. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/visitors/SyntaxHighlighter.js +0 -316
  909. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mode/xquery_highlight_rules.js +0 -145
  910. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/mouse/dragdrop.js +0 -98
  911. data/lib/gollum/public/gollum/livepreview/js/ace/lib/ace/worker/worker_sourcemint.js +0 -73
@@ -0,0 +1,3866 @@
1
+
2
+ if (typeof process !== "undefined") {
3
+ require("amd-loader");
4
+ }
5
+
6
+ define(function(require, exports, module) {
7
+
8
+ var EditSession = require("./../edit_session").EditSession;
9
+ var Editor = require("./../editor").Editor;
10
+ var UndoManager = require("./../undomanager").UndoManager;
11
+ var MockRenderer = require("./../test/mockrenderer").MockRenderer;
12
+ var JavaScriptMode = require("./../mode/javascript").Mode;
13
+ var VirtualRenderer = require("./../virtual_renderer").VirtualRenderer;
14
+ var assert = require("./../test/assertions");
15
+ var keys = require("./../lib/keys");
16
+ var vim = require("./vim");
17
+
18
+ var el = document.createElement("div");
19
+ el.style.position = "fixed";
20
+ el.style.left = "20px";
21
+ el.style.top = "30px";
22
+ el.style.width = "500px";
23
+ el.style.height = "300px";
24
+ document.body.appendChild(el);
25
+
26
+ if (!el.getBoundingClientRect)
27
+ return console.log("Skipping test: This test only runs in the browser");
28
+
29
+ var renderer = new VirtualRenderer(el);
30
+ editor = new Editor(renderer);//(new MockRenderer());
31
+ editor.session.setUndoManager(new UndoManager());
32
+ editor.session.setUseWorker(false);
33
+ editor.session.setMode(new JavaScriptMode());
34
+ function CodeMirror(place, opts) {
35
+ if (opts.value != null)
36
+ editor.session.setValue(opts.value);
37
+ editor.setOption("wrap", opts.lineWrapping);
38
+ editor.setOption("useSoftTabs", !opts.indentWithTabs);
39
+ editor.setKeyboardHandler(null);
40
+ editor.setKeyboardHandler(vim.handler);
41
+ var cm = editor.state.cm;
42
+ cm.setOption("tabSize", opts.tabSize || 4);
43
+ cm.setOption("indentUnit", opts.indentUnit || 2);
44
+
45
+ cm.setSize = function(w, h) {
46
+ var changed = false;
47
+ if (w && editor.w != w) {
48
+ changed = true;
49
+ el.style.width = (editor.w = w) + "px";
50
+ }
51
+ if (h && editor.h != h) {
52
+ changed = true;
53
+ el.style.height = (editor.h = h) + "px";
54
+ }
55
+ if (changed)
56
+ editor.resize(true);
57
+ };
58
+ cm.setSize(500, 300);
59
+ return cm;
60
+ }
61
+ for (var key in vim.CodeMirror)
62
+ CodeMirror[key] = vim.CodeMirror[key];
63
+ var editor;
64
+ var i = 0;
65
+ function test(name, fn) {
66
+ // if (name != 'vim_search_history') return
67
+ // for (i = 0; i < 1000; i++)
68
+ // exports["test " + name + i] = fn; // vim_ex_global_confirm
69
+ if (i++ < 0 || /- /.test(name))
70
+ exports["test " + name] = function() {};
71
+ else
72
+ exports["test " + name] = fn;
73
+ }
74
+
75
+ vim.CodeMirror.Vim.unmap("Y");
76
+
77
+
78
+
79
+ // cm.setBookmark({ch: 5, line: 0})
80
+ // cm.setBookmark({ch: 4, line: 0})
81
+ // cm.replaceRange("x-", {ch: 4, line: 0}, {ch: 5, line: 0}); [editor.$vimModeHandler.cm.marks[0].find(),editor.$vimModeHandler.cm.marks[1].find()]
82
+
83
+ var lineText, verbose, phantom;
84
+ var Pos = CodeMirror.Pos;
85
+ var place = document.createElement("div");
86
+ var eqPos = assert.deepEqual;
87
+ var eq = assert.equal;
88
+ var is = assert.ok;
89
+
90
+
91
+ var code = '' +
92
+ ' wOrd1 (#%\n' +
93
+ ' word3] \n' +
94
+ 'aopop pop 0 1 2 3 4\n' +
95
+ ' (a) [b] {c} \n' +
96
+ 'int getchar(void) {\n' +
97
+ ' static char buf[BUFSIZ];\n' +
98
+ ' static char *bufp = buf;\n' +
99
+ ' if (n == 0) { /* buffer is empty */\n' +
100
+ ' n = read(0, buf, sizeof buf);\n' +
101
+ ' bufp = buf;\n' +
102
+ ' }\n' +
103
+ '\n' +
104
+ ' return (--n >= 0) ? (unsigned char) *bufp++ : EOF;\n' +
105
+ ' \n' +
106
+ '}\n';
107
+
108
+ var lines = (function() {
109
+ lineText = code.split('\n');
110
+ var ret = [];
111
+ for (var i = 0; i < lineText.length; i++) {
112
+ ret[i] = {
113
+ line: i,
114
+ length: lineText[i].length,
115
+ lineText: lineText[i],
116
+ textStart: /^\s*/.exec(lineText[i])[0].length
117
+ };
118
+ }
119
+ return ret;
120
+ })();
121
+ var endOfDocument = makeCursor(lines.length - 1,
122
+ lines[lines.length - 1].length);
123
+ var wordLine = lines[0];
124
+ var bigWordLine = lines[1];
125
+ var charLine = lines[2];
126
+ var bracesLine = lines[3];
127
+ var seekBraceLine = lines[4];
128
+
129
+ var word1 = {
130
+ start: { line: wordLine.line, ch: 1 },
131
+ end: { line: wordLine.line, ch: 5 }
132
+ };
133
+ var word2 = {
134
+ start: { line: wordLine.line, ch: word1.end.ch + 2 },
135
+ end: { line: wordLine.line, ch: word1.end.ch + 4 }
136
+ };
137
+ var word3 = {
138
+ start: { line: bigWordLine.line, ch: 1 },
139
+ end: { line: bigWordLine.line, ch: 5 }
140
+ };
141
+ var bigWord1 = word1;
142
+ var bigWord2 = word2;
143
+ var bigWord3 = {
144
+ start: { line: bigWordLine.line, ch: 1 },
145
+ end: { line: bigWordLine.line, ch: 7 }
146
+ };
147
+ var bigWord4 = {
148
+ start: { line: bigWordLine.line, ch: bigWord1.end.ch + 3 },
149
+ end: { line: bigWordLine.line, ch: bigWord1.end.ch + 7 }
150
+ };
151
+
152
+ var oChars = [ { line: charLine.line, ch: 1 },
153
+ { line: charLine.line, ch: 3 },
154
+ { line: charLine.line, ch: 7 } ];
155
+ var pChars = [ { line: charLine.line, ch: 2 },
156
+ { line: charLine.line, ch: 4 },
157
+ { line: charLine.line, ch: 6 },
158
+ { line: charLine.line, ch: 8 } ];
159
+ var numChars = [ { line: charLine.line, ch: 10 },
160
+ { line: charLine.line, ch: 12 },
161
+ { line: charLine.line, ch: 14 },
162
+ { line: charLine.line, ch: 16 },
163
+ { line: charLine.line, ch: 18 }];
164
+ var parens1 = {
165
+ start: { line: bracesLine.line, ch: 1 },
166
+ end: { line: bracesLine.line, ch: 3 }
167
+ };
168
+ var squares1 = {
169
+ start: { line: bracesLine.line, ch: 5 },
170
+ end: { line: bracesLine.line, ch: 7 }
171
+ };
172
+ var curlys1 = {
173
+ start: { line: bracesLine.line, ch: 9 },
174
+ end: { line: bracesLine.line, ch: 11 }
175
+ };
176
+ var seekOutside = {
177
+ start: { line: seekBraceLine.line, ch: 1 },
178
+ end: { line: seekBraceLine.line, ch: 16 }
179
+ };
180
+ var seekInside = {
181
+ start: { line: seekBraceLine.line, ch: 14 },
182
+ end: { line: seekBraceLine.line, ch: 11 }
183
+ };
184
+
185
+ function copyCursor(cur) {
186
+ return { ch: cur.ch, line: cur.line };
187
+ }
188
+
189
+ function forEach(arr, func) {
190
+ for (var i = 0; i < arr.length; i++) {
191
+ func(arr[i], i, arr);
192
+ }
193
+ }
194
+
195
+ function testVim(name, run, opts, expectedFail) {
196
+ var vimOpts = {
197
+ lineNumbers: true,
198
+ vimMode: true,
199
+ showCursorWhenSelecting: true,
200
+ value: code
201
+ };
202
+ for (var prop in opts) {
203
+ if (opts.hasOwnProperty(prop)) {
204
+ vimOpts[prop] = opts[prop];
205
+ }
206
+ }
207
+ return test('vim_' + name, function() {
208
+ var place = document.getElementById("testground");
209
+ var cm = CodeMirror(place, vimOpts);
210
+ var vim = CodeMirror.Vim.maybeInitVimState_(cm);
211
+
212
+ function doKeysFn(cm) {
213
+ return function(args) {
214
+ if (args instanceof Array) {
215
+ arguments = args;
216
+ }
217
+ for (var i = 0; i < arguments.length; i++) {
218
+ CodeMirror.Vim.handleKey(cm, arguments[i]);
219
+ }
220
+ }
221
+ }
222
+ function doInsertModeKeysFn(cm) {
223
+ return function(args) {
224
+ if (args instanceof Array) { arguments = args; }
225
+ function executeHandler(handler) {
226
+ if (typeof handler == 'string') {
227
+ CodeMirror.commands[handler](cm);
228
+ } else {
229
+ handler(cm);
230
+ }
231
+ return true;
232
+ }
233
+ for (var i = 0; i < arguments.length; i++) {
234
+ var key = arguments[i];
235
+ // Find key in keymap and handle.
236
+ var handled = CodeMirror.lookupKey(key, 'vim-insert', executeHandler);
237
+ // Record for insert mode.
238
+ if (handled == "handled" && cm.state.vim.insertMode && arguments[i] != 'Esc') {
239
+ var lastChange = CodeMirror.Vim.getVimGlobalState_().macroModeState.lastInsertModeChanges;
240
+ if (lastChange) {
241
+ lastChange.changes.push(new CodeMirror.Vim.InsertModeKey(key));
242
+ }
243
+ }
244
+ }
245
+ }
246
+ }
247
+ function doExFn(cm) {
248
+ return function(command) {
249
+ cm.openDialog = helpers.fakeOpenDialog(command);
250
+ helpers.doKeys(':');
251
+ }
252
+ }
253
+ function assertCursorAtFn(cm) {
254
+ return function(line, ch) {
255
+ var pos;
256
+ if (ch == null && typeof line.line == 'number') {
257
+ pos = line;
258
+ } else {
259
+ pos = makeCursor(line, ch);
260
+ }
261
+ eqPos(pos, cm.getCursor());
262
+ }
263
+ }
264
+ function fakeOpenDialog(result) {
265
+ return function(text, callback) {
266
+ return callback(result);
267
+ }
268
+ }
269
+ function fakeOpenNotification(matcher) {
270
+ return function(text) {
271
+ matcher(text);
272
+ }
273
+ }
274
+ var helpers = {
275
+ doKeys: doKeysFn(cm),
276
+ // Warning: Only emulates keymap events, not character insertions. Use
277
+ // replaceRange to simulate character insertions.
278
+ // Keys are in CodeMirror format, NOT vim format.
279
+ doInsertModeKeys: doInsertModeKeysFn(cm),
280
+ doEx: doExFn(cm),
281
+ assertCursorAt: assertCursorAtFn(cm),
282
+ fakeOpenDialog: fakeOpenDialog,
283
+ fakeOpenNotification: fakeOpenNotification,
284
+ getRegisterController: function() {
285
+ return CodeMirror.Vim.getRegisterController();
286
+ }
287
+ }
288
+ CodeMirror.Vim.resetVimGlobalState_();
289
+ var successful = false;
290
+ var savedOpenNotification = cm.openNotification;
291
+ try {
292
+ run(cm, vim, helpers);
293
+ successful = true;
294
+ } finally {
295
+ cm.openNotification = savedOpenNotification;
296
+ // if (!successful || verbose) {
297
+ // place.style.visibility = "visible";
298
+ // } else {
299
+ // place.removeChild(cm.getWrapperElement());
300
+ // }
301
+ }
302
+ }, expectedFail);
303
+ };
304
+ testVim('qq@q', function(cm, vim, helpers) {
305
+ cm.setCursor(0, 0);
306
+ helpers.doKeys('q', 'q', 'l', 'l', 'q');
307
+ helpers.assertCursorAt(0,2);
308
+ helpers.doKeys('@', 'q');
309
+ helpers.assertCursorAt(0,4);
310
+ }, { value: ' '});
311
+ testVim('@@', function(cm, vim, helpers) {
312
+ cm.setCursor(0, 0);
313
+ helpers.doKeys('q', 'q', 'l', 'l', 'q');
314
+ helpers.assertCursorAt(0,2);
315
+ helpers.doKeys('@', 'q');
316
+ helpers.assertCursorAt(0,4);
317
+ helpers.doKeys('@', '@');
318
+ helpers.assertCursorAt(0,6);
319
+ }, { value: ' '});
320
+ var jumplistScene = ''+
321
+ 'word\n'+
322
+ '(word)\n'+
323
+ '{word\n'+
324
+ 'word.\n'+
325
+ '\n'+
326
+ 'word search\n'+
327
+ '}word\n'+
328
+ 'word\n'+
329
+ 'word\n';
330
+ function testJumplist(name, keys, endPos, startPos, dialog) {
331
+ endPos = makeCursor(endPos[0], endPos[1]);
332
+ startPos = makeCursor(startPos[0], startPos[1]);
333
+ testVim(name, function(cm, vim, helpers) {
334
+ CodeMirror.Vim.resetVimGlobalState_();
335
+ if(dialog)cm.openDialog = helpers.fakeOpenDialog('word');
336
+ cm.setCursor(startPos);
337
+ helpers.doKeys.apply(null, keys);
338
+ helpers.assertCursorAt(endPos);
339
+ }, {value: jumplistScene});
340
+ };
341
+ testJumplist('jumplist_H', ['H', '<C-o>'], [5,2], [5,2]);
342
+ testJumplist('jumplist_M', ['M', '<C-o>'], [2,2], [2,2]);
343
+ testJumplist('jumplist_L', ['L', '<C-o>'], [2,2], [2,2]);
344
+ testJumplist('jumplist_[[', ['[', '[', '<C-o>'], [5,2], [5,2]);
345
+ testJumplist('jumplist_]]', [']', ']', '<C-o>'], [2,2], [2,2]);
346
+ testJumplist('jumplist_G', ['G', '<C-o>'], [5,2], [5,2]);
347
+ testJumplist('jumplist_gg', ['g', 'g', '<C-o>'], [5,2], [5,2]);
348
+ testJumplist('jumplist_%', ['%', '<C-o>'], [1,5], [1,5]);
349
+ testJumplist('jumplist_{', ['{', '<C-o>'], [1,5], [1,5]);
350
+ testJumplist('jumplist_}', ['}', '<C-o>'], [1,5], [1,5]);
351
+ testJumplist('jumplist_\'', ['m', 'a', 'h', '\'', 'a', 'h', '<C-i>'], [1,0], [1,5]);
352
+ testJumplist('jumplist_`', ['m', 'a', 'h', '`', 'a', 'h', '<C-i>'], [1,5], [1,5]);
353
+ testJumplist('jumplist_*_cachedCursor', ['*', '<C-o>'], [1,3], [1,3]);
354
+ testJumplist('jumplist_#_cachedCursor', ['#', '<C-o>'], [1,3], [1,3]);
355
+ testJumplist('jumplist_n', ['#', 'n', '<C-o>'], [1,1], [2,3]);
356
+ testJumplist('jumplist_N', ['#', 'N', '<C-o>'], [1,1], [2,3]);
357
+ testJumplist('jumplist_repeat_<c-o>', ['*', '*', '*', '3', '<C-o>'], [2,3], [2,3]);
358
+ testJumplist('jumplist_repeat_<c-i>', ['*', '*', '*', '3', '<C-o>', '2', '<C-i>'], [5,0], [2,3]);
359
+ testJumplist('jumplist_repeated_motion', ['3', '*', '<C-o>'], [2,3], [2,3]);
360
+ testJumplist('jumplist_/', ['/', '<C-o>'], [2,3], [2,3], 'dialog');
361
+ testJumplist('jumplist_?', ['?', '<C-o>'], [2,3], [2,3], 'dialog');
362
+ testJumplist('jumplist_skip_delted_mark<c-o>',
363
+ ['*', 'n', 'n', 'k', 'd', 'k', '<C-o>', '<C-o>', '<C-o>'],
364
+ [0,2], [0,2]);
365
+ testJumplist('jumplist_skip_delted_mark<c-i>',
366
+ ['*', 'n', 'n', 'k', 'd', 'k', '<C-o>', '<C-i>', '<C-i>'],
367
+ [1,0], [0,2]);
368
+
369
+ /**
370
+ * @param name Name of the test
371
+ * @param keys An array of keys or a string with a single key to simulate.
372
+ * @param endPos The expected end position of the cursor.
373
+ * @param startPos The position the cursor should start at, defaults to 0, 0.
374
+ */
375
+ function testMotion(name, keys, endPos, startPos) {
376
+ testVim(name, function(cm, vim, helpers) {
377
+ if (!startPos) {
378
+ startPos = { line: 0, ch: 0 };
379
+ }
380
+ cm.setCursor(startPos);
381
+ helpers.doKeys(keys);
382
+ helpers.assertCursorAt(endPos);
383
+ });
384
+ };
385
+
386
+ function makeCursor(line, ch) {
387
+ return { line: line, ch: ch };
388
+ };
389
+
390
+ function offsetCursor(cur, offsetLine, offsetCh) {
391
+ return { line: cur.line + offsetLine, ch: cur.ch + offsetCh };
392
+ };
393
+
394
+ // Motion tests
395
+ testMotion('|', '|', makeCursor(0, 0), makeCursor(0,4));
396
+ testMotion('|_repeat', ['3', '|'], makeCursor(0, 2), makeCursor(0,4));
397
+ testMotion('h', 'h', makeCursor(0, 0), word1.start);
398
+ testMotion('h_repeat', ['3', 'h'], offsetCursor(word1.end, 0, -3), word1.end);
399
+ testMotion('l', 'l', makeCursor(0, 1));
400
+ testMotion('l_repeat', ['2', 'l'], makeCursor(0, 2));
401
+ testMotion('j', 'j', offsetCursor(word1.end, 1, 0), word1.end);
402
+ testMotion('j_repeat', ['2', 'j'], offsetCursor(word1.end, 2, 0), word1.end);
403
+ testMotion('j_repeat_clip', ['1000', 'j'], endOfDocument);
404
+ testMotion('k', 'k', offsetCursor(word3.end, -1, 0), word3.end);
405
+ testMotion('k_repeat', ['2', 'k'], makeCursor(0, 4), makeCursor(2, 4));
406
+ testMotion('k_repeat_clip', ['1000', 'k'], makeCursor(0, 4), makeCursor(2, 4));
407
+ testMotion('w', 'w', word1.start);
408
+ testMotion('w_multiple_newlines_no_space', 'w', makeCursor(12, 2), makeCursor(11, 2));
409
+ testMotion('w_multiple_newlines_with_space', 'w', makeCursor(14, 0), makeCursor(12, 51));
410
+ testMotion('w_repeat', ['2', 'w'], word2.start);
411
+ testMotion('w_wrap', ['w'], word3.start, word2.start);
412
+ testMotion('w_endOfDocument', 'w', endOfDocument, endOfDocument);
413
+ testMotion('w_start_to_end', ['1000', 'w'], endOfDocument, makeCursor(0, 0));
414
+ testMotion('W', 'W', bigWord1.start);
415
+ testMotion('W_repeat', ['2', 'W'], bigWord3.start, bigWord1.start);
416
+ testMotion('e', 'e', word1.end);
417
+ testMotion('e_repeat', ['2', 'e'], word2.end);
418
+ testMotion('e_wrap', 'e', word3.end, word2.end);
419
+ testMotion('e_endOfDocument', 'e', endOfDocument, endOfDocument);
420
+ testMotion('e_start_to_end', ['1000', 'e'], endOfDocument, makeCursor(0, 0));
421
+ testMotion('b', 'b', word3.start, word3.end);
422
+ testMotion('b_repeat', ['2', 'b'], word2.start, word3.end);
423
+ testMotion('b_wrap', 'b', word2.start, word3.start);
424
+ testMotion('b_startOfDocument', 'b', makeCursor(0, 0), makeCursor(0, 0));
425
+ testMotion('b_end_to_start', ['1000', 'b'], makeCursor(0, 0), endOfDocument);
426
+ testMotion('ge', ['g', 'e'], word2.end, word3.end);
427
+ testMotion('ge_repeat', ['2', 'g', 'e'], word1.end, word3.start);
428
+ testMotion('ge_wrap', ['g', 'e'], word2.end, word3.start);
429
+ testMotion('ge_startOfDocument', ['g', 'e'], makeCursor(0, 0),
430
+ makeCursor(0, 0));
431
+ testMotion('ge_end_to_start', ['1000', 'g', 'e'], makeCursor(0, 0), endOfDocument);
432
+ testMotion('gg', ['g', 'g'], makeCursor(lines[0].line, lines[0].textStart),
433
+ makeCursor(3, 1));
434
+ testMotion('gg_repeat', ['3', 'g', 'g'],
435
+ makeCursor(lines[2].line, lines[2].textStart));
436
+ testMotion('G', 'G',
437
+ makeCursor(lines[lines.length - 1].line, lines[lines.length - 1].textStart),
438
+ makeCursor(3, 1));
439
+ testMotion('G_repeat', ['3', 'G'], makeCursor(lines[2].line,
440
+ lines[2].textStart));
441
+ // TODO: Make the test code long enough to test Ctrl-F and Ctrl-B.
442
+ testMotion('0', '0', makeCursor(0, 0), makeCursor(0, 8));
443
+ testMotion('^', '^', makeCursor(0, lines[0].textStart), makeCursor(0, 8));
444
+ testMotion('+', '+', makeCursor(1, lines[1].textStart), makeCursor(0, 8));
445
+ testMotion('-', '-', makeCursor(0, lines[0].textStart), makeCursor(1, 4));
446
+ testMotion('_', ['6','_'], makeCursor(5, lines[5].textStart), makeCursor(0, 8));
447
+ testMotion('$', '$', makeCursor(0, lines[0].length - 1), makeCursor(0, 1));
448
+ testMotion('$_repeat', ['2', '$'], makeCursor(1, lines[1].length - 1),
449
+ makeCursor(0, 3));
450
+ testMotion('f', ['f', 'p'], pChars[0], makeCursor(charLine.line, 0));
451
+ testMotion('f_repeat', ['2', 'f', 'p'], pChars[2], pChars[0]);
452
+ testMotion('f_num', ['f', '2'], numChars[2], makeCursor(charLine.line, 0));
453
+ testMotion('t', ['t','p'], offsetCursor(pChars[0], 0, -1),
454
+ makeCursor(charLine.line, 0));
455
+ testMotion('t_repeat', ['2', 't', 'p'], offsetCursor(pChars[2], 0, -1),
456
+ pChars[0]);
457
+ testMotion('F', ['F', 'p'], pChars[0], pChars[1]);
458
+ testMotion('F_repeat', ['2', 'F', 'p'], pChars[0], pChars[2]);
459
+ testMotion('T', ['T', 'p'], offsetCursor(pChars[0], 0, 1), pChars[1]);
460
+ testMotion('T_repeat', ['2', 'T', 'p'], offsetCursor(pChars[0], 0, 1), pChars[2]);
461
+ testMotion('%_parens', ['%'], parens1.end, parens1.start);
462
+ testMotion('%_squares', ['%'], squares1.end, squares1.start);
463
+ testMotion('%_braces', ['%'], curlys1.end, curlys1.start);
464
+ testMotion('%_seek_outside', ['%'], seekOutside.end, seekOutside.start);
465
+ testMotion('%_seek_inside', ['%'], seekInside.end, seekInside.start);
466
+ testVim('%_seek_skip', function(cm, vim, helpers) {
467
+ cm.setCursor(0,0);
468
+ helpers.doKeys(['%']);
469
+ helpers.assertCursorAt(0,9);
470
+ }, {value:'01234"("()'});
471
+ testVim('%_skip_string', function(cm, vim, helpers) {
472
+ cm.setCursor(0,0);
473
+ helpers.doKeys(['%']);
474
+ helpers.assertCursorAt(0,4);
475
+ cm.setCursor(0,2);
476
+ helpers.doKeys(['%']);
477
+ helpers.assertCursorAt(0,0);
478
+ }, {value:'(")")'});
479
+ (')')
480
+ testVim('%_skip_comment', function(cm, vim, helpers) {
481
+ cm.setCursor(0,0);
482
+ helpers.doKeys(['%']);
483
+ helpers.assertCursorAt(0,6);
484
+ cm.setCursor(0,3);
485
+ helpers.doKeys(['%']);
486
+ helpers.assertCursorAt(0,0);
487
+ }, {value:'(/*)*/)'});
488
+ // Make sure that moving down after going to the end of a line always leaves you
489
+ // at the end of a line, but preserves the offset in other cases
490
+ testVim('Changing lines after Eol operation', function(cm, vim, helpers) {
491
+ cm.setCursor(0,0);
492
+ helpers.doKeys(['$']);
493
+ helpers.doKeys(['j']);
494
+ // After moving to Eol and then down, we should be at Eol of line 2
495
+ helpers.assertCursorAt({ line: 1, ch: lines[1].length - 1 });
496
+ helpers.doKeys(['j']);
497
+ // After moving down, we should be at Eol of line 3
498
+ helpers.assertCursorAt({ line: 2, ch: lines[2].length - 1 });
499
+ helpers.doKeys(['h']);
500
+ helpers.doKeys(['j']);
501
+ // After moving back one space and then down, since line 4 is shorter than line 2, we should
502
+ // be at Eol of line 2 - 1
503
+ helpers.assertCursorAt({ line: 3, ch: lines[3].length - 1 });
504
+ helpers.doKeys(['j']);
505
+ helpers.doKeys(['j']);
506
+ // After moving down again, since line 3 has enough characters, we should be back to the
507
+ // same place we were at on line 1
508
+ helpers.assertCursorAt({ line: 5, ch: lines[2].length - 2 });
509
+ });
510
+ //making sure gj and gk recover from clipping
511
+ testVim('gj_gk_clipping', function(cm,vim,helpers){
512
+ cm.setCursor(0, 1);
513
+ helpers.doKeys('g','j','g','j');
514
+ helpers.assertCursorAt(2, 1);
515
+ helpers.doKeys('g','k','g','k');
516
+ helpers.assertCursorAt(0, 1);
517
+ },{value: 'line 1\n\nline 2'});
518
+ //testing a mix of j/k and gj/gk
519
+ testVim('j_k_and_gj_gk', function(cm,vim,helpers){
520
+ cm.setSize(120);
521
+ cm.setCursor(0, 0);
522
+ //go to the last character on the first line
523
+ helpers.doKeys('$');
524
+ //move up/down on the column within the wrapped line
525
+ //side-effect: cursor is not locked to eol anymore
526
+ helpers.doKeys('g','k');
527
+ var cur=cm.getCursor();
528
+ eq(cur.line,0);
529
+ is((cur.ch<176),'gk didn\'t move cursor back (1)');
530
+ helpers.doKeys('g','j');
531
+ helpers.assertCursorAt(0, 176);
532
+ //should move to character 177 on line 2 (j/k preserve character index within line)
533
+ helpers.doKeys('j');
534
+ //due to different line wrapping, the cursor can be on a different screen-x now
535
+ //gj and gk preserve screen-x on movement, much like moveV
536
+ helpers.doKeys('3','g','k');
537
+ cur=cm.getCursor();
538
+ eq(cur.line,1);
539
+ is((cur.ch<176),'gk didn\'t move cursor back (2)');
540
+ helpers.doKeys('g','j','2','g','j');
541
+ //should return to the same character-index
542
+ helpers.doKeys('k');
543
+ helpers.assertCursorAt(0, 176);
544
+ },{ lineWrapping:true, value: 'This line is intentially long to test movement of gj and gk over wrapped lines. I will start on the end of this line, then make a step up and back to set the origin for j and k.\nThis line is supposed to be even longer than the previous. I will jump here and make another wiggle with gj and gk, before I jump back to the line above. Both wiggles should not change my cursor\'s target character but both j/k and gj/gk change each other\'s reference position.'});
545
+ testVim('gj_gk', function(cm, vim, helpers) {
546
+ if (phantom) return;
547
+ cm.setSize(120);
548
+ // Test top of document edge case.
549
+ cm.setCursor(0, 4);
550
+ helpers.doKeys('g', 'j');
551
+ helpers.doKeys('10', 'g', 'k');
552
+ helpers.assertCursorAt(0, 4);
553
+
554
+ // Test moving down preserves column position.
555
+ helpers.doKeys('g', 'j');
556
+ var pos1 = cm.getCursor();
557
+ var expectedPos2 = { line: 0, ch: (pos1.ch - 4) * 2 + 4};
558
+ helpers.doKeys('g', 'j');
559
+ helpers.assertCursorAt(expectedPos2);
560
+
561
+ // Move to the last character
562
+ cm.setCursor(0, 0);
563
+ // Move left to reset HSPos
564
+ helpers.doKeys('h');
565
+ // Test bottom of document edge case.
566
+ helpers.doKeys('100', 'g', 'j');
567
+ var endingPos = cm.getCursor();
568
+ is(endingPos != 0, 'gj should not be on wrapped line 0');
569
+ var topLeftCharCoords = cm.charCoords(makeCursor(0, 0));
570
+ var endingCharCoords = cm.charCoords(endingPos);
571
+ is(topLeftCharCoords.left == endingCharCoords.left, 'gj should end up on column 0');
572
+ },{ lineNumbers: false, lineWrapping:true, value: 'Thislineisintentiallylongtotestmovementofgjandgkoverwrappedlines.' });
573
+ testVim('}', function(cm, vim, helpers) {
574
+ cm.setCursor(0, 0);
575
+ helpers.doKeys('}');
576
+ helpers.assertCursorAt(1, 0);
577
+ cm.setCursor(0, 0);
578
+ helpers.doKeys('2', '}');
579
+ helpers.assertCursorAt(4, 0);
580
+ cm.setCursor(0, 0);
581
+ helpers.doKeys('6', '}');
582
+ helpers.assertCursorAt(5, 0);
583
+ }, { value: 'a\n\nb\nc\n\nd' });
584
+ testVim('{', function(cm, vim, helpers) {
585
+ cm.setCursor(5, 0);
586
+ helpers.doKeys('{');
587
+ helpers.assertCursorAt(4, 0);
588
+ cm.setCursor(5, 0);
589
+ helpers.doKeys('2', '{');
590
+ helpers.assertCursorAt(1, 0);
591
+ cm.setCursor(5, 0);
592
+ helpers.doKeys('6', '{');
593
+ helpers.assertCursorAt(0, 0);
594
+ }, { value: 'a\n\nb\nc\n\nd' });
595
+ testVim('paragraph motions', function(cm, vim, helpers) {
596
+ cm.setCursor(10, 0);
597
+ helpers.doKeys('{');
598
+ helpers.assertCursorAt(4, 0);
599
+ helpers.doKeys('{');
600
+ helpers.assertCursorAt(0, 0);
601
+ helpers.doKeys('2', '}');
602
+ helpers.assertCursorAt(7, 0);
603
+ helpers.doKeys('2', '}');
604
+ helpers.assertCursorAt(16, 0);
605
+
606
+ cm.setCursor(9, 0);
607
+ helpers.doKeys('}');
608
+ helpers.assertCursorAt(14, 0);
609
+
610
+ cm.setCursor(6, 0);
611
+ helpers.doKeys('}');
612
+ helpers.assertCursorAt(7, 0);
613
+
614
+ // ip inside empty space
615
+ cm.setCursor(10, 0);
616
+ helpers.doKeys('v', 'i', 'p');
617
+ eqPos(Pos(7, 0), cm.getCursor('anchor'));
618
+ eqPos(Pos(12, 0), cm.getCursor('head'));
619
+ helpers.doKeys('i', 'p');
620
+ eqPos(Pos(7, 0), cm.getCursor('anchor'));
621
+ eqPos(Pos(13, 1), cm.getCursor('head'));
622
+ helpers.doKeys('2', 'i', 'p');
623
+ eqPos(Pos(7, 0), cm.getCursor('anchor'));
624
+ eqPos(Pos(16, 1), cm.getCursor('head'));
625
+
626
+ // should switch to visualLine mode
627
+ cm.setCursor(14, 0);
628
+ helpers.doKeys('<Esc>', 'v', 'i', 'p');
629
+ helpers.assertCursorAt(14, 0);
630
+
631
+ cm.setCursor(14, 0);
632
+ helpers.doKeys('<Esc>', 'V', 'i', 'p');
633
+ eqPos(Pos(16, 1), cm.getCursor('head'));
634
+
635
+ // ap inside empty space
636
+ cm.setCursor(10, 0);
637
+ helpers.doKeys('<Esc>', 'v', 'a', 'p');
638
+ eqPos(Pos(7, 0), cm.getCursor('anchor'));
639
+ eqPos(Pos(13, 1), cm.getCursor('head'));
640
+ helpers.doKeys('a', 'p');
641
+ eqPos(Pos(7, 0), cm.getCursor('anchor'));
642
+ eqPos(Pos(16, 1), cm.getCursor('head'));
643
+
644
+ cm.setCursor(13, 0);
645
+ helpers.doKeys('v', 'a', 'p');
646
+ eqPos(Pos(13, 0), cm.getCursor('anchor'));
647
+ eqPos(Pos(14, 0), cm.getCursor('head'));
648
+
649
+ cm.setCursor(16, 0);
650
+ helpers.doKeys('v', 'a', 'p');
651
+ eqPos(Pos(14, 0), cm.getCursor('anchor'));
652
+ eqPos(Pos(16, 1), cm.getCursor('head'));
653
+
654
+ cm.setCursor(0, 0);
655
+ helpers.doKeys('v', 'a', 'p');
656
+ eqPos(Pos(0, 0), cm.getCursor('anchor'));
657
+ eqPos(Pos(4, 0), cm.getCursor('head'));
658
+
659
+ cm.setCursor(0, 0);
660
+ helpers.doKeys('d', 'i', 'p');
661
+ var register = helpers.getRegisterController().getRegister();
662
+ eq('a\na\n', register.toString());
663
+ is(register.linewise);
664
+ helpers.doKeys('3', 'j', 'p');
665
+ helpers.doKeys('y', 'i', 'p');
666
+ is(register.linewise);
667
+ eq('b\na\na\nc\n', register.toString());
668
+ }, { value: 'a\na\n\n\n\nb\nc\n\n\n\n\n\n\nd\n\ne\nf' });
669
+
670
+ // Operator tests
671
+ testVim('dl', function(cm, vim, helpers) {
672
+ var curStart = makeCursor(0, 0);
673
+ cm.setCursor(curStart);
674
+ helpers.doKeys('d', 'l');
675
+ eq('word1 ', cm.getValue());
676
+ var register = helpers.getRegisterController().getRegister();
677
+ eq(' ', register.toString());
678
+ is(!register.linewise);
679
+ eqPos(curStart, cm.getCursor());
680
+ }, { value: ' word1 ' });
681
+ testVim('dl_eol', function(cm, vim, helpers) {
682
+ cm.setCursor(0, 6);
683
+ helpers.doKeys('d', 'l');
684
+ eq(' word1', cm.getValue());
685
+ var register = helpers.getRegisterController().getRegister();
686
+ eq(' ', register.toString());
687
+ is(!register.linewise);
688
+ helpers.assertCursorAt(0, 6);
689
+ }, { value: ' word1 ' });
690
+ testVim('dl_repeat', function(cm, vim, helpers) {
691
+ var curStart = makeCursor(0, 0);
692
+ cm.setCursor(curStart);
693
+ helpers.doKeys('2', 'd', 'l');
694
+ eq('ord1 ', cm.getValue());
695
+ var register = helpers.getRegisterController().getRegister();
696
+ eq(' w', register.toString());
697
+ is(!register.linewise);
698
+ eqPos(curStart, cm.getCursor());
699
+ }, { value: ' word1 ' });
700
+ testVim('dh', function(cm, vim, helpers) {
701
+ var curStart = makeCursor(0, 3);
702
+ cm.setCursor(curStart);
703
+ helpers.doKeys('d', 'h');
704
+ eq(' wrd1 ', cm.getValue());
705
+ var register = helpers.getRegisterController().getRegister();
706
+ eq('o', register.toString());
707
+ is(!register.linewise);
708
+ eqPos(offsetCursor(curStart, 0 , -1), cm.getCursor());
709
+ }, { value: ' word1 ' });
710
+ testVim('dj', function(cm, vim, helpers) {
711
+ var curStart = makeCursor(0, 3);
712
+ cm.setCursor(curStart);
713
+ helpers.doKeys('d', 'j');
714
+ eq(' word3', cm.getValue());
715
+ var register = helpers.getRegisterController().getRegister();
716
+ eq(' word1\nword2\n', register.toString());
717
+ is(register.linewise);
718
+ helpers.assertCursorAt(0, 1);
719
+ }, { value: ' word1\nword2\n word3' });
720
+ testVim('dj_end_of_document', function(cm, vim, helpers) {
721
+ var curStart = makeCursor(0, 3);
722
+ cm.setCursor(curStart);
723
+ helpers.doKeys('d', 'j');
724
+ eq(' word1 ', cm.getValue());
725
+ var register = helpers.getRegisterController().getRegister();
726
+ eq('', register.toString());
727
+ is(!register.linewise);
728
+ helpers.assertCursorAt(0, 3);
729
+ }, { value: ' word1 ' });
730
+ testVim('dk', function(cm, vim, helpers) {
731
+ var curStart = makeCursor(1, 3);
732
+ cm.setCursor(curStart);
733
+ helpers.doKeys('d', 'k');
734
+ eq(' word3', cm.getValue());
735
+ var register = helpers.getRegisterController().getRegister();
736
+ eq(' word1\nword2\n', register.toString());
737
+ is(register.linewise);
738
+ helpers.assertCursorAt(0, 1);
739
+ }, { value: ' word1\nword2\n word3' });
740
+ testVim('dk_start_of_document', function(cm, vim, helpers) {
741
+ var curStart = makeCursor(0, 3);
742
+ cm.setCursor(curStart);
743
+ helpers.doKeys('d', 'k');
744
+ eq(' word1 ', cm.getValue());
745
+ var register = helpers.getRegisterController().getRegister();
746
+ eq('', register.toString());
747
+ is(!register.linewise);
748
+ helpers.assertCursorAt(0, 3);
749
+ }, { value: ' word1 ' });
750
+ testVim('dw_space', function(cm, vim, helpers) {
751
+ var curStart = makeCursor(0, 0);
752
+ cm.setCursor(curStart);
753
+ helpers.doKeys('d', 'w');
754
+ eq('word1 ', cm.getValue());
755
+ var register = helpers.getRegisterController().getRegister();
756
+ eq(' ', register.toString());
757
+ is(!register.linewise);
758
+ eqPos(curStart, cm.getCursor());
759
+ }, { value: ' word1 ' });
760
+ testVim('dw_word', function(cm, vim, helpers) {
761
+ var curStart = makeCursor(0, 1);
762
+ cm.setCursor(curStart);
763
+ helpers.doKeys('d', 'w');
764
+ eq(' word2', cm.getValue());
765
+ var register = helpers.getRegisterController().getRegister();
766
+ eq('word1 ', register.toString());
767
+ is(!register.linewise);
768
+ eqPos(curStart, cm.getCursor());
769
+ }, { value: ' word1 word2' });
770
+ testVim('dw_only_word', function(cm, vim, helpers) {
771
+ // Test that if there is only 1 word left, dw deletes till the end of the
772
+ // line.
773
+ cm.setCursor(0, 1);
774
+ helpers.doKeys('d', 'w');
775
+ eq(' ', cm.getValue());
776
+ var register = helpers.getRegisterController().getRegister();
777
+ eq('word1 ', register.toString());
778
+ is(!register.linewise);
779
+ helpers.assertCursorAt(0, 1);
780
+ }, { value: ' word1 ' });
781
+ testVim('dw_eol', function(cm, vim, helpers) {
782
+ // Assert that dw does not delete the newline if last word to delete is at end
783
+ // of line.
784
+ cm.setCursor(0, 1);
785
+ helpers.doKeys('d', 'w');
786
+ eq(' \nword2', cm.getValue());
787
+ var register = helpers.getRegisterController().getRegister();
788
+ eq('word1', register.toString());
789
+ is(!register.linewise);
790
+ helpers.assertCursorAt(0, 1);
791
+ }, { value: ' word1\nword2' });
792
+ testVim('dw_eol_with_multiple_newlines', function(cm, vim, helpers) {
793
+ // Assert that dw does not delete the newline if last word to delete is at end
794
+ // of line and it is followed by multiple newlines.
795
+ cm.setCursor(0, 1);
796
+ helpers.doKeys('d', 'w');
797
+ eq(' \n\nword2', cm.getValue());
798
+ var register = helpers.getRegisterController().getRegister();
799
+ eq('word1', register.toString());
800
+ is(!register.linewise);
801
+ helpers.assertCursorAt(0, 1);
802
+ }, { value: ' word1\n\nword2' });
803
+ testVim('dw_empty_line_followed_by_whitespace', function(cm, vim, helpers) {
804
+ cm.setCursor(0, 0);
805
+ helpers.doKeys('d', 'w');
806
+ eq(' \nword', cm.getValue());
807
+ }, { value: '\n \nword' });
808
+ testVim('dw_empty_line_followed_by_word', function(cm, vim, helpers) {
809
+ cm.setCursor(0, 0);
810
+ helpers.doKeys('d', 'w');
811
+ eq('word', cm.getValue());
812
+ }, { value: '\nword' });
813
+ testVim('dw_empty_line_followed_by_empty_line', function(cm, vim, helpers) {
814
+ cm.setCursor(0, 0);
815
+ helpers.doKeys('d', 'w');
816
+ eq('\n', cm.getValue());
817
+ }, { value: '\n\n' });
818
+ testVim('dw_whitespace_followed_by_whitespace', function(cm, vim, helpers) {
819
+ cm.setCursor(0, 0);
820
+ helpers.doKeys('d', 'w');
821
+ eq('\n \n', cm.getValue());
822
+ }, { value: ' \n \n' });
823
+ testVim('dw_whitespace_followed_by_empty_line', function(cm, vim, helpers) {
824
+ cm.setCursor(0, 0);
825
+ helpers.doKeys('d', 'w');
826
+ eq('\n\n', cm.getValue());
827
+ }, { value: ' \n\n' });
828
+ testVim('dw_word_whitespace_word', function(cm, vim, helpers) {
829
+ cm.setCursor(0, 0);
830
+ helpers.doKeys('d', 'w');
831
+ eq('\n \nword2', cm.getValue());
832
+ }, { value: 'word1\n \nword2'})
833
+ testVim('dw_end_of_document', function(cm, vim, helpers) {
834
+ cm.setCursor(1, 2);
835
+ helpers.doKeys('d', 'w');
836
+ eq('\nab', cm.getValue());
837
+ }, { value: '\nabc' });
838
+ testVim('dw_repeat', function(cm, vim, helpers) {
839
+ // Assert that dw does delete newline if it should go to the next line, and
840
+ // that repeat works properly.
841
+ cm.setCursor(0, 1);
842
+ helpers.doKeys('d', '2', 'w');
843
+ eq(' ', cm.getValue());
844
+ var register = helpers.getRegisterController().getRegister();
845
+ eq('word1\nword2', register.toString());
846
+ is(!register.linewise);
847
+ helpers.assertCursorAt(0, 1);
848
+ }, { value: ' word1\nword2' });
849
+ testVim('de_word_start_and_empty_lines', function(cm, vim, helpers) {
850
+ cm.setCursor(0, 0);
851
+ helpers.doKeys('d', 'e');
852
+ eq('\n\n', cm.getValue());
853
+ }, { value: 'word\n\n' });
854
+ testVim('de_word_end_and_empty_lines', function(cm, vim, helpers) {
855
+ cm.setCursor(0, 3);
856
+ helpers.doKeys('d', 'e');
857
+ eq('wor', cm.getValue());
858
+ }, { value: 'word\n\n\n' });
859
+ testVim('de_whitespace_and_empty_lines', function(cm, vim, helpers) {
860
+ cm.setCursor(0, 0);
861
+ helpers.doKeys('d', 'e');
862
+ eq('', cm.getValue());
863
+ }, { value: ' \n\n\n' });
864
+ testVim('de_end_of_document', function(cm, vim, helpers) {
865
+ cm.setCursor(1, 2);
866
+ helpers.doKeys('d', 'e');
867
+ eq('\nab', cm.getValue());
868
+ }, { value: '\nabc' });
869
+ testVim('db_empty_lines', function(cm, vim, helpers) {
870
+ cm.setCursor(2, 0);
871
+ helpers.doKeys('d', 'b');
872
+ eq('\n\n', cm.getValue());
873
+ }, { value: '\n\n\n' });
874
+ testVim('db_word_start_and_empty_lines', function(cm, vim, helpers) {
875
+ cm.setCursor(2, 0);
876
+ helpers.doKeys('d', 'b');
877
+ eq('\nword', cm.getValue());
878
+ }, { value: '\n\nword' });
879
+ testVim('db_word_end_and_empty_lines', function(cm, vim, helpers) {
880
+ cm.setCursor(2, 3);
881
+ helpers.doKeys('d', 'b');
882
+ eq('\n\nd', cm.getValue());
883
+ }, { value: '\n\nword' });
884
+ testVim('db_whitespace_and_empty_lines', function(cm, vim, helpers) {
885
+ cm.setCursor(2, 0);
886
+ helpers.doKeys('d', 'b');
887
+ eq('', cm.getValue());
888
+ }, { value: '\n \n' });
889
+ testVim('db_start_of_document', function(cm, vim, helpers) {
890
+ cm.setCursor(0, 0);
891
+ helpers.doKeys('d', 'b');
892
+ eq('abc\n', cm.getValue());
893
+ }, { value: 'abc\n' });
894
+ testVim('dge_empty_lines', function(cm, vim, helpers) {
895
+ cm.setCursor(1, 0);
896
+ helpers.doKeys('d', 'g', 'e');
897
+ // Note: In real VIM the result should be '', but it's not quite consistent,
898
+ // since 2 newlines are deleted. But in the similar case of word\n\n, only
899
+ // 1 newline is deleted. We'll diverge from VIM's behavior since it's much
900
+ // easier this way.
901
+ eq('\n', cm.getValue());
902
+ }, { value: '\n\n' });
903
+ testVim('dge_word_and_empty_lines', function(cm, vim, helpers) {
904
+ cm.setCursor(1, 0);
905
+ helpers.doKeys('d', 'g', 'e');
906
+ eq('wor\n', cm.getValue());
907
+ }, { value: 'word\n\n'});
908
+ testVim('dge_whitespace_and_empty_lines', function(cm, vim, helpers) {
909
+ cm.setCursor(2, 0);
910
+ helpers.doKeys('d', 'g', 'e');
911
+ eq('', cm.getValue());
912
+ }, { value: '\n \n' });
913
+ testVim('dge_start_of_document', function(cm, vim, helpers) {
914
+ cm.setCursor(0, 0);
915
+ helpers.doKeys('d', 'g', 'e');
916
+ eq('bc\n', cm.getValue());
917
+ }, { value: 'abc\n' });
918
+ testVim('d_inclusive', function(cm, vim, helpers) {
919
+ // Assert that when inclusive is set, the character the cursor is on gets
920
+ // deleted too.
921
+ var curStart = makeCursor(0, 1);
922
+ cm.setCursor(curStart);
923
+ helpers.doKeys('d', 'e');
924
+ eq(' ', cm.getValue());
925
+ var register = helpers.getRegisterController().getRegister();
926
+ eq('word1', register.toString());
927
+ is(!register.linewise);
928
+ eqPos(curStart, cm.getCursor());
929
+ }, { value: ' word1 ' });
930
+ testVim('d_reverse', function(cm, vim, helpers) {
931
+ // Test that deleting in reverse works.
932
+ cm.setCursor(1, 0);
933
+ helpers.doKeys('d', 'b');
934
+ eq(' word2 ', cm.getValue());
935
+ var register = helpers.getRegisterController().getRegister();
936
+ eq('word1\n', register.toString());
937
+ is(!register.linewise);
938
+ helpers.assertCursorAt(0, 1);
939
+ }, { value: ' word1\nword2 ' });
940
+ testVim('dd', function(cm, vim, helpers) {
941
+ cm.setCursor(0, 3);
942
+ var expectedBuffer = cm.getRange({ line: 0, ch: 0 },
943
+ { line: 1, ch: 0 });
944
+ var expectedLineCount = cm.lineCount() - 1;
945
+ helpers.doKeys('d', 'd');
946
+ eq(expectedLineCount, cm.lineCount());
947
+ var register = helpers.getRegisterController().getRegister();
948
+ eq(expectedBuffer, register.toString());
949
+ is(register.linewise);
950
+ helpers.assertCursorAt(0, lines[1].textStart);
951
+ });
952
+ testVim('dd_prefix_repeat', function(cm, vim, helpers) {
953
+ cm.setCursor(0, 3);
954
+ var expectedBuffer = cm.getRange({ line: 0, ch: 0 },
955
+ { line: 2, ch: 0 });
956
+ var expectedLineCount = cm.lineCount() - 2;
957
+ helpers.doKeys('2', 'd', 'd');
958
+ eq(expectedLineCount, cm.lineCount());
959
+ var register = helpers.getRegisterController().getRegister();
960
+ eq(expectedBuffer, register.toString());
961
+ is(register.linewise);
962
+ helpers.assertCursorAt(0, lines[2].textStart);
963
+ });
964
+ testVim('dd_motion_repeat', function(cm, vim, helpers) {
965
+ cm.setCursor(0, 3);
966
+ var expectedBuffer = cm.getRange({ line: 0, ch: 0 },
967
+ { line: 2, ch: 0 });
968
+ var expectedLineCount = cm.lineCount() - 2;
969
+ helpers.doKeys('d', '2', 'd');
970
+ eq(expectedLineCount, cm.lineCount());
971
+ var register = helpers.getRegisterController().getRegister();
972
+ eq(expectedBuffer, register.toString());
973
+ is(register.linewise);
974
+ helpers.assertCursorAt(0, lines[2].textStart);
975
+ });
976
+ testVim('dd_multiply_repeat', function(cm, vim, helpers) {
977
+ cm.setCursor(0, 3);
978
+ var expectedBuffer = cm.getRange({ line: 0, ch: 0 },
979
+ { line: 6, ch: 0 });
980
+ var expectedLineCount = cm.lineCount() - 6;
981
+ helpers.doKeys('2', 'd', '3', 'd');
982
+ eq(expectedLineCount, cm.lineCount());
983
+ var register = helpers.getRegisterController().getRegister();
984
+ eq(expectedBuffer, register.toString());
985
+ is(register.linewise);
986
+ helpers.assertCursorAt(0, lines[6].textStart);
987
+ });
988
+ testVim('dd_lastline', function(cm, vim, helpers) {
989
+ cm.setCursor(cm.lineCount(), 0);
990
+ var expectedLineCount = cm.lineCount() - 1;
991
+ helpers.doKeys('d', 'd');
992
+ eq(expectedLineCount, cm.lineCount());
993
+ helpers.assertCursorAt(cm.lineCount() - 1, 0);
994
+ });
995
+ testVim('dd_only_line', function(cm, vim, helpers) {
996
+ cm.setCursor(0, 0);
997
+ var expectedRegister = cm.getValue() + "\n";
998
+ helpers.doKeys('d','d');
999
+ eq(1, cm.lineCount());
1000
+ eq('', cm.getValue());
1001
+ var register = helpers.getRegisterController().getRegister();
1002
+ eq(expectedRegister, register.toString());
1003
+ }, { value: "thisistheonlyline" });
1004
+ // Yank commands should behave the exact same as d commands, expect that nothing
1005
+ // gets deleted.
1006
+ testVim('yw_repeat', function(cm, vim, helpers) {
1007
+ // Assert that yw does yank newline if it should go to the next line, and
1008
+ // that repeat works properly.
1009
+ var curStart = makeCursor(0, 1);
1010
+ cm.setCursor(curStart);
1011
+ helpers.doKeys('y', '2', 'w');
1012
+ eq(' word1\nword2', cm.getValue());
1013
+ var register = helpers.getRegisterController().getRegister();
1014
+ eq('word1\nword2', register.toString());
1015
+ is(!register.linewise);
1016
+ eqPos(curStart, cm.getCursor());
1017
+ }, { value: ' word1\nword2' });
1018
+ testVim('yy_multiply_repeat', function(cm, vim, helpers) {
1019
+ var curStart = makeCursor(0, 3);
1020
+ cm.setCursor(curStart);
1021
+ var expectedBuffer = cm.getRange({ line: 0, ch: 0 },
1022
+ { line: 6, ch: 0 });
1023
+ var expectedLineCount = cm.lineCount();
1024
+ helpers.doKeys('2', 'y', '3', 'y');
1025
+ eq(expectedLineCount, cm.lineCount());
1026
+ var register = helpers.getRegisterController().getRegister();
1027
+ eq(expectedBuffer, register.toString());
1028
+ is(register.linewise);
1029
+ eqPos(curStart, cm.getCursor());
1030
+ });
1031
+ // Change commands behave like d commands except that it also enters insert
1032
+ // mode. In addition, when the change is linewise, an additional newline is
1033
+ // inserted so that insert mode starts on that line.
1034
+ testVim('cw', function(cm, vim, helpers) {
1035
+ cm.setCursor(0, 0);
1036
+ helpers.doKeys('c', '2', 'w');
1037
+ eq(' word3', cm.getValue());
1038
+ helpers.assertCursorAt(0, 0);
1039
+ }, { value: 'word1 word2 word3'});
1040
+ testVim('cw_repeat', function(cm, vim, helpers) {
1041
+ // Assert that cw does delete newline if it should go to the next line, and
1042
+ // that repeat works properly.
1043
+ var curStart = makeCursor(0, 1);
1044
+ cm.setCursor(curStart);
1045
+ helpers.doKeys('c', '2', 'w');
1046
+ eq(' ', cm.getValue());
1047
+ var register = helpers.getRegisterController().getRegister();
1048
+ eq('word1\nword2', register.toString());
1049
+ is(!register.linewise);
1050
+ eqPos(curStart, cm.getCursor());
1051
+ eq('vim-insert', cm.getOption('keyMap'));
1052
+ }, { value: ' word1\nword2' });
1053
+ testVim('cc_multiply_repeat', function(cm, vim, helpers) {
1054
+ cm.setCursor(0, 3);
1055
+ var expectedBuffer = cm.getRange({ line: 0, ch: 0 },
1056
+ { line: 6, ch: 0 });
1057
+ var expectedLineCount = cm.lineCount() - 5;
1058
+ helpers.doKeys('2', 'c', '3', 'c');
1059
+ eq(expectedLineCount, cm.lineCount());
1060
+ var register = helpers.getRegisterController().getRegister();
1061
+ eq(expectedBuffer, register.toString());
1062
+ is(register.linewise);
1063
+ eq('vim-insert', cm.getOption('keyMap'));
1064
+ });
1065
+ testVim('cc_should_not_append_to_document', function(cm, vim, helpers) {
1066
+ var expectedLineCount = cm.lineCount();
1067
+ cm.setCursor(cm.lastLine(), 0);
1068
+ helpers.doKeys('c', 'c');
1069
+ eq(expectedLineCount, cm.lineCount());
1070
+ });
1071
+ function fillArray(val, times) {
1072
+ var arr = [];
1073
+ for (var i = 0; i < times; i++) {
1074
+ arr.push(val);
1075
+ }
1076
+ return arr;
1077
+ }
1078
+ testVim('c_visual_block', function(cm, vim, helpers) {
1079
+ cm.setCursor(0, 1);
1080
+ helpers.doKeys('<C-v>', '2', 'j', 'l', 'l', 'l', 'c');
1081
+ var replacement = fillArray('hello', 3);
1082
+ cm.replaceSelections(replacement);
1083
+ eq('1hello\n5hello\nahellofg', cm.getValue());
1084
+ helpers.doKeys('<Esc>');
1085
+ cm.setCursor(2, 3);
1086
+ helpers.doKeys('<C-v>', '2', 'k', 'h', 'C');
1087
+ replacement = fillArray('world', 3);
1088
+ cm.replaceSelections(replacement);
1089
+ eq('1hworld\n5hworld\nahworld', cm.getValue());
1090
+ }, {value: '1234\n5678\nabcdefg'});
1091
+ testVim('c_visual_block_replay', function(cm, vim, helpers) {
1092
+ cm.setCursor(0, 1);
1093
+ helpers.doKeys('<C-v>', '2', 'j', 'l', 'c');
1094
+ var replacement = fillArray('fo', 3);
1095
+ cm.replaceSelections(replacement);
1096
+ eq('1fo4\n5fo8\nafodefg', cm.getValue());
1097
+ helpers.doKeys('<Esc>');
1098
+ cm.setCursor(0, 0);
1099
+ helpers.doKeys('.');
1100
+ eq('foo4\nfoo8\nfoodefg', cm.getValue());
1101
+ }, {value: '1234\n5678\nabcdefg'});
1102
+
1103
+ testVim('d_visual_block', function(cm, vim, helpers) {
1104
+ cm.setCursor(0, 1);
1105
+ helpers.doKeys('<C-v>', '2', 'j', 'l', 'l', 'l', 'd');
1106
+ eq('1\n5\nafg', cm.getValue());
1107
+ }, {value: '1234\n5678\nabcdefg'});
1108
+ testVim('D_visual_block', function(cm, vim, helpers) {
1109
+ cm.setCursor(0, 1);
1110
+ helpers.doKeys('<C-v>', '2', 'j', 'l', 'D');
1111
+ eq('1\n5\na', cm.getValue());
1112
+ }, {value: '1234\n5678\nabcdefg'});
1113
+
1114
+ // Swapcase commands edit in place and do not modify registers.
1115
+ testVim('g~w_repeat', function(cm, vim, helpers) {
1116
+ // Assert that dw does delete newline if it should go to the next line, and
1117
+ // that repeat works properly.
1118
+ var curStart = makeCursor(0, 1);
1119
+ cm.setCursor(curStart);
1120
+ helpers.doKeys('g', '~', '2', 'w');
1121
+ eq(' WORD1\nWORD2', cm.getValue());
1122
+ var register = helpers.getRegisterController().getRegister();
1123
+ eq('', register.toString());
1124
+ is(!register.linewise);
1125
+ eqPos(curStart, cm.getCursor());
1126
+ }, { value: ' word1\nword2' });
1127
+ testVim('g~g~', function(cm, vim, helpers) {
1128
+ var curStart = makeCursor(0, 3);
1129
+ cm.setCursor(curStart);
1130
+ var expectedLineCount = cm.lineCount();
1131
+ var expectedValue = cm.getValue().toUpperCase();
1132
+ helpers.doKeys('2', 'g', '~', '3', 'g', '~');
1133
+ eq(expectedValue, cm.getValue());
1134
+ var register = helpers.getRegisterController().getRegister();
1135
+ eq('', register.toString());
1136
+ is(!register.linewise);
1137
+ eqPos(curStart, cm.getCursor());
1138
+ }, { value: ' word1\nword2\nword3\nword4\nword5\nword6' });
1139
+ testVim('gu_and_gU', function(cm, vim, helpers) {
1140
+ var curStart = makeCursor(0, 7);
1141
+ var value = cm.getValue();
1142
+ cm.setCursor(curStart);
1143
+ helpers.doKeys('2', 'g', 'U', 'w');
1144
+ eq(cm.getValue(), 'wa wb xX WC wd');
1145
+ eqPos(curStart, cm.getCursor());
1146
+ helpers.doKeys('2', 'g', 'u', 'w');
1147
+ eq(cm.getValue(), value);
1148
+
1149
+ helpers.doKeys('2', 'g', 'U', 'B');
1150
+ eq(cm.getValue(), 'wa WB Xx wc wd');
1151
+ eqPos(makeCursor(0, 3), cm.getCursor());
1152
+
1153
+ cm.setCursor(makeCursor(0, 4));
1154
+ helpers.doKeys('g', 'u', 'i', 'w');
1155
+ eq(cm.getValue(), 'wa wb Xx wc wd');
1156
+ eqPos(makeCursor(0, 3), cm.getCursor());
1157
+
1158
+ // TODO: support gUgU guu
1159
+ // eqPos(makeCursor(0, 0), cm.getCursor());
1160
+
1161
+ var register = helpers.getRegisterController().getRegister();
1162
+ eq('', register.toString());
1163
+ is(!register.linewise);
1164
+ }, { value: 'wa wb xx wc wd' });
1165
+ testVim('visual_block_~', function(cm, vim, helpers) {
1166
+ cm.setCursor(1, 1);
1167
+ helpers.doKeys('<C-v>', 'l', 'l', 'j', '~');
1168
+ helpers.assertCursorAt(1, 1);
1169
+ eq('hello\nwoRLd\naBCDe', cm.getValue());
1170
+ cm.setCursor(2, 0);
1171
+ helpers.doKeys('v', 'l', 'l', '~');
1172
+ helpers.assertCursorAt(2, 0);
1173
+ eq('hello\nwoRLd\nAbcDe', cm.getValue());
1174
+ },{value: 'hello\nwOrld\nabcde' });
1175
+ testVim('._swapCase_visualBlock', function(cm, vim, helpers) {
1176
+ helpers.doKeys('<C-v>', 'j', 'j', 'l', '~');
1177
+ cm.setCursor(0, 3);
1178
+ helpers.doKeys('.');
1179
+ eq('HelLO\nWorLd\nAbcdE', cm.getValue());
1180
+ },{value: 'hEllo\nwOrlD\naBcDe' });
1181
+ testVim('._delete_visualBlock', function(cm, vim, helpers) {
1182
+ helpers.doKeys('<C-v>', 'j', 'x');
1183
+ eq('ive\ne\nsome\nsugar', cm.getValue());
1184
+ helpers.doKeys('.');
1185
+ eq('ve\n\nsome\nsugar', cm.getValue());
1186
+ helpers.doKeys('j', 'j', '.');
1187
+ eq('ve\n\nome\nugar', cm.getValue());
1188
+ helpers.doKeys('u', '<C-r>', '.');
1189
+ eq('ve\n\nme\ngar', cm.getValue());
1190
+ },{value: 'give\nme\nsome\nsugar' });
1191
+ testVim('>{motion}', function(cm, vim, helpers) {
1192
+ cm.setCursor(1, 3);
1193
+ var expectedLineCount = cm.lineCount();
1194
+ var expectedValue = ' word1\n word2\nword3 ';
1195
+ helpers.doKeys('>', 'k');
1196
+ eq(expectedValue, cm.getValue());
1197
+ var register = helpers.getRegisterController().getRegister();
1198
+ eq('', register.toString());
1199
+ is(!register.linewise);
1200
+ helpers.assertCursorAt(0, 3);
1201
+ }, { value: ' word1\nword2\nword3 ', indentUnit: 2 });
1202
+ testVim('>>', function(cm, vim, helpers) {
1203
+ cm.setCursor(0, 3);
1204
+ var expectedLineCount = cm.lineCount();
1205
+ var expectedValue = ' word1\n word2\nword3 ';
1206
+ helpers.doKeys('2', '>', '>');
1207
+ eq(expectedValue, cm.getValue());
1208
+ var register = helpers.getRegisterController().getRegister();
1209
+ eq('', register.toString());
1210
+ is(!register.linewise);
1211
+ helpers.assertCursorAt(0, 3);
1212
+ }, { value: ' word1\nword2\nword3 ', indentUnit: 2 });
1213
+ testVim('<{motion}', function(cm, vim, helpers) {
1214
+ cm.setCursor(1, 3);
1215
+ var expectedLineCount = cm.lineCount();
1216
+ var expectedValue = ' word1\nword2\nword3 ';
1217
+ helpers.doKeys('<', 'k');
1218
+ eq(expectedValue, cm.getValue());
1219
+ var register = helpers.getRegisterController().getRegister();
1220
+ eq('', register.toString());
1221
+ is(!register.linewise);
1222
+ helpers.assertCursorAt(0, 1);
1223
+ }, { value: ' word1\n word2\nword3 ', indentUnit: 2 });
1224
+ testVim('<<', function(cm, vim, helpers) {
1225
+ cm.setCursor(0, 3);
1226
+ var expectedLineCount = cm.lineCount();
1227
+ var expectedValue = ' word1\nword2\nword3 ';
1228
+ helpers.doKeys('2', '<', '<');
1229
+ eq(expectedValue, cm.getValue());
1230
+ var register = helpers.getRegisterController().getRegister();
1231
+ eq('', register.toString());
1232
+ is(!register.linewise);
1233
+ helpers.assertCursorAt(0, 1);
1234
+ }, { value: ' word1\n word2\nword3 ', indentUnit: 2 });
1235
+
1236
+ // Edit tests
1237
+ function testEdit(name, before, pos, edit, after) {
1238
+ return testVim(name, function(cm, vim, helpers) {
1239
+ var ch = before.search(pos)
1240
+ var line = before.substring(0, ch).split('\n').length - 1;
1241
+ if (line) {
1242
+ ch = before.substring(0, ch).split('\n').pop().length;
1243
+ }
1244
+ cm.setCursor(line, ch);
1245
+ helpers.doKeys.apply(this, edit.split(''));
1246
+ eq(after, cm.getValue());
1247
+ }, {value: before});
1248
+ }
1249
+
1250
+ // These Delete tests effectively cover word-wise Change, Visual & Yank.
1251
+ // Tabs are used as differentiated whitespace to catch edge cases.
1252
+ // Normal word:
1253
+ testEdit('diw_mid_spc', 'foo \tbAr\t baz', /A/, 'diw', 'foo \t\t baz');
1254
+ testEdit('daw_mid_spc', 'foo \tbAr\t baz', /A/, 'daw', 'foo \tbaz');
1255
+ testEdit('diw_mid_punct', 'foo \tbAr.\t baz', /A/, 'diw', 'foo \t.\t baz');
1256
+ testEdit('daw_mid_punct', 'foo \tbAr.\t baz', /A/, 'daw', 'foo.\t baz');
1257
+ testEdit('diw_mid_punct2', 'foo \t,bAr.\t baz', /A/, 'diw', 'foo \t,.\t baz');
1258
+ testEdit('daw_mid_punct2', 'foo \t,bAr.\t baz', /A/, 'daw', 'foo \t,.\t baz');
1259
+ testEdit('diw_start_spc', 'bAr \tbaz', /A/, 'diw', ' \tbaz');
1260
+ testEdit('daw_start_spc', 'bAr \tbaz', /A/, 'daw', 'baz');
1261
+ testEdit('diw_start_punct', 'bAr. \tbaz', /A/, 'diw', '. \tbaz');
1262
+ testEdit('daw_start_punct', 'bAr. \tbaz', /A/, 'daw', '. \tbaz');
1263
+ testEdit('diw_end_spc', 'foo \tbAr', /A/, 'diw', 'foo \t');
1264
+ testEdit('daw_end_spc', 'foo \tbAr', /A/, 'daw', 'foo');
1265
+ testEdit('diw_end_punct', 'foo \tbAr.', /A/, 'diw', 'foo \t.');
1266
+ testEdit('daw_end_punct', 'foo \tbAr.', /A/, 'daw', 'foo.');
1267
+ // Big word:
1268
+ testEdit('diW_mid_spc', 'foo \tbAr\t baz', /A/, 'diW', 'foo \t\t baz');
1269
+ testEdit('daW_mid_spc', 'foo \tbAr\t baz', /A/, 'daW', 'foo \tbaz');
1270
+ testEdit('diW_mid_punct', 'foo \tbAr.\t baz', /A/, 'diW', 'foo \t\t baz');
1271
+ testEdit('daW_mid_punct', 'foo \tbAr.\t baz', /A/, 'daW', 'foo \tbaz');
1272
+ testEdit('diW_mid_punct2', 'foo \t,bAr.\t baz', /A/, 'diW', 'foo \t\t baz');
1273
+ testEdit('daW_mid_punct2', 'foo \t,bAr.\t baz', /A/, 'daW', 'foo \tbaz');
1274
+ testEdit('diW_start_spc', 'bAr\t baz', /A/, 'diW', '\t baz');
1275
+ testEdit('daW_start_spc', 'bAr\t baz', /A/, 'daW', 'baz');
1276
+ testEdit('diW_start_punct', 'bAr.\t baz', /A/, 'diW', '\t baz');
1277
+ testEdit('daW_start_punct', 'bAr.\t baz', /A/, 'daW', 'baz');
1278
+ testEdit('diW_end_spc', 'foo \tbAr', /A/, 'diW', 'foo \t');
1279
+ testEdit('daW_end_spc', 'foo \tbAr', /A/, 'daW', 'foo');
1280
+ testEdit('diW_end_punct', 'foo \tbAr.', /A/, 'diW', 'foo \t');
1281
+ testEdit('daW_end_punct', 'foo \tbAr.', /A/, 'daW', 'foo');
1282
+ // Deleting text objects
1283
+ // Open and close on same line
1284
+ testEdit('di(_open_spc', 'foo (bAr) baz', /\(/, 'di(', 'foo () baz');
1285
+ testEdit('di)_open_spc', 'foo (bAr) baz', /\(/, 'di)', 'foo () baz');
1286
+ testEdit('dib_open_spc', 'foo (bAr) baz', /\(/, 'dib', 'foo () baz');
1287
+ testEdit('da(_open_spc', 'foo (bAr) baz', /\(/, 'da(', 'foo baz');
1288
+ testEdit('da)_open_spc', 'foo (bAr) baz', /\(/, 'da)', 'foo baz');
1289
+
1290
+ testEdit('di(_middle_spc', 'foo (bAr) baz', /A/, 'di(', 'foo () baz');
1291
+ testEdit('di)_middle_spc', 'foo (bAr) baz', /A/, 'di)', 'foo () baz');
1292
+ testEdit('da(_middle_spc', 'foo (bAr) baz', /A/, 'da(', 'foo baz');
1293
+ testEdit('da)_middle_spc', 'foo (bAr) baz', /A/, 'da)', 'foo baz');
1294
+
1295
+ testEdit('di(_close_spc', 'foo (bAr) baz', /\)/, 'di(', 'foo () baz');
1296
+ testEdit('di)_close_spc', 'foo (bAr) baz', /\)/, 'di)', 'foo () baz');
1297
+ testEdit('da(_close_spc', 'foo (bAr) baz', /\)/, 'da(', 'foo baz');
1298
+ testEdit('da)_close_spc', 'foo (bAr) baz', /\)/, 'da)', 'foo baz');
1299
+
1300
+ // delete around and inner b.
1301
+ testEdit('dab_on_(_should_delete_around_()block', 'o( in(abc) )', /\(a/, 'dab', 'o( in )');
1302
+
1303
+ // delete around and inner B.
1304
+ testEdit('daB_on_{_should_delete_around_{}block', 'o{ in{abc} }', /{a/, 'daB', 'o{ in }');
1305
+ testEdit('diB_on_{_should_delete_inner_{}block', 'o{ in{abc} }', /{a/, 'diB', 'o{ in{} }');
1306
+
1307
+ testEdit('da{_on_{_should_delete_inner_block', 'o{ in{abc} }', /{a/, 'da{', 'o{ in }');
1308
+ testEdit('di[_on_(_should_not_delete', 'foo (bAr) baz', /\(/, 'di[', 'foo (bAr) baz');
1309
+ testEdit('di[_on_)_should_not_delete', 'foo (bAr) baz', /\)/, 'di[', 'foo (bAr) baz');
1310
+ testEdit('da[_on_(_should_not_delete', 'foo (bAr) baz', /\(/, 'da[', 'foo (bAr) baz');
1311
+ testEdit('da[_on_)_should_not_delete', 'foo (bAr) baz', /\)/, 'da[', 'foo (bAr) baz');
1312
+ testMotion('di(_outside_should_stay', ['d', 'i', '('], { line: 0, ch: 0}, { line: 0, ch: 0});
1313
+
1314
+ // Open and close on different lines, equally indented
1315
+ testEdit('di{_middle_spc', 'a{\n\tbar\n}b', /r/, 'di{', 'a{}b');
1316
+ testEdit('di}_middle_spc', 'a{\n\tbar\n}b', /r/, 'di}', 'a{}b');
1317
+ testEdit('da{_middle_spc', 'a{\n\tbar\n}b', /r/, 'da{', 'ab');
1318
+ testEdit('da}_middle_spc', 'a{\n\tbar\n}b', /r/, 'da}', 'ab');
1319
+ testEdit('daB_middle_spc', 'a{\n\tbar\n}b', /r/, 'daB', 'ab');
1320
+
1321
+ // open and close on diff lines, open indented less than close
1322
+ testEdit('di{_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'di{', 'a{}b');
1323
+ testEdit('di}_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'di}', 'a{}b');
1324
+ testEdit('da{_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'da{', 'ab');
1325
+ testEdit('da}_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'da}', 'ab');
1326
+
1327
+ // open and close on diff lines, open indented more than close
1328
+ testEdit('di[_middle_spc', 'a\t[\n\tbar\n]b', /r/, 'di[', 'a\t[]b');
1329
+ testEdit('di]_middle_spc', 'a\t[\n\tbar\n]b', /r/, 'di]', 'a\t[]b');
1330
+ testEdit('da[_middle_spc', 'a\t[\n\tbar\n]b', /r/, 'da[', 'a\tb');
1331
+ testEdit('da]_middle_spc', 'a\t[\n\tbar\n]b', /r/, 'da]', 'a\tb');
1332
+
1333
+ function testSelection(name, before, pos, keys, sel) {
1334
+ return testVim(name, function(cm, vim, helpers) {
1335
+ var ch = before.search(pos)
1336
+ var line = before.substring(0, ch).split('\n').length - 1;
1337
+ if (line) {
1338
+ ch = before.substring(0, ch).split('\n').pop().length;
1339
+ }
1340
+ cm.setCursor(line, ch);
1341
+ helpers.doKeys.apply(this, keys.split(''));
1342
+ eq(sel, cm.getSelection());
1343
+ }, {value: before});
1344
+ }
1345
+ testSelection('viw_middle_spc', 'foo \tbAr\t baz', /A/, 'viw', 'bAr');
1346
+ testSelection('vaw_middle_spc', 'foo \tbAr\t baz', /A/, 'vaw', 'bAr\t ');
1347
+ testSelection('viw_middle_punct', 'foo \tbAr,\t baz', /A/, 'viw', 'bAr');
1348
+ testSelection('vaW_middle_punct', 'foo \tbAr,\t baz', /A/, 'vaW', 'bAr,\t ');
1349
+ testSelection('viw_start_spc', 'foo \tbAr\t baz', /b/, 'viw', 'bAr');
1350
+ testSelection('viw_end_spc', 'foo \tbAr\t baz', /r/, 'viw', 'bAr');
1351
+ testSelection('viw_eol', 'foo \tbAr', /r/, 'viw', 'bAr');
1352
+ testSelection('vi{_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'vi{', '\n\tbar\n\t');
1353
+ testSelection('va{_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'va{', '{\n\tbar\n\t}');
1354
+
1355
+ testVim('mouse_select', function(cm, vim, helpers) {
1356
+ cm.setSelection(Pos(0, 2), Pos(0, 4), {origin: '*mouse'});
1357
+ is(cm.state.vim.visualMode);
1358
+ is(!cm.state.vim.visualLine);
1359
+ is(!cm.state.vim.visualBlock);
1360
+ helpers.doKeys('<Esc>');
1361
+ is(!cm.somethingSelected());
1362
+ helpers.doKeys('g', 'v');
1363
+ eq('cd', cm.getSelection());
1364
+ }, {value: 'abcdef'});
1365
+
1366
+ // Operator-motion tests
1367
+ testVim('D', function(cm, vim, helpers) {
1368
+ cm.setCursor(0, 3);
1369
+ helpers.doKeys('D');
1370
+ eq(' wo\nword2\n word3', cm.getValue());
1371
+ var register = helpers.getRegisterController().getRegister();
1372
+ eq('rd1', register.toString());
1373
+ is(!register.linewise);
1374
+ helpers.assertCursorAt(0, 3);
1375
+ }, { value: ' word1\nword2\n word3' });
1376
+ testVim('C', function(cm, vim, helpers) {
1377
+ var curStart = makeCursor(0, 3);
1378
+ cm.setCursor(curStart);
1379
+ helpers.doKeys('C');
1380
+ eq(' wo\nword2\n word3', cm.getValue());
1381
+ var register = helpers.getRegisterController().getRegister();
1382
+ eq('rd1', register.toString());
1383
+ is(!register.linewise);
1384
+ eqPos(curStart, cm.getCursor());
1385
+ eq('vim-insert', cm.getOption('keyMap'));
1386
+ }, { value: ' word1\nword2\n word3' });
1387
+ testVim('Y', function(cm, vim, helpers) {
1388
+ var curStart = makeCursor(0, 3);
1389
+ cm.setCursor(curStart);
1390
+ helpers.doKeys('Y');
1391
+ eq(' word1\nword2\n word3', cm.getValue());
1392
+ var register = helpers.getRegisterController().getRegister();
1393
+ eq('rd1', register.toString());
1394
+ is(!register.linewise);
1395
+ helpers.assertCursorAt(0, 3);
1396
+ }, { value: ' word1\nword2\n word3' });
1397
+ testVim('~', function(cm, vim, helpers) {
1398
+ helpers.doKeys('3', '~');
1399
+ eq('ABCdefg', cm.getValue());
1400
+ helpers.assertCursorAt(0, 3);
1401
+ }, { value: 'abcdefg' });
1402
+
1403
+ // Action tests
1404
+ testVim('ctrl-a', function(cm, vim, helpers) {
1405
+ cm.setCursor(0, 0);
1406
+ helpers.doKeys('<C-a>');
1407
+ eq('-9', cm.getValue());
1408
+ helpers.assertCursorAt(0, 1);
1409
+ helpers.doKeys('2','<C-a>');
1410
+ eq('-7', cm.getValue());
1411
+ }, {value: '-10'});
1412
+ testVim('ctrl-x', function(cm, vim, helpers) {
1413
+ cm.setCursor(0, 0);
1414
+ helpers.doKeys('<C-x>');
1415
+ eq('-1', cm.getValue());
1416
+ helpers.assertCursorAt(0, 1);
1417
+ helpers.doKeys('2','<C-x>');
1418
+ eq('-3', cm.getValue());
1419
+ }, {value: '0'});
1420
+ testVim('<C-x>/<C-a> search forward', function(cm, vim, helpers) {
1421
+ forEach(['<C-x>', '<C-a>'], function(key) {
1422
+ cm.setCursor(0, 0);
1423
+ helpers.doKeys(key);
1424
+ helpers.assertCursorAt(0, 5);
1425
+ helpers.doKeys('l');
1426
+ helpers.doKeys(key);
1427
+ helpers.assertCursorAt(0, 10);
1428
+ cm.setCursor(0, 11);
1429
+ helpers.doKeys(key);
1430
+ helpers.assertCursorAt(0, 11);
1431
+ });
1432
+ }, {value: '__jmp1 jmp2 jmp'});
1433
+ testVim('a', function(cm, vim, helpers) {
1434
+ cm.setCursor(0, 1);
1435
+ helpers.doKeys('a');
1436
+ helpers.assertCursorAt(0, 2);
1437
+ eq('vim-insert', cm.getOption('keyMap'));
1438
+ });
1439
+ testVim('a_eol', function(cm, vim, helpers) {
1440
+ cm.setCursor(0, lines[0].length - 1);
1441
+ helpers.doKeys('a');
1442
+ helpers.assertCursorAt(0, lines[0].length);
1443
+ eq('vim-insert', cm.getOption('keyMap'));
1444
+ });
1445
+ testVim('A_endOfSelectedArea', function(cm, vim, helpers) {
1446
+ cm.setCursor(0, 0);
1447
+ helpers.doKeys('v', 'j', 'l');
1448
+ helpers.doKeys('A');
1449
+ helpers.assertCursorAt(1, 2);
1450
+ eq('vim-insert', cm.getOption('keyMap'));
1451
+ }, {value: 'foo\nbar'});
1452
+ testVim('i', function(cm, vim, helpers) {
1453
+ cm.setCursor(0, 1);
1454
+ helpers.doKeys('i');
1455
+ helpers.assertCursorAt(0, 1);
1456
+ eq('vim-insert', cm.getOption('keyMap'));
1457
+ });
1458
+ testVim('i_repeat', function(cm, vim, helpers) {
1459
+ helpers.doKeys('3', 'i');
1460
+ cm.replaceRange('test', cm.getCursor());
1461
+ helpers.doKeys('<Esc>');
1462
+ eq('testtesttest', cm.getValue());
1463
+ helpers.assertCursorAt(0, 11);
1464
+ }, { value: '' });
1465
+ testVim('i_repeat_delete', function(cm, vim, helpers) {
1466
+ cm.setCursor(0, 4);
1467
+ helpers.doKeys('2', 'i');
1468
+ cm.replaceRange('z', cm.getCursor());
1469
+ helpers.doInsertModeKeys('Backspace', 'Backspace');
1470
+ helpers.doKeys('<Esc>');
1471
+ eq('abe', cm.getValue());
1472
+ helpers.assertCursorAt(0, 1);
1473
+ }, { value: 'abcde' });
1474
+ testVim('A', function(cm, vim, helpers) {
1475
+ helpers.doKeys('A');
1476
+ helpers.assertCursorAt(0, lines[0].length);
1477
+ eq('vim-insert', cm.getOption('keyMap'));
1478
+ });
1479
+ testVim('A_visual_block', function(cm, vim, helpers) {
1480
+ cm.setCursor(0, 1);
1481
+ helpers.doKeys('<C-v>', '2', 'j', 'l', 'l', 'A');
1482
+ var replacement = new Array(cm.listSelections().length+1).join('hello ').split(' ');
1483
+ replacement.pop();
1484
+ cm.replaceSelections(replacement);
1485
+ eq('testhello\nmehello\npleahellose', cm.getValue());
1486
+ helpers.doKeys('<Esc>');
1487
+ cm.setCursor(0, 0);
1488
+ helpers.doKeys('.');
1489
+ // TODO this doesn't work yet
1490
+ // eq('teshellothello\nme hello hello\nplehelloahellose', cm.getValue());
1491
+ }, {value: 'test\nme\nplease'});
1492
+ testVim('I', function(cm, vim, helpers) {
1493
+ cm.setCursor(0, 4);
1494
+ helpers.doKeys('I');
1495
+ helpers.assertCursorAt(0, lines[0].textStart);
1496
+ eq('vim-insert', cm.getOption('keyMap'));
1497
+ });
1498
+ testVim('I_repeat', function(cm, vim, helpers) {
1499
+ cm.setCursor(0, 1);
1500
+ helpers.doKeys('3', 'I');
1501
+ cm.replaceRange('test', cm.getCursor());
1502
+ helpers.doKeys('<Esc>');
1503
+ eq('testtesttestblah', cm.getValue());
1504
+ helpers.assertCursorAt(0, 11);
1505
+ }, { value: 'blah' });
1506
+ testVim('I_visual_block', function(cm, vim, helpers) {
1507
+ cm.setCursor(0, 0);
1508
+ helpers.doKeys('<C-v>', '2', 'j', 'l', 'l', 'I');
1509
+ var replacement = new Array(cm.listSelections().length+1).join('hello ').split(' ');
1510
+ replacement.pop();
1511
+ cm.replaceSelections(replacement);
1512
+ eq('hellotest\nhellome\nhelloplease', cm.getValue());
1513
+ }, {value: 'test\nme\nplease'});
1514
+ testVim('o', function(cm, vim, helpers) {
1515
+ cm.setCursor(0, 4);
1516
+ helpers.doKeys('o');
1517
+ eq('word1\n\nword2', cm.getValue());
1518
+ helpers.assertCursorAt(1, 0);
1519
+ eq('vim-insert', cm.getOption('keyMap'));
1520
+ }, { value: 'word1\nword2' });
1521
+ testVim('o_repeat', function(cm, vim, helpers) {
1522
+ cm.setCursor(0, 0);
1523
+ helpers.doKeys('3', 'o');
1524
+ cm.replaceRange('test', cm.getCursor());
1525
+ helpers.doKeys('<Esc>');
1526
+ eq('\ntest\ntest\ntest', cm.getValue());
1527
+ helpers.assertCursorAt(3, 3);
1528
+ }, { value: '' });
1529
+ testVim('O', function(cm, vim, helpers) {
1530
+ cm.setCursor(0, 4);
1531
+ helpers.doKeys('O');
1532
+ eq('\nword1\nword2', cm.getValue());
1533
+ helpers.assertCursorAt(0, 0);
1534
+ eq('vim-insert', cm.getOption('keyMap'));
1535
+ }, { value: 'word1\nword2' });
1536
+ testVim('J', function(cm, vim, helpers) {
1537
+ cm.setCursor(0, 4);
1538
+ helpers.doKeys('J');
1539
+ var expectedValue = 'word1 word2\nword3\n word4';
1540
+ eq(expectedValue, cm.getValue());
1541
+ helpers.assertCursorAt(0, expectedValue.indexOf('word2') - 1);
1542
+ }, { value: 'word1 \n word2\nword3\n word4' });
1543
+ testVim('J_repeat', function(cm, vim, helpers) {
1544
+ cm.setCursor(0, 4);
1545
+ helpers.doKeys('3', 'J');
1546
+ var expectedValue = 'word1 word2 word3\n word4';
1547
+ eq(expectedValue, cm.getValue());
1548
+ helpers.assertCursorAt(0, expectedValue.indexOf('word3') - 1);
1549
+ }, { value: 'word1 \n word2\nword3\n word4' });
1550
+ testVim('p', function(cm, vim, helpers) {
1551
+ cm.setCursor(0, 1);
1552
+ helpers.getRegisterController().pushText('"', 'yank', 'abc\ndef', false);
1553
+ helpers.doKeys('p');
1554
+ eq('__abc\ndef_', cm.getValue());
1555
+ helpers.assertCursorAt(1, 2);
1556
+ }, { value: '___' });
1557
+ testVim('p_register', function(cm, vim, helpers) {
1558
+ cm.setCursor(0, 1);
1559
+ helpers.getRegisterController().getRegister('a').setText('abc\ndef', false);
1560
+ helpers.doKeys('"', 'a', 'p');
1561
+ eq('__abc\ndef_', cm.getValue());
1562
+ helpers.assertCursorAt(1, 2);
1563
+ }, { value: '___' });
1564
+ testVim('p_wrong_register', function(cm, vim, helpers) {
1565
+ cm.setCursor(0, 1);
1566
+ helpers.getRegisterController().getRegister('a').setText('abc\ndef', false);
1567
+ helpers.doKeys('p');
1568
+ eq('___', cm.getValue());
1569
+ helpers.assertCursorAt(0, 1);
1570
+ }, { value: '___' });
1571
+ testVim('p_line', function(cm, vim, helpers) {
1572
+ cm.setCursor(0, 1);
1573
+ helpers.getRegisterController().pushText('"', 'yank', ' a\nd\n', true);
1574
+ helpers.doKeys('2', 'p');
1575
+ eq('___\n a\nd\n a\nd', cm.getValue());
1576
+ helpers.assertCursorAt(1, 2);
1577
+ }, { value: '___' });
1578
+ testVim('p_lastline', function(cm, vim, helpers) {
1579
+ cm.setCursor(0, 1);
1580
+ helpers.getRegisterController().pushText('"', 'yank', ' a\nd', true);
1581
+ helpers.doKeys('2', 'p');
1582
+ eq('___\n a\nd\n a\nd', cm.getValue());
1583
+ helpers.assertCursorAt(1, 2);
1584
+ }, { value: '___' });
1585
+ testVim(']p_first_indent_is_smaller', function(cm, vim, helpers) {
1586
+ helpers.getRegisterController().pushText('"', 'yank', ' abc\n def\n', true);
1587
+ helpers.doKeys(']', 'p');
1588
+ eq(' ___\n abc\n def', cm.getValue());
1589
+ }, { value: ' ___' });
1590
+ testVim(']p_first_indent_is_larger', function(cm, vim, helpers) {
1591
+ helpers.getRegisterController().pushText('"', 'yank', ' abc\n def\n', true);
1592
+ helpers.doKeys(']', 'p');
1593
+ eq(' ___\n abc\ndef', cm.getValue());
1594
+ }, { value: ' ___' });
1595
+ testVim(']p_with_tab_indents', function(cm, vim, helpers) {
1596
+ helpers.getRegisterController().pushText('"', 'yank', '\t\tabc\n\t\t\tdef\n', true);
1597
+ helpers.doKeys(']', 'p');
1598
+ eq('\t___\n\tabc\n\t\tdef', cm.getValue());
1599
+ }, { value: '\t___', indentWithTabs: true});
1600
+ testVim(']p_with_spaces_translated_to_tabs', function(cm, vim, helpers) {
1601
+ helpers.getRegisterController().pushText('"', 'yank', ' abc\n def\n', true);
1602
+ helpers.doKeys(']', 'p');
1603
+ eq('\t___\n\tabc\n\t\tdef', cm.getValue());
1604
+ }, { value: '\t___', indentWithTabs: true, tabSize: 2 });
1605
+ testVim('[p', function(cm, vim, helpers) {
1606
+ helpers.getRegisterController().pushText('"', 'yank', ' abc\n def\n', true);
1607
+ helpers.doKeys('[', 'p');
1608
+ eq(' abc\n def\n ___', cm.getValue());
1609
+ }, { value: ' ___' });
1610
+ testVim('P', function(cm, vim, helpers) {
1611
+ cm.setCursor(0, 1);
1612
+ helpers.getRegisterController().pushText('"', 'yank', 'abc\ndef', false);
1613
+ helpers.doKeys('P');
1614
+ eq('_abc\ndef__', cm.getValue());
1615
+ helpers.assertCursorAt(1, 3);
1616
+ }, { value: '___' });
1617
+ testVim('P_line', function(cm, vim, helpers) {
1618
+ cm.setCursor(0, 1);
1619
+ helpers.getRegisterController().pushText('"', 'yank', ' a\nd\n', true);
1620
+ helpers.doKeys('2', 'P');
1621
+ eq(' a\nd\n a\nd\n___', cm.getValue());
1622
+ helpers.assertCursorAt(0, 2);
1623
+ }, { value: '___' });
1624
+ testVim('r', function(cm, vim, helpers) {
1625
+ cm.setCursor(0, 1);
1626
+ helpers.doKeys('3', 'r', 'u');
1627
+ eq('wuuuet\nanother', cm.getValue(),'3r failed');
1628
+ helpers.assertCursorAt(0, 3);
1629
+ cm.setCursor(0, 4);
1630
+ helpers.doKeys('v', 'j', 'h', 'r', '<Space>');
1631
+ eq('wuuu \n her', cm.getValue(),'Replacing selection by space-characters failed');
1632
+ }, { value: 'wordet\nanother' });
1633
+ testVim('r_visual_block', function(cm, vim, helpers) {
1634
+ cm.setCursor(2, 3);
1635
+ helpers.doKeys('<C-v>', 'k', 'k', 'h', 'h', 'r', 'l');
1636
+ eq('1lll\n5lll\nalllefg', cm.getValue());
1637
+ helpers.doKeys('<C-v>', 'l', 'j', 'r', '<Space>');
1638
+ eq('1 l\n5 l\nalllefg', cm.getValue());
1639
+ cm.setCursor(2, 0);
1640
+ helpers.doKeys('o');
1641
+ helpers.doKeys('<Esc>');
1642
+ cm.replaceRange('\t\t', cm.getCursor());
1643
+ helpers.doKeys('<C-v>', 'h', 'h', 'r', 'r');
1644
+ eq('1 l\n5 l\nalllefg\nrrrrrrrr', cm.getValue());
1645
+ }, {value: '1234\n5678\nabcdefg'});
1646
+ testVim('R', function(cm, vim, helpers) {
1647
+ cm.setCursor(0, 1);
1648
+ helpers.doKeys('R');
1649
+ helpers.assertCursorAt(0, 1);
1650
+ eq('vim-replace', cm.getOption('keyMap'));
1651
+ is(cm.state.overwrite, 'Setting overwrite state failed');
1652
+ });
1653
+ testVim('mark', function(cm, vim, helpers) {
1654
+ cm.setCursor(2, 2);
1655
+ helpers.doKeys('m', 't');
1656
+ cm.setCursor(0, 0);
1657
+ helpers.doKeys('`', 't');
1658
+ helpers.assertCursorAt(2, 2);
1659
+ cm.setCursor(2, 0);
1660
+ cm.replaceRange(' h', cm.getCursor());
1661
+ cm.setCursor(0, 0);
1662
+ helpers.doKeys('\'', 't');
1663
+ helpers.assertCursorAt(2, 3);
1664
+ });
1665
+ testVim('jumpToMark_next', function(cm, vim, helpers) {
1666
+ cm.setCursor(2, 2);
1667
+ helpers.doKeys('m', 't');
1668
+ cm.setCursor(0, 0);
1669
+ helpers.doKeys(']', '`');
1670
+ helpers.assertCursorAt(2, 2);
1671
+ cm.setCursor(0, 0);
1672
+ helpers.doKeys(']', '\'');
1673
+ helpers.assertCursorAt(2, 0);
1674
+ });
1675
+ testVim('jumpToMark_next_repeat', function(cm, vim, helpers) {
1676
+ cm.setCursor(2, 2);
1677
+ helpers.doKeys('m', 'a');
1678
+ cm.setCursor(3, 2);
1679
+ helpers.doKeys('m', 'b');
1680
+ cm.setCursor(4, 2);
1681
+ helpers.doKeys('m', 'c');
1682
+ cm.setCursor(0, 0);
1683
+ helpers.doKeys('2', ']', '`');
1684
+ helpers.assertCursorAt(3, 2);
1685
+ cm.setCursor(0, 0);
1686
+ helpers.doKeys('2', ']', '\'');
1687
+ helpers.assertCursorAt(3, 1);
1688
+ });
1689
+ testVim('jumpToMark_next_sameline', function(cm, vim, helpers) {
1690
+ cm.setCursor(2, 0);
1691
+ helpers.doKeys('m', 'a');
1692
+ cm.setCursor(2, 4);
1693
+ helpers.doKeys('m', 'b');
1694
+ cm.setCursor(2, 2);
1695
+ helpers.doKeys(']', '`');
1696
+ helpers.assertCursorAt(2, 4);
1697
+ });
1698
+ testVim('jumpToMark_next_onlyprev', function(cm, vim, helpers) {
1699
+ cm.setCursor(2, 0);
1700
+ helpers.doKeys('m', 'a');
1701
+ cm.setCursor(4, 0);
1702
+ helpers.doKeys(']', '`');
1703
+ helpers.assertCursorAt(4, 0);
1704
+ });
1705
+ testVim('jumpToMark_next_nomark', function(cm, vim, helpers) {
1706
+ cm.setCursor(2, 2);
1707
+ helpers.doKeys(']', '`');
1708
+ helpers.assertCursorAt(2, 2);
1709
+ helpers.doKeys(']', '\'');
1710
+ helpers.assertCursorAt(2, 0);
1711
+ });
1712
+ testVim('jumpToMark_next_linewise_over', function(cm, vim, helpers) {
1713
+ cm.setCursor(2, 2);
1714
+ helpers.doKeys('m', 'a');
1715
+ cm.setCursor(3, 4);
1716
+ helpers.doKeys('m', 'b');
1717
+ cm.setCursor(2, 1);
1718
+ helpers.doKeys(']', '\'');
1719
+ helpers.assertCursorAt(3, 1);
1720
+ });
1721
+ testVim('jumpToMark_next_action', function(cm, vim, helpers) {
1722
+ cm.setCursor(2, 2);
1723
+ helpers.doKeys('m', 't');
1724
+ cm.setCursor(0, 0);
1725
+ helpers.doKeys('d', ']', '`');
1726
+ helpers.assertCursorAt(0, 0);
1727
+ var actual = cm.getLine(0);
1728
+ var expected = 'pop pop 0 1 2 3 4';
1729
+ eq(actual, expected, "Deleting while jumping to the next mark failed.");
1730
+ });
1731
+ testVim('jumpToMark_next_line_action', function(cm, vim, helpers) {
1732
+ cm.setCursor(2, 2);
1733
+ helpers.doKeys('m', 't');
1734
+ cm.setCursor(0, 0);
1735
+ helpers.doKeys('d', ']', '\'');
1736
+ helpers.assertCursorAt(0, 1);
1737
+ var actual = cm.getLine(0);
1738
+ var expected = ' (a) [b] {c} '
1739
+ eq(actual, expected, "Deleting while jumping to the next mark line failed.");
1740
+ });
1741
+ testVim('jumpToMark_prev', function(cm, vim, helpers) {
1742
+ cm.setCursor(2, 2);
1743
+ helpers.doKeys('m', 't');
1744
+ cm.setCursor(4, 0);
1745
+ helpers.doKeys('[', '`');
1746
+ helpers.assertCursorAt(2, 2);
1747
+ cm.setCursor(4, 0);
1748
+ helpers.doKeys('[', '\'');
1749
+ helpers.assertCursorAt(2, 0);
1750
+ });
1751
+ testVim('jumpToMark_prev_repeat', function(cm, vim, helpers) {
1752
+ cm.setCursor(2, 2);
1753
+ helpers.doKeys('m', 'a');
1754
+ cm.setCursor(3, 2);
1755
+ helpers.doKeys('m', 'b');
1756
+ cm.setCursor(4, 2);
1757
+ helpers.doKeys('m', 'c');
1758
+ cm.setCursor(5, 0);
1759
+ helpers.doKeys('2', '[', '`');
1760
+ helpers.assertCursorAt(3, 2);
1761
+ cm.setCursor(5, 0);
1762
+ helpers.doKeys('2', '[', '\'');
1763
+ helpers.assertCursorAt(3, 1);
1764
+ });
1765
+ testVim('jumpToMark_prev_sameline', function(cm, vim, helpers) {
1766
+ cm.setCursor(2, 0);
1767
+ helpers.doKeys('m', 'a');
1768
+ cm.setCursor(2, 4);
1769
+ helpers.doKeys('m', 'b');
1770
+ cm.setCursor(2, 2);
1771
+ helpers.doKeys('[', '`');
1772
+ helpers.assertCursorAt(2, 0);
1773
+ });
1774
+ testVim('jumpToMark_prev_onlynext', function(cm, vim, helpers) {
1775
+ cm.setCursor(4, 4);
1776
+ helpers.doKeys('m', 'a');
1777
+ cm.setCursor(2, 0);
1778
+ helpers.doKeys('[', '`');
1779
+ helpers.assertCursorAt(2, 0);
1780
+ });
1781
+ testVim('jumpToMark_prev_nomark', function(cm, vim, helpers) {
1782
+ cm.setCursor(2, 2);
1783
+ helpers.doKeys('[', '`');
1784
+ helpers.assertCursorAt(2, 2);
1785
+ helpers.doKeys('[', '\'');
1786
+ helpers.assertCursorAt(2, 0);
1787
+ });
1788
+ testVim('jumpToMark_prev_linewise_over', function(cm, vim, helpers) {
1789
+ cm.setCursor(2, 2);
1790
+ helpers.doKeys('m', 'a');
1791
+ cm.setCursor(3, 4);
1792
+ helpers.doKeys('m', 'b');
1793
+ cm.setCursor(3, 6);
1794
+ helpers.doKeys('[', '\'');
1795
+ helpers.assertCursorAt(2, 0);
1796
+ });
1797
+ testVim('delmark_single', function(cm, vim, helpers) {
1798
+ cm.setCursor(1, 2);
1799
+ helpers.doKeys('m', 't');
1800
+ helpers.doEx('delmarks t');
1801
+ cm.setCursor(0, 0);
1802
+ helpers.doKeys('`', 't');
1803
+ helpers.assertCursorAt(0, 0);
1804
+ });
1805
+ testVim('delmark_range', function(cm, vim, helpers) {
1806
+ cm.setCursor(1, 2);
1807
+ helpers.doKeys('m', 'a');
1808
+ cm.setCursor(2, 2);
1809
+ helpers.doKeys('m', 'b');
1810
+ cm.setCursor(3, 2);
1811
+ helpers.doKeys('m', 'c');
1812
+ cm.setCursor(4, 2);
1813
+ helpers.doKeys('m', 'd');
1814
+ cm.setCursor(5, 2);
1815
+ helpers.doKeys('m', 'e');
1816
+ helpers.doEx('delmarks b-d');
1817
+ cm.setCursor(0, 0);
1818
+ helpers.doKeys('`', 'a');
1819
+ helpers.assertCursorAt(1, 2);
1820
+ helpers.doKeys('`', 'b');
1821
+ helpers.assertCursorAt(1, 2);
1822
+ helpers.doKeys('`', 'c');
1823
+ helpers.assertCursorAt(1, 2);
1824
+ helpers.doKeys('`', 'd');
1825
+ helpers.assertCursorAt(1, 2);
1826
+ helpers.doKeys('`', 'e');
1827
+ helpers.assertCursorAt(5, 2);
1828
+ });
1829
+ testVim('delmark_multi', function(cm, vim, helpers) {
1830
+ cm.setCursor(1, 2);
1831
+ helpers.doKeys('m', 'a');
1832
+ cm.setCursor(2, 2);
1833
+ helpers.doKeys('m', 'b');
1834
+ cm.setCursor(3, 2);
1835
+ helpers.doKeys('m', 'c');
1836
+ cm.setCursor(4, 2);
1837
+ helpers.doKeys('m', 'd');
1838
+ cm.setCursor(5, 2);
1839
+ helpers.doKeys('m', 'e');
1840
+ helpers.doEx('delmarks bcd');
1841
+ cm.setCursor(0, 0);
1842
+ helpers.doKeys('`', 'a');
1843
+ helpers.assertCursorAt(1, 2);
1844
+ helpers.doKeys('`', 'b');
1845
+ helpers.assertCursorAt(1, 2);
1846
+ helpers.doKeys('`', 'c');
1847
+ helpers.assertCursorAt(1, 2);
1848
+ helpers.doKeys('`', 'd');
1849
+ helpers.assertCursorAt(1, 2);
1850
+ helpers.doKeys('`', 'e');
1851
+ helpers.assertCursorAt(5, 2);
1852
+ });
1853
+ testVim('delmark_multi_space', function(cm, vim, helpers) {
1854
+ cm.setCursor(1, 2);
1855
+ helpers.doKeys('m', 'a');
1856
+ cm.setCursor(2, 2);
1857
+ helpers.doKeys('m', 'b');
1858
+ cm.setCursor(3, 2);
1859
+ helpers.doKeys('m', 'c');
1860
+ cm.setCursor(4, 2);
1861
+ helpers.doKeys('m', 'd');
1862
+ cm.setCursor(5, 2);
1863
+ helpers.doKeys('m', 'e');
1864
+ helpers.doEx('delmarks b c d');
1865
+ cm.setCursor(0, 0);
1866
+ helpers.doKeys('`', 'a');
1867
+ helpers.assertCursorAt(1, 2);
1868
+ helpers.doKeys('`', 'b');
1869
+ helpers.assertCursorAt(1, 2);
1870
+ helpers.doKeys('`', 'c');
1871
+ helpers.assertCursorAt(1, 2);
1872
+ helpers.doKeys('`', 'd');
1873
+ helpers.assertCursorAt(1, 2);
1874
+ helpers.doKeys('`', 'e');
1875
+ helpers.assertCursorAt(5, 2);
1876
+ });
1877
+ testVim('delmark_all', function(cm, vim, helpers) {
1878
+ cm.setCursor(1, 2);
1879
+ helpers.doKeys('m', 'a');
1880
+ cm.setCursor(2, 2);
1881
+ helpers.doKeys('m', 'b');
1882
+ cm.setCursor(3, 2);
1883
+ helpers.doKeys('m', 'c');
1884
+ cm.setCursor(4, 2);
1885
+ helpers.doKeys('m', 'd');
1886
+ cm.setCursor(5, 2);
1887
+ helpers.doKeys('m', 'e');
1888
+ helpers.doEx('delmarks a b-de');
1889
+ cm.setCursor(0, 0);
1890
+ helpers.doKeys('`', 'a');
1891
+ helpers.assertCursorAt(0, 0);
1892
+ helpers.doKeys('`', 'b');
1893
+ helpers.assertCursorAt(0, 0);
1894
+ helpers.doKeys('`', 'c');
1895
+ helpers.assertCursorAt(0, 0);
1896
+ helpers.doKeys('`', 'd');
1897
+ helpers.assertCursorAt(0, 0);
1898
+ helpers.doKeys('`', 'e');
1899
+ helpers.assertCursorAt(0, 0);
1900
+ });
1901
+ testVim('visual', function(cm, vim, helpers) {
1902
+ helpers.doKeys('l', 'v', 'l', 'l');
1903
+ helpers.assertCursorAt(0, 4);
1904
+ eqPos(makeCursor(0, 1), cm.getCursor('anchor'));
1905
+ helpers.doKeys('d');
1906
+ eq('15', cm.getValue());
1907
+ }, { value: '12345' });
1908
+ testVim('visual_yank', function(cm, vim, helpers) {
1909
+ helpers.doKeys('v', '3', 'l', 'y');
1910
+ helpers.assertCursorAt(0, 0);
1911
+ helpers.doKeys('p');
1912
+ eq('aa te test for yank', cm.getValue());
1913
+ }, { value: 'a test for yank' })
1914
+ testVim('visual_w', function(cm, vim, helpers) {
1915
+ helpers.doKeys('v', 'w');
1916
+ eq(cm.getSelection(), 'motion t');
1917
+ }, { value: 'motion test'});
1918
+ testVim('visual_initial_selection', function(cm, vim, helpers) {
1919
+ cm.setCursor(0, 1);
1920
+ helpers.doKeys('v');
1921
+ cm.getSelection('n');
1922
+ }, { value: 'init'});
1923
+ testVim('visual_crossover_left', function(cm, vim, helpers) {
1924
+ cm.setCursor(0, 2);
1925
+ helpers.doKeys('v', 'l', 'h', 'h');
1926
+ cm.getSelection('ro');
1927
+ }, { value: 'cross'});
1928
+ testVim('visual_crossover_left', function(cm, vim, helpers) {
1929
+ cm.setCursor(0, 2);
1930
+ helpers.doKeys('v', 'h', 'l', 'l');
1931
+ cm.getSelection('os');
1932
+ }, { value: 'cross'});
1933
+ testVim('visual_crossover_up', function(cm, vim, helpers) {
1934
+ cm.setCursor(3, 2);
1935
+ helpers.doKeys('v', 'j', 'k', 'k');
1936
+ eqPos(Pos(2, 2), cm.getCursor('head'));
1937
+ eqPos(Pos(3, 3), cm.getCursor('anchor'));
1938
+ helpers.doKeys('k');
1939
+ eqPos(Pos(1, 2), cm.getCursor('head'));
1940
+ eqPos(Pos(3, 3), cm.getCursor('anchor'));
1941
+ }, { value: 'cross\ncross\ncross\ncross\ncross\n'});
1942
+ testVim('visual_crossover_down', function(cm, vim, helpers) {
1943
+ cm.setCursor(1, 2);
1944
+ helpers.doKeys('v', 'k', 'j', 'j');
1945
+ eqPos(Pos(2, 3), cm.getCursor('head'));
1946
+ eqPos(Pos(1, 2), cm.getCursor('anchor'));
1947
+ helpers.doKeys('j');
1948
+ eqPos(Pos(3, 3), cm.getCursor('head'));
1949
+ eqPos(Pos(1, 2), cm.getCursor('anchor'));
1950
+ }, { value: 'cross\ncross\ncross\ncross\ncross\n'});
1951
+ testVim('visual_exit', function(cm, vim, helpers) {
1952
+ helpers.doKeys('<C-v>', 'l', 'j', 'j', '<Esc>');
1953
+ eqPos(cm.getCursor('anchor'), cm.getCursor('head'));
1954
+ eq(vim.visualMode, false);
1955
+ }, { value: 'hello\nworld\nfoo' });
1956
+ testVim('visual_line', function(cm, vim, helpers) {
1957
+ helpers.doKeys('l', 'V', 'l', 'j', 'j', 'd');
1958
+ eq(' 4\n 5', cm.getValue());
1959
+ }, { value: ' 1\n 2\n 3\n 4\n 5' });
1960
+ testVim('visual_block_move_to_eol', function(cm, vim, helpers) {
1961
+ // moveToEol should move all block cursors to end of line
1962
+ cm.setCursor(0, 0);
1963
+ helpers.doKeys('<C-v>', 'G', '$');
1964
+ var selections = cm.getSelections().join();
1965
+ console.log(selections);
1966
+ eq("123,45,6", selections);
1967
+ }, {value: '123\n45\n6'});
1968
+ testVim('visual_block_different_line_lengths', function(cm, vim, helpers) {
1969
+ // test the block selection with lines of different length
1970
+ // i.e. extending the selection
1971
+ // till the end of the longest line.
1972
+ helpers.doKeys('<C-v>', 'l', 'j', 'j', '6', 'l', 'd');
1973
+ helpers.doKeys('d', 'd', 'd', 'd');
1974
+ eq('', cm.getValue());
1975
+ }, {value: '1234\n5678\nabcdefg'});
1976
+ testVim('visual_block_truncate_on_short_line', function(cm, vim, helpers) {
1977
+ // check for left side selection in case
1978
+ // of moving up to a shorter line.
1979
+ cm.replaceRange('', cm.getCursor());
1980
+ cm.setCursor(3, 4);
1981
+ helpers.doKeys('<C-v>', 'l', 'k', 'k', 'd');
1982
+ eq('hello world\n{\ntis\nsa!', cm.getValue());
1983
+ }, {value: 'hello world\n{\nthis is\nsparta!'});
1984
+ testVim('visual_block_corners', function(cm, vim, helpers) {
1985
+ cm.setCursor(1, 2);
1986
+ helpers.doKeys('<C-v>', '2', 'l', 'k');
1987
+ // circle around the anchor
1988
+ // and check the selections
1989
+ var selections = cm.getSelections();
1990
+ eq('345891', selections.join(''));
1991
+ helpers.doKeys('4', 'h');
1992
+ selections = cm.getSelections();
1993
+ eq('123678', selections.join(''));
1994
+ helpers.doKeys('j', 'j');
1995
+ selections = cm.getSelections();
1996
+ eq('678abc', selections.join(''));
1997
+ helpers.doKeys('4', 'l');
1998
+ selections = cm.getSelections();
1999
+ eq('891cde', selections.join(''));
2000
+ }, {value: '12345\n67891\nabcde'});
2001
+ testVim('visual_block_mode_switch', function(cm, vim, helpers) {
2002
+ // switch between visual modes
2003
+ cm.setCursor(1, 1);
2004
+ // blockwise to characterwise visual
2005
+ helpers.doKeys('<C-v>', 'j', 'l', 'v');
2006
+ selections = cm.getSelections();
2007
+ eq('7891\nabc', selections.join(''));
2008
+ // characterwise to blockwise
2009
+ helpers.doKeys('<C-v>');
2010
+ selections = cm.getSelections();
2011
+ eq('78bc', selections.join(''));
2012
+ // blockwise to linewise visual
2013
+ helpers.doKeys('V');
2014
+ selections = cm.getSelections();
2015
+ eq('67891\nabcde', selections.join(''));
2016
+ }, {value: '12345\n67891\nabcde'});
2017
+ testVim('visual_block_crossing_short_line', function(cm, vim, helpers) {
2018
+ // visual block with long and short lines
2019
+ cm.setCursor(0, 3);
2020
+ helpers.doKeys('<C-v>', 'j', 'j', 'j');
2021
+ var selections = cm.getSelections().join();
2022
+ eq('4,,d,b', selections);
2023
+ helpers.doKeys('3', 'k');
2024
+ selections = cm.getSelections().join();
2025
+ eq('4', selections);
2026
+ helpers.doKeys('5', 'j', 'k');
2027
+ selections = cm.getSelections().join("");
2028
+ eq(10, selections.length);
2029
+ }, {value: '123456\n78\nabcdefg\nfoobar\n}\n'});
2030
+ testVim('visual_block_curPos_on_exit', function(cm, vim, helpers) {
2031
+ cm.setCursor(0, 0);
2032
+ helpers.doKeys('<C-v>', '3' , 'l', '<Esc>');
2033
+ eqPos(makeCursor(0, 3), cm.getCursor());
2034
+ helpers.doKeys('h', '<C-v>', '2' , 'j' ,'3' , 'l');
2035
+ eq(cm.getSelections().join(), "3456,,cdef");
2036
+ helpers.doKeys('4' , 'h');
2037
+ eq(cm.getSelections().join(), "23,8,bc");
2038
+ helpers.doKeys('2' , 'l');
2039
+ eq(cm.getSelections().join(), "34,,cd");
2040
+ }, {value: '123456\n78\nabcdefg\nfoobar'});
2041
+
2042
+ testVim('visual_marks', function(cm, vim, helpers) {
2043
+ helpers.doKeys('l', 'v', 'l', 'l', 'j', 'j', 'v');
2044
+ // Test visual mode marks
2045
+ cm.setCursor(2, 1);
2046
+ helpers.doKeys('\'', '<');
2047
+ helpers.assertCursorAt(0, 1);
2048
+ helpers.doKeys('\'', '>');
2049
+ helpers.assertCursorAt(2, 0);
2050
+ });
2051
+ testVim('visual_join', function(cm, vim, helpers) {
2052
+ helpers.doKeys('l', 'V', 'l', 'j', 'j', 'J');
2053
+ eq(' 1 2 3\n 4\n 5', cm.getValue());
2054
+ is(!vim.visualMode);
2055
+ }, { value: ' 1\n 2\n 3\n 4\n 5' });
2056
+ testVim('visual_blank', function(cm, vim, helpers) {
2057
+ helpers.doKeys('v', 'k');
2058
+ eq(vim.visualMode, true);
2059
+ }, { value: '\n' });
2060
+ testVim('reselect_visual', function(cm, vim, helpers) {
2061
+ helpers.doKeys('l', 'v', 'l', 'l', 'l', 'y', 'g', 'v');
2062
+ helpers.assertCursorAt(0, 5);
2063
+ eqPos(makeCursor(0, 1), cm.getCursor('anchor'));
2064
+ helpers.doKeys('v');
2065
+ cm.setCursor(1, 0);
2066
+ helpers.doKeys('v', 'l', 'l', 'p');
2067
+ eq('123456\n2345\nbar', cm.getValue());
2068
+ cm.setCursor(0, 0);
2069
+ helpers.doKeys('g', 'v');
2070
+ // here the fake cursor is at (1, 3)
2071
+ helpers.assertCursorAt(1, 4);
2072
+ eqPos(makeCursor(1, 0), cm.getCursor('anchor'));
2073
+ helpers.doKeys('v');
2074
+ cm.setCursor(2, 0);
2075
+ helpers.doKeys('v', 'l', 'l', 'g', 'v');
2076
+ helpers.assertCursorAt(1, 4);
2077
+ eqPos(makeCursor(1, 0), cm.getCursor('anchor'));
2078
+ helpers.doKeys('g', 'v');
2079
+ helpers.assertCursorAt(2, 3);
2080
+ eqPos(makeCursor(2, 0), cm.getCursor('anchor'));
2081
+ eq('123456\n2345\nbar', cm.getValue());
2082
+ }, { value: '123456\nfoo\nbar' });
2083
+ testVim('reselect_visual_line', function(cm, vim, helpers) {
2084
+ helpers.doKeys('l', 'V', 'j', 'j', 'V', 'g', 'v', 'd');
2085
+ eq('foo\nand\nbar', cm.getValue());
2086
+ cm.setCursor(1, 0);
2087
+ helpers.doKeys('V', 'y', 'j');
2088
+ helpers.doKeys('V', 'p' , 'g', 'v', 'd');
2089
+ eq('foo\nand', cm.getValue());
2090
+ }, { value: 'hello\nthis\nis\nfoo\nand\nbar' });
2091
+ testVim('reselect_visual_block', function(cm, vim, helpers) {
2092
+ cm.setCursor(1, 2);
2093
+ helpers.doKeys('<C-v>', 'k', 'h', '<C-v>');
2094
+ cm.setCursor(2, 1);
2095
+ helpers.doKeys('v', 'l', 'g', 'v');
2096
+ eqPos(Pos(1, 2), vim.sel.anchor);
2097
+ eqPos(Pos(0, 1), vim.sel.head);
2098
+ // Ensure selection is done with visual block mode rather than one
2099
+ // continuous range.
2100
+ eq(cm.getSelections().join(''), '23oo')
2101
+ helpers.doKeys('g', 'v');
2102
+ eqPos(Pos(2, 1), vim.sel.anchor);
2103
+ eqPos(Pos(2, 2), vim.sel.head);
2104
+ helpers.doKeys('<Esc>');
2105
+ // Ensure selection of deleted range
2106
+ cm.setCursor(1, 1);
2107
+ helpers.doKeys('v', '<C-v>', 'j', 'd', 'g', 'v');
2108
+ eq(cm.getSelections().join(''), 'or');
2109
+ }, { value: '123456\nfoo\nbar' });
2110
+ testVim('s_normal', function(cm, vim, helpers) {
2111
+ cm.setCursor(0, 1);
2112
+ helpers.doKeys('s');
2113
+ helpers.doKeys('<Esc>');
2114
+ eq('ac', cm.getValue());
2115
+ }, { value: 'abc'});
2116
+ testVim('s_visual', function(cm, vim, helpers) {
2117
+ cm.setCursor(0, 1);
2118
+ helpers.doKeys('v', 's');
2119
+ helpers.doKeys('<Esc>');
2120
+ helpers.assertCursorAt(0, 0);
2121
+ eq('ac', cm.getValue());
2122
+ }, { value: 'abc'});
2123
+ testVim('o_visual', function(cm, vim, helpers) {
2124
+ cm.setCursor(0,0);
2125
+ helpers.doKeys('v','l','l','l','o');
2126
+ helpers.assertCursorAt(0,0);
2127
+ helpers.doKeys('v','v','j','j','j','o');
2128
+ helpers.assertCursorAt(0,0);
2129
+ helpers.doKeys('O');
2130
+ helpers.doKeys('l','l')
2131
+ helpers.assertCursorAt(3, 3);
2132
+ helpers.doKeys('d');
2133
+ eq('p',cm.getValue());
2134
+ }, { value: 'abcd\nefgh\nijkl\nmnop'});
2135
+ testVim('o_visual_block', function(cm, vim, helpers) {
2136
+ cm.setCursor(0, 1);
2137
+ helpers.doKeys('<C-v>','3','j','l','l', 'o');
2138
+ eqPos(Pos(3, 3), vim.sel.anchor);
2139
+ eqPos(Pos(0, 1), vim.sel.head);
2140
+ helpers.doKeys('O');
2141
+ eqPos(Pos(3, 1), vim.sel.anchor);
2142
+ eqPos(Pos(0, 3), vim.sel.head);
2143
+ helpers.doKeys('o');
2144
+ eqPos(Pos(0, 3), vim.sel.anchor);
2145
+ eqPos(Pos(3, 1), vim.sel.head);
2146
+ }, { value: 'abcd\nefgh\nijkl\nmnop'});
2147
+ testVim('changeCase_visual', function(cm, vim, helpers) {
2148
+ cm.setCursor(0, 0);
2149
+ helpers.doKeys('v', 'l', 'l');
2150
+ helpers.doKeys('U');
2151
+ helpers.assertCursorAt(0, 0);
2152
+ helpers.doKeys('v', 'l', 'l');
2153
+ helpers.doKeys('u');
2154
+ helpers.assertCursorAt(0, 0);
2155
+ helpers.doKeys('l', 'l', 'l', '.');
2156
+ helpers.assertCursorAt(0, 3);
2157
+ cm.setCursor(0, 0);
2158
+ helpers.doKeys('q', 'a', 'v', 'j', 'U', 'q');
2159
+ helpers.assertCursorAt(0, 0);
2160
+ helpers.doKeys('j', '@', 'a');
2161
+ helpers.assertCursorAt(1, 0);
2162
+ cm.setCursor(3, 0);
2163
+ helpers.doKeys('V', 'U', 'j', '.');
2164
+ eq('ABCDEF\nGHIJKL\nMnopq\nSHORT LINE\nLONG LINE OF TEXT', cm.getValue());
2165
+ }, { value: 'abcdef\nghijkl\nmnopq\nshort line\nlong line of text'});
2166
+ testVim('changeCase_visual_block', function(cm, vim, helpers) {
2167
+ cm.setCursor(2, 1);
2168
+ helpers.doKeys('<C-v>', 'k', 'k', 'h', 'U');
2169
+ eq('ABcdef\nGHijkl\nMNopq\nfoo', cm.getValue());
2170
+ cm.setCursor(0, 2);
2171
+ helpers.doKeys('.');
2172
+ eq('ABCDef\nGHIJkl\nMNOPq\nfoo', cm.getValue());
2173
+ // check when last line is shorter.
2174
+ cm.setCursor(2, 2);
2175
+ helpers.doKeys('.');
2176
+ eq('ABCDef\nGHIJkl\nMNOPq\nfoO', cm.getValue());
2177
+ }, { value: 'abcdef\nghijkl\nmnopq\nfoo'});
2178
+ testVim('visual_paste', function(cm, vim, helpers) {
2179
+ cm.setCursor(0, 0);
2180
+ helpers.doKeys('v', 'l', 'l', 'y');
2181
+ helpers.assertCursorAt(0, 0);
2182
+ helpers.doKeys('3', 'l', 'j', 'v', 'l', 'p');
2183
+ helpers.assertCursorAt(1, 5);
2184
+ eq('this is a\nunithitest for visual paste', cm.getValue());
2185
+ cm.setCursor(0, 0);
2186
+ // in case of pasting whole line
2187
+ helpers.doKeys('y', 'y');
2188
+ cm.setCursor(1, 6);
2189
+ helpers.doKeys('v', 'l', 'l', 'l', 'p');
2190
+ helpers.assertCursorAt(2, 0);
2191
+ eq('this is a\nunithi\nthis is a\n for visual paste', cm.getValue());
2192
+ }, { value: 'this is a\nunit test for visual paste'});
2193
+
2194
+ // This checks the contents of the register used to paste the text
2195
+ testVim('v_paste_from_register', function(cm, vim, helpers) {
2196
+ cm.setCursor(0, 0);
2197
+ helpers.doKeys('"', 'a', 'y', 'w');
2198
+ cm.setCursor(1, 0);
2199
+ helpers.doKeys('v', 'p');
2200
+ cm.openDialog = helpers.fakeOpenDialog('registers');
2201
+ cm.openNotification = helpers.fakeOpenNotification(function(text) {
2202
+ is(/a\s+register/.test(text));
2203
+ });
2204
+ }, { value: 'register contents\nare not erased'});
2205
+ testVim('S_normal', function(cm, vim, helpers) {
2206
+ cm.setCursor(0, 1);
2207
+ helpers.doKeys('j', 'S');
2208
+ helpers.doKeys('<Esc>');
2209
+ helpers.assertCursorAt(1, 0);
2210
+ eq('aa\n\ncc', cm.getValue());
2211
+ }, { value: 'aa\nbb\ncc'});
2212
+ testVim('blockwise_paste', function(cm, vim, helpers) {
2213
+ cm.setCursor(0, 0);
2214
+ helpers.doKeys('<C-v>', '3', 'j', 'l', 'y');
2215
+ cm.setCursor(0, 2);
2216
+ // paste one char after the current cursor position
2217
+ helpers.doKeys('p');
2218
+ eq('helhelo\nworwold\nfoofo\nbarba', cm.getValue());
2219
+ cm.setCursor(0, 0);
2220
+ helpers.doKeys('v', '4', 'l', 'y');
2221
+ cm.setCursor(0, 0);
2222
+ helpers.doKeys('<C-v>', '3', 'j', 'p');
2223
+ eq('helheelhelo\norwold\noofo\narba', cm.getValue());
2224
+ }, { value: 'hello\nworld\nfoo\nbar'});
2225
+ testVim('blockwise_paste_long/short_line', function(cm, vim, helpers) {
2226
+ // extend short lines in case of different line lengths.
2227
+ cm.setCursor(0, 0);
2228
+ helpers.doKeys('<C-v>', 'j', 'j', 'y');
2229
+ cm.setCursor(0, 3);
2230
+ helpers.doKeys('p');
2231
+ eq('hellho\nfoo f\nbar b', cm.getValue());
2232
+ }, { value: 'hello\nfoo\nbar'});
2233
+ testVim('blockwise_paste_cut_paste', function(cm, vim, helpers) {
2234
+ cm.setCursor(0, 0);
2235
+ helpers.doKeys('<C-v>', '2', 'j', 'x');
2236
+ cm.setCursor(0, 0);
2237
+ helpers.doKeys('P');
2238
+ eq('cut\nand\npaste\nme', cm.getValue());
2239
+ }, { value: 'cut\nand\npaste\nme'});
2240
+ testVim('blockwise_paste_from_register', function(cm, vim, helpers) {
2241
+ cm.setCursor(0, 0);
2242
+ helpers.doKeys('<C-v>', '2', 'j', '"', 'a', 'y');
2243
+ cm.setCursor(0, 3);
2244
+ helpers.doKeys('"', 'a', 'p');
2245
+ eq('foobfar\nhellho\nworlwd', cm.getValue());
2246
+ }, { value: 'foobar\nhello\nworld'});
2247
+ testVim('blockwise_paste_last_line', function(cm, vim, helpers) {
2248
+ cm.setCursor(0, 0);
2249
+ helpers.doKeys('<C-v>', '2', 'j', 'l', 'y');
2250
+ cm.setCursor(3, 0);
2251
+ helpers.doKeys('p');
2252
+ eq('cut\nand\npaste\nmcue\n an\n pa', cm.getValue());
2253
+ }, { value: 'cut\nand\npaste\nme'});
2254
+
2255
+ testVim('S_visual', function(cm, vim, helpers) {
2256
+ cm.setCursor(0, 1);
2257
+ helpers.doKeys('v', 'j', 'S');
2258
+ helpers.doKeys('<Esc>');
2259
+ helpers.assertCursorAt(0, 0);
2260
+ eq('\ncc', cm.getValue());
2261
+ }, { value: 'aa\nbb\ncc'});
2262
+
2263
+ testVim('/ and n/N', function(cm, vim, helpers) {
2264
+ cm.openDialog = helpers.fakeOpenDialog('match');
2265
+ helpers.doKeys('/');
2266
+ helpers.assertCursorAt(0, 11);
2267
+ helpers.doKeys('n');
2268
+ helpers.assertCursorAt(1, 6);
2269
+ helpers.doKeys('N');
2270
+ helpers.assertCursorAt(0, 11);
2271
+
2272
+ cm.setCursor(0, 0);
2273
+ helpers.doKeys('2', '/');
2274
+ helpers.assertCursorAt(1, 6);
2275
+ }, { value: 'match nope match \n nope Match' });
2276
+ testVim('/_case', function(cm, vim, helpers) {
2277
+ cm.openDialog = helpers.fakeOpenDialog('Match');
2278
+ helpers.doKeys('/');
2279
+ helpers.assertCursorAt(1, 6);
2280
+ }, { value: 'match nope match \n nope Match' });
2281
+ testVim('/_2_pcre', function(cm, vim, helpers) {
2282
+ CodeMirror.Vim.setOption('pcre', true);
2283
+ cm.openDialog = helpers.fakeOpenDialog('(word){2}');
2284
+ helpers.doKeys('/');
2285
+ helpers.assertCursorAt(1, 9);
2286
+ helpers.doKeys('n');
2287
+ helpers.assertCursorAt(2, 1);
2288
+ }, { value: 'word\n another wordword\n wordwordword\n' });
2289
+ testVim('/_2_nopcre', function(cm, vim, helpers) {
2290
+ CodeMirror.Vim.setOption('pcre', false);
2291
+ cm.openDialog = helpers.fakeOpenDialog('\\(word\\)\\{2}');
2292
+ helpers.doKeys('/');
2293
+ helpers.assertCursorAt(1, 9);
2294
+ helpers.doKeys('n');
2295
+ helpers.assertCursorAt(2, 1);
2296
+ }, { value: 'word\n another wordword\n wordwordword\n' });
2297
+ testVim('/_nongreedy', function(cm, vim, helpers) {
2298
+ cm.openDialog = helpers.fakeOpenDialog('aa');
2299
+ helpers.doKeys('/');
2300
+ helpers.assertCursorAt(0, 4);
2301
+ helpers.doKeys('n');
2302
+ helpers.assertCursorAt(1, 3);
2303
+ helpers.doKeys('n');
2304
+ helpers.assertCursorAt(0, 0);
2305
+ }, { value: 'aaa aa \n a aa'});
2306
+ testVim('?_nongreedy', function(cm, vim, helpers) {
2307
+ cm.openDialog = helpers.fakeOpenDialog('aa');
2308
+ helpers.doKeys('?');
2309
+ helpers.assertCursorAt(1, 3);
2310
+ helpers.doKeys('n');
2311
+ helpers.assertCursorAt(0, 4);
2312
+ helpers.doKeys('n');
2313
+ helpers.assertCursorAt(0, 0);
2314
+ }, { value: 'aaa aa \n a aa'});
2315
+ testVim('/_greedy', function(cm, vim, helpers) {
2316
+ cm.openDialog = helpers.fakeOpenDialog('a+');
2317
+ helpers.doKeys('/');
2318
+ helpers.assertCursorAt(0, 4);
2319
+ helpers.doKeys('n');
2320
+ helpers.assertCursorAt(1, 1);
2321
+ helpers.doKeys('n');
2322
+ helpers.assertCursorAt(1, 3);
2323
+ helpers.doKeys('n');
2324
+ helpers.assertCursorAt(0, 0);
2325
+ }, { value: 'aaa aa \n a aa'});
2326
+ testVim('?_greedy', function(cm, vim, helpers) {
2327
+ cm.openDialog = helpers.fakeOpenDialog('a+');
2328
+ helpers.doKeys('?');
2329
+ helpers.assertCursorAt(1, 3);
2330
+ helpers.doKeys('n');
2331
+ helpers.assertCursorAt(1, 1);
2332
+ helpers.doKeys('n');
2333
+ helpers.assertCursorAt(0, 4);
2334
+ helpers.doKeys('n');
2335
+ helpers.assertCursorAt(0, 0);
2336
+ }, { value: 'aaa aa \n a aa'});
2337
+ testVim('/_greedy_0_or_more', function(cm, vim, helpers) {
2338
+ cm.openDialog = helpers.fakeOpenDialog('a*');
2339
+ helpers.doKeys('/');
2340
+ helpers.assertCursorAt(0, 3);
2341
+ helpers.doKeys('n');
2342
+ helpers.assertCursorAt(0, 4);
2343
+ helpers.doKeys('n');
2344
+ helpers.assertCursorAt(0, 5);
2345
+ helpers.doKeys('n');
2346
+ helpers.assertCursorAt(1, 0);
2347
+ helpers.doKeys('n');
2348
+ helpers.assertCursorAt(1, 1);
2349
+ helpers.doKeys('n');
2350
+ helpers.assertCursorAt(0, 0);
2351
+ }, { value: 'aaa aa\n aa'});
2352
+ testVim('?_greedy_0_or_more', function(cm, vim, helpers) {
2353
+ cm.openDialog = helpers.fakeOpenDialog('a*');
2354
+ helpers.doKeys('?');
2355
+ helpers.assertCursorAt(1, 1);
2356
+ helpers.doKeys('n');
2357
+ helpers.assertCursorAt(1, 0);
2358
+ helpers.doKeys('n');
2359
+ helpers.assertCursorAt(0, 5);
2360
+ helpers.doKeys('n');
2361
+ helpers.assertCursorAt(0, 4);
2362
+ helpers.doKeys('n');
2363
+ helpers.assertCursorAt(0, 3);
2364
+ helpers.doKeys('n');
2365
+ helpers.assertCursorAt(0, 0);
2366
+ }, { value: 'aaa aa\n aa'});
2367
+ testVim('? and n/N', function(cm, vim, helpers) {
2368
+ cm.openDialog = helpers.fakeOpenDialog('match');
2369
+ helpers.doKeys('?');
2370
+ helpers.assertCursorAt(1, 6);
2371
+ helpers.doKeys('n');
2372
+ helpers.assertCursorAt(0, 11);
2373
+ helpers.doKeys('N');
2374
+ helpers.assertCursorAt(1, 6);
2375
+
2376
+ cm.setCursor(0, 0);
2377
+ helpers.doKeys('2', '?');
2378
+ helpers.assertCursorAt(0, 11);
2379
+ }, { value: 'match nope match \n nope Match' });
2380
+ testVim('*', function(cm, vim, helpers) {
2381
+ cm.setCursor(0, 9);
2382
+ helpers.doKeys('*');
2383
+ helpers.assertCursorAt(0, 22);
2384
+
2385
+ cm.setCursor(0, 9);
2386
+ helpers.doKeys('2', '*');
2387
+ helpers.assertCursorAt(1, 8);
2388
+ }, { value: 'nomatch match nomatch match \nnomatch Match' });
2389
+ testVim('*_no_word', function(cm, vim, helpers) {
2390
+ cm.setCursor(0, 0);
2391
+ helpers.doKeys('*');
2392
+ helpers.assertCursorAt(0, 0);
2393
+ }, { value: ' \n match \n' });
2394
+ testVim('*_symbol', function(cm, vim, helpers) {
2395
+ cm.setCursor(0, 0);
2396
+ helpers.doKeys('*');
2397
+ helpers.assertCursorAt(1, 0);
2398
+ }, { value: ' /}\n/} match \n' });
2399
+ testVim('#', function(cm, vim, helpers) {
2400
+ cm.setCursor(0, 9);
2401
+ helpers.doKeys('#');
2402
+ helpers.assertCursorAt(1, 8);
2403
+
2404
+ cm.setCursor(0, 9);
2405
+ helpers.doKeys('2', '#');
2406
+ helpers.assertCursorAt(0, 22);
2407
+ }, { value: 'nomatch match nomatch match \nnomatch Match' });
2408
+ testVim('*_seek', function(cm, vim, helpers) {
2409
+ // Should skip over space and symbols.
2410
+ cm.setCursor(0, 3);
2411
+ helpers.doKeys('*');
2412
+ helpers.assertCursorAt(0, 22);
2413
+ }, { value: ' := match nomatch match \nnomatch Match' });
2414
+ testVim('#', function(cm, vim, helpers) {
2415
+ // Should skip over space and symbols.
2416
+ cm.setCursor(0, 3);
2417
+ helpers.doKeys('#');
2418
+ helpers.assertCursorAt(1, 8);
2419
+ }, { value: ' := match nomatch match \nnomatch Match' });
2420
+ testVim('g*', function(cm, vim, helpers) {
2421
+ cm.setCursor(0, 8);
2422
+ helpers.doKeys('g', '*');
2423
+ helpers.assertCursorAt(0, 18);
2424
+ cm.setCursor(0, 8);
2425
+ helpers.doKeys('3', 'g', '*');
2426
+ helpers.assertCursorAt(1, 8);
2427
+ }, { value: 'matches match alsoMatch\nmatchme matching' });
2428
+ testVim('g#', function(cm, vim, helpers) {
2429
+ cm.setCursor(0, 8);
2430
+ helpers.doKeys('g', '#');
2431
+ helpers.assertCursorAt(0, 0);
2432
+ cm.setCursor(0, 8);
2433
+ helpers.doKeys('3', 'g', '#');
2434
+ helpers.assertCursorAt(1, 0);
2435
+ }, { value: 'matches match alsoMatch\nmatchme matching' });
2436
+ testVim('macro_insert', function(cm, vim, helpers) {
2437
+ cm.setCursor(0, 0);
2438
+ helpers.doKeys('q', 'a', '0', 'i');
2439
+ cm.replaceRange('foo', cm.getCursor());
2440
+ helpers.doKeys('<Esc>');
2441
+ helpers.doKeys('q', '@', 'a');
2442
+ eq('foofoo', cm.getValue());
2443
+ }, { value: ''});
2444
+ testVim('macro_insert_repeat', function(cm, vim, helpers) {
2445
+ cm.setCursor(0, 0);
2446
+ helpers.doKeys('q', 'a', '$', 'a');
2447
+ cm.replaceRange('larry.', cm.getCursor());
2448
+ helpers.doKeys('<Esc>');
2449
+ helpers.doKeys('a');
2450
+ cm.replaceRange('curly.', cm.getCursor());
2451
+ helpers.doKeys('<Esc>');
2452
+ helpers.doKeys('q');
2453
+ helpers.doKeys('a');
2454
+ cm.replaceRange('moe.', cm.getCursor());
2455
+ helpers.doKeys('<Esc>');
2456
+ helpers.doKeys('@', 'a');
2457
+ // At this point, the most recent edit should be the 2nd insert change
2458
+ // inside the macro, i.e. "curly.".
2459
+ helpers.doKeys('.');
2460
+ eq('larry.curly.moe.larry.curly.curly.', cm.getValue());
2461
+ }, { value: ''});
2462
+ testVim('macro_space', function(cm, vim, helpers) {
2463
+ cm.setCursor(0, 0);
2464
+ helpers.doKeys('<Space>', '<Space>');
2465
+ helpers.assertCursorAt(0, 2);
2466
+ helpers.doKeys('q', 'a', '<Space>', '<Space>', 'q');
2467
+ helpers.assertCursorAt(0, 4);
2468
+ helpers.doKeys('@', 'a');
2469
+ helpers.assertCursorAt(0, 6);
2470
+ helpers.doKeys('@', 'a');
2471
+ helpers.assertCursorAt(0, 8);
2472
+ }, { value: 'one line of text.'});
2473
+ testVim('macro_t_search', function(cm, vim, helpers) {
2474
+ cm.setCursor(0, 0);
2475
+ helpers.doKeys('q', 'a', 't', 'e', 'q');
2476
+ helpers.assertCursorAt(0, 1);
2477
+ helpers.doKeys('l', '@', 'a');
2478
+ helpers.assertCursorAt(0, 6);
2479
+ helpers.doKeys('l', ';');
2480
+ helpers.assertCursorAt(0, 12);
2481
+ }, { value: 'one line of text.'});
2482
+ testVim('macro_f_search', function(cm, vim, helpers) {
2483
+ cm.setCursor(0, 0);
2484
+ helpers.doKeys('q', 'b', 'f', 'e', 'q');
2485
+ helpers.assertCursorAt(0, 2);
2486
+ helpers.doKeys('@', 'b');
2487
+ helpers.assertCursorAt(0, 7);
2488
+ helpers.doKeys(';');
2489
+ helpers.assertCursorAt(0, 13);
2490
+ }, { value: 'one line of text.'});
2491
+ testVim('macro_slash_search', function(cm, vim, helpers) {
2492
+ cm.setCursor(0, 0);
2493
+ helpers.doKeys('q', 'c');
2494
+ cm.openDialog = helpers.fakeOpenDialog('e');
2495
+ helpers.doKeys('/', 'q');
2496
+ helpers.assertCursorAt(0, 2);
2497
+ helpers.doKeys('@', 'c');
2498
+ helpers.assertCursorAt(0, 7);
2499
+ helpers.doKeys('n');
2500
+ helpers.assertCursorAt(0, 13);
2501
+ }, { value: 'one line of text.'});
2502
+ testVim('macro_multislash_search', function(cm, vim, helpers) {
2503
+ cm.setCursor(0, 0);
2504
+ helpers.doKeys('q', 'd');
2505
+ cm.openDialog = helpers.fakeOpenDialog('e');
2506
+ helpers.doKeys('/');
2507
+ cm.openDialog = helpers.fakeOpenDialog('t');
2508
+ helpers.doKeys('/', 'q');
2509
+ helpers.assertCursorAt(0, 12);
2510
+ helpers.doKeys('@', 'd');
2511
+ helpers.assertCursorAt(0, 15);
2512
+ }, { value: 'one line of text to rule them all.'});
2513
+ testVim('macro_parens', function(cm, vim, helpers) {
2514
+ cm.setCursor(0, 0);
2515
+ helpers.doKeys('q', 'z', 'i');
2516
+ cm.replaceRange('(', cm.getCursor());
2517
+ helpers.doKeys('<Esc>');
2518
+ helpers.doKeys('e', 'a');
2519
+ cm.replaceRange(')', cm.getCursor());
2520
+ helpers.doKeys('<Esc>');
2521
+ helpers.doKeys('q');
2522
+ helpers.doKeys('w', '@', 'z');
2523
+ helpers.doKeys('w', '@', 'z');
2524
+ eq('(see) (spot) (run)', cm.getValue());
2525
+ }, { value: 'see spot run'});
2526
+ testVim('macro_overwrite', function(cm, vim, helpers) {
2527
+ cm.setCursor(0, 0);
2528
+ helpers.doKeys('q', 'z', '0', 'i');
2529
+ cm.replaceRange('I ', cm.getCursor());
2530
+ helpers.doKeys('<Esc>');
2531
+ helpers.doKeys('q');
2532
+ helpers.doKeys('e');
2533
+ // Now replace the macro with something else.
2534
+ helpers.doKeys('q', 'z', 'a');
2535
+ cm.replaceRange('.', cm.getCursor());
2536
+ helpers.doKeys('<Esc>');
2537
+ helpers.doKeys('q');
2538
+ helpers.doKeys('e', '@', 'z');
2539
+ helpers.doKeys('e', '@', 'z');
2540
+ eq('I see. spot. run.', cm.getValue());
2541
+ }, { value: 'see spot run'});
2542
+ testVim('macro_search_f', function(cm, vim, helpers) {
2543
+ cm.setCursor(0, 0);
2544
+ helpers.doKeys('q', 'a', 'f', ' ');
2545
+ helpers.assertCursorAt(0,3);
2546
+ helpers.doKeys('q', '0');
2547
+ helpers.assertCursorAt(0,0);
2548
+ helpers.doKeys('@', 'a');
2549
+ helpers.assertCursorAt(0,3);
2550
+ }, { value: 'The quick brown fox jumped over the lazy dog.'});
2551
+ testVim('macro_search_2f', function(cm, vim, helpers) {
2552
+ cm.setCursor(0, 0);
2553
+ helpers.doKeys('q', 'a', '2', 'f', ' ');
2554
+ helpers.assertCursorAt(0,9);
2555
+ helpers.doKeys('q', '0');
2556
+ helpers.assertCursorAt(0,0);
2557
+ helpers.doKeys('@', 'a');
2558
+ helpers.assertCursorAt(0,9);
2559
+ }, { value: 'The quick brown fox jumped over the lazy dog.'});
2560
+ testVim('yank_register', function(cm, vim, helpers) {
2561
+ cm.setCursor(0, 0);
2562
+ helpers.doKeys('"', 'a', 'y', 'y');
2563
+ helpers.doKeys('j', '"', 'b', 'y', 'y');
2564
+ cm.openDialog = helpers.fakeOpenDialog('registers');
2565
+ cm.openNotification = helpers.fakeOpenNotification(function(text) {
2566
+ is(/a\s+foo/.test(text));
2567
+ is(/b\s+bar/.test(text));
2568
+ });
2569
+ helpers.doKeys(':');
2570
+ }, { value: 'foo\nbar'});
2571
+ testVim('yank_visual_block', function(cm, vim, helpers) {
2572
+ cm.setCursor(0, 1);
2573
+ helpers.doKeys('<C-v>', 'l', 'j', '"', 'a', 'y');
2574
+ cm.openNotification = helpers.fakeOpenNotification(function(text) {
2575
+ is(/a\s+oo\nar/.test(text));
2576
+ });
2577
+ helpers.doKeys(':');
2578
+ }, { value: 'foo\nbar'});
2579
+ testVim('yank_append_line_to_line_register', function(cm, vim, helpers) {
2580
+ cm.setCursor(0, 0);
2581
+ helpers.doKeys('"', 'a', 'y', 'y');
2582
+ helpers.doKeys('j', '"', 'A', 'y', 'y');
2583
+ cm.openDialog = helpers.fakeOpenDialog('registers');
2584
+ cm.openNotification = helpers.fakeOpenNotification(function(text) {
2585
+ is(/a\s+foo\nbar/.test(text));
2586
+ is(/"\s+foo\nbar/.test(text));
2587
+ });
2588
+ helpers.doKeys(':');
2589
+ }, { value: 'foo\nbar'});
2590
+ testVim('yank_append_word_to_word_register', function(cm, vim, helpers) {
2591
+ cm.setCursor(0, 0);
2592
+ helpers.doKeys('"', 'a', 'y', 'w');
2593
+ helpers.doKeys('j', '"', 'A', 'y', 'w');
2594
+ cm.openDialog = helpers.fakeOpenDialog('registers');
2595
+ cm.openNotification = helpers.fakeOpenNotification(function(text) {
2596
+ is(/a\s+foobar/.test(text));
2597
+ is(/"\s+foobar/.test(text));
2598
+ });
2599
+ helpers.doKeys(':');
2600
+ }, { value: 'foo\nbar'});
2601
+ testVim('yank_append_line_to_word_register', function(cm, vim, helpers) {
2602
+ cm.setCursor(0, 0);
2603
+ helpers.doKeys('"', 'a', 'y', 'w');
2604
+ helpers.doKeys('j', '"', 'A', 'y', 'y');
2605
+ cm.openDialog = helpers.fakeOpenDialog('registers');
2606
+ cm.openNotification = helpers.fakeOpenNotification(function(text) {
2607
+ is(/a\s+foo\nbar/.test(text));
2608
+ is(/"\s+foo\nbar/.test(text));
2609
+ });
2610
+ helpers.doKeys(':');
2611
+ }, { value: 'foo\nbar'});
2612
+ testVim('yank_append_word_to_line_register', function(cm, vim, helpers) {
2613
+ cm.setCursor(0, 0);
2614
+ helpers.doKeys('"', 'a', 'y', 'y');
2615
+ helpers.doKeys('j', '"', 'A', 'y', 'w');
2616
+ cm.openDialog = helpers.fakeOpenDialog('registers');
2617
+ cm.openNotification = helpers.fakeOpenNotification(function(text) {
2618
+ is(/a\s+foo\nbar/.test(text));
2619
+ is(/"\s+foo\nbar/.test(text));
2620
+ });
2621
+ helpers.doKeys(':');
2622
+ }, { value: 'foo\nbar'});
2623
+ testVim('macro_register', function(cm, vim, helpers) {
2624
+ cm.setCursor(0, 0);
2625
+ helpers.doKeys('q', 'a', 'i');
2626
+ cm.replaceRange('gangnam', cm.getCursor());
2627
+ helpers.doKeys('<Esc>');
2628
+ helpers.doKeys('q');
2629
+ helpers.doKeys('q', 'b', 'o');
2630
+ cm.replaceRange('style', cm.getCursor());
2631
+ helpers.doKeys('<Esc>');
2632
+ helpers.doKeys('q');
2633
+ cm.openDialog = helpers.fakeOpenDialog('registers');
2634
+ cm.openNotification = helpers.fakeOpenNotification(function(text) {
2635
+ is(/a\s+i/.test(text));
2636
+ is(/b\s+o/.test(text));
2637
+ });
2638
+ helpers.doKeys(':');
2639
+ }, { value: ''});
2640
+ testVim('._register', function(cm,vim,helpers) {
2641
+ cm.setCursor(0,0);
2642
+ helpers.doKeys('i');
2643
+ cm.replaceRange('foo',cm.getCursor());
2644
+ helpers.doKeys('<Esc>');
2645
+ cm.openDialog = helpers.fakeOpenDialog('registers');
2646
+ cm.openNotification = helpers.fakeOpenNotification(function(text) {
2647
+ is(/\.\s+foo/.test(text));
2648
+ });
2649
+ helpers.doKeys(':');
2650
+ }, {value: ''});
2651
+ testVim(':_register', function(cm,vim,helpers) {
2652
+ helpers.doEx('bar');
2653
+ cm.openDialog = helpers.fakeOpenDialog('registers');
2654
+ cm.openNotification = helpers.fakeOpenNotification(function(text) {
2655
+ is(/:\s+bar/.test(text));
2656
+ });
2657
+ helpers.doKeys(':');
2658
+ }, {value: ''});
2659
+ testVim('search_register_escape', function(cm, vim, helpers) {
2660
+ // Check that the register is restored if the user escapes rather than confirms.
2661
+ cm.openDialog = helpers.fakeOpenDialog('waldo');
2662
+ helpers.doKeys('/');
2663
+ var onKeyDown;
2664
+ var onKeyUp;
2665
+ var KEYCODES = {
2666
+ f: 70,
2667
+ o: 79,
2668
+ Esc: 27
2669
+ };
2670
+ cm.openDialog = function(template, callback, options) {
2671
+ onKeyDown = options.onKeyDown;
2672
+ onKeyUp = options.onKeyUp;
2673
+ };
2674
+ var close = function() {};
2675
+ helpers.doKeys('/');
2676
+ // Fake some keyboard events coming in.
2677
+ onKeyDown({keyCode: KEYCODES.f}, '', close);
2678
+ onKeyUp({keyCode: KEYCODES.f}, '', close);
2679
+ onKeyDown({keyCode: KEYCODES.o}, 'f', close);
2680
+ onKeyUp({keyCode: KEYCODES.o}, 'f', close);
2681
+ onKeyDown({keyCode: KEYCODES.o}, 'fo', close);
2682
+ onKeyUp({keyCode: KEYCODES.o}, 'fo', close);
2683
+ onKeyDown({keyCode: KEYCODES.Esc}, 'foo', close);
2684
+ cm.openDialog = helpers.fakeOpenDialog('registers');
2685
+ cm.openNotification = helpers.fakeOpenNotification(function(text) {
2686
+ is(/waldo/.test(text));
2687
+ is(!/foo/.test(text));
2688
+ });
2689
+ helpers.doKeys(':');
2690
+ }, {value: ''});
2691
+ testVim('search_register', function(cm, vim, helpers) {
2692
+ cm.openDialog = helpers.fakeOpenDialog('foo');
2693
+ helpers.doKeys('/');
2694
+ cm.openDialog = helpers.fakeOpenDialog('registers');
2695
+ cm.openNotification = helpers.fakeOpenNotification(function(text) {
2696
+ is(/\/\s+foo/.test(text));
2697
+ });
2698
+ helpers.doKeys(':');
2699
+ }, {value: ''});
2700
+ testVim('search_history', function(cm, vim, helpers) {
2701
+ cm.openDialog = helpers.fakeOpenDialog('this');
2702
+ helpers.doKeys('/');
2703
+ cm.openDialog = helpers.fakeOpenDialog('checks');
2704
+ helpers.doKeys('/');
2705
+ cm.openDialog = helpers.fakeOpenDialog('search');
2706
+ helpers.doKeys('/');
2707
+ cm.openDialog = helpers.fakeOpenDialog('history');
2708
+ helpers.doKeys('/');
2709
+ cm.openDialog = helpers.fakeOpenDialog('checks');
2710
+ helpers.doKeys('/');
2711
+ var onKeyDown;
2712
+ var onKeyUp;
2713
+ var query = '';
2714
+ var keyCodes = {
2715
+ Up: 38,
2716
+ Down: 40
2717
+ };
2718
+ cm.openDialog = function(template, callback, options) {
2719
+ onKeyUp = options.onKeyUp;
2720
+ onKeyDown = options.onKeyDown;
2721
+ };
2722
+ var close = function(newVal) {
2723
+ if (typeof newVal == 'string') query = newVal;
2724
+ }
2725
+ helpers.doKeys('/');
2726
+ onKeyDown({keyCode: keyCodes.Up}, query, close);
2727
+ onKeyUp({keyCode: keyCodes.Up}, query, close);
2728
+ eq(query, 'checks');
2729
+ onKeyDown({keyCode: keyCodes.Up}, query, close);
2730
+ onKeyUp({keyCode: keyCodes.Up}, query, close);
2731
+ eq(query, 'history');
2732
+ onKeyDown({keyCode: keyCodes.Up}, query, close);
2733
+ onKeyUp({keyCode: keyCodes.Up}, query, close);
2734
+ eq(query, 'search');
2735
+ onKeyDown({keyCode: keyCodes.Up}, query, close);
2736
+ onKeyUp({keyCode: keyCodes.Up}, query, close);
2737
+ eq(query, 'this');
2738
+ onKeyDown({keyCode: keyCodes.Down}, query, close);
2739
+ onKeyUp({keyCode: keyCodes.Down}, query, close);
2740
+ eq(query, 'search');
2741
+ }, {value: ''});
2742
+ testVim('exCommand_history', function(cm, vim, helpers) {
2743
+ cm.openDialog = helpers.fakeOpenDialog('registers');
2744
+ helpers.doKeys(':');
2745
+ cm.openDialog = helpers.fakeOpenDialog('sort');
2746
+ helpers.doKeys(':');
2747
+ cm.openDialog = helpers.fakeOpenDialog('map');
2748
+ helpers.doKeys(':');
2749
+ cm.openDialog = helpers.fakeOpenDialog('invalid');
2750
+ helpers.doKeys(':');
2751
+ var onKeyDown;
2752
+ var onKeyUp;
2753
+ var input = '';
2754
+ var keyCodes = {
2755
+ Up: 38,
2756
+ Down: 40,
2757
+ s: 115
2758
+ };
2759
+ cm.openDialog = function(template, callback, options) {
2760
+ onKeyUp = options.onKeyUp;
2761
+ onKeyDown = options.onKeyDown;
2762
+ };
2763
+ var close = function(newVal) {
2764
+ if (typeof newVal == 'string') input = newVal;
2765
+ }
2766
+ helpers.doKeys(':');
2767
+ onKeyDown({keyCode: keyCodes.Up}, input, close);
2768
+ eq(input, 'invalid');
2769
+ onKeyDown({keyCode: keyCodes.Up}, input, close);
2770
+ eq(input, 'map');
2771
+ onKeyDown({keyCode: keyCodes.Up}, input, close);
2772
+ eq(input, 'sort');
2773
+ onKeyDown({keyCode: keyCodes.Up}, input, close);
2774
+ eq(input, 'registers');
2775
+ onKeyDown({keyCode: keyCodes.s}, '', close);
2776
+ input = 's';
2777
+ onKeyDown({keyCode: keyCodes.Up}, input, close);
2778
+ eq(input, 'sort');
2779
+ }, {value: ''});
2780
+ testVim('.', function(cm, vim, helpers) {
2781
+ cm.setCursor(0, 0);
2782
+ helpers.doKeys('2', 'd', 'w');
2783
+ helpers.doKeys('.');
2784
+ eq('5 6', cm.getValue());
2785
+ }, { value: '1 2 3 4 5 6'});
2786
+ testVim('._repeat', function(cm, vim, helpers) {
2787
+ cm.setCursor(0, 0);
2788
+ helpers.doKeys('2', 'd', 'w');
2789
+ helpers.doKeys('3', '.');
2790
+ eq('6', cm.getValue());
2791
+ }, { value: '1 2 3 4 5 6'});
2792
+ testVim('._insert', function(cm, vim, helpers) {
2793
+ helpers.doKeys('i');
2794
+ cm.replaceRange('test', cm.getCursor());
2795
+ helpers.doKeys('<Esc>');
2796
+ helpers.doKeys('.');
2797
+ eq('testestt', cm.getValue());
2798
+ helpers.assertCursorAt(0, 6);
2799
+ }, { value: ''});
2800
+ testVim('._insert_repeat', function(cm, vim, helpers) {
2801
+ helpers.doKeys('i');
2802
+ cm.replaceRange('test', cm.getCursor());
2803
+ cm.setCursor(0, 4);
2804
+ helpers.doKeys('<Esc>');
2805
+ helpers.doKeys('2', '.');
2806
+ eq('testesttestt', cm.getValue());
2807
+ helpers.assertCursorAt(0, 10);
2808
+ }, { value: ''});
2809
+ testVim('._repeat_insert', function(cm, vim, helpers) {
2810
+ helpers.doKeys('3', 'i');
2811
+ cm.replaceRange('te', cm.getCursor());
2812
+ cm.setCursor(0, 2);
2813
+ helpers.doKeys('<Esc>');
2814
+ helpers.doKeys('.');
2815
+ eq('tetettetetee', cm.getValue());
2816
+ helpers.assertCursorAt(0, 10);
2817
+ }, { value: ''});
2818
+ testVim('._insert_o', function(cm, vim, helpers) {
2819
+ helpers.doKeys('o');
2820
+ cm.replaceRange('z', cm.getCursor());
2821
+ cm.setCursor(1, 1);
2822
+ helpers.doKeys('<Esc>');
2823
+ helpers.doKeys('.');
2824
+ eq('\nz\nz', cm.getValue());
2825
+ helpers.assertCursorAt(2, 0);
2826
+ }, { value: ''});
2827
+ testVim('._insert_o_repeat', function(cm, vim, helpers) {
2828
+ helpers.doKeys('o');
2829
+ cm.replaceRange('z', cm.getCursor());
2830
+ helpers.doKeys('<Esc>');
2831
+ cm.setCursor(1, 0);
2832
+ helpers.doKeys('2', '.');
2833
+ eq('\nz\nz\nz', cm.getValue());
2834
+ helpers.assertCursorAt(3, 0);
2835
+ }, { value: ''});
2836
+ testVim('._insert_o_indent', function(cm, vim, helpers) {
2837
+ helpers.doKeys('o');
2838
+ cm.replaceRange('z', cm.getCursor());
2839
+ helpers.doKeys('<Esc>');
2840
+ cm.setCursor(1, 2);
2841
+ helpers.doKeys('.');
2842
+ eq('{\n z\n z', cm.getValue());
2843
+ helpers.assertCursorAt(2, 2);
2844
+ }, { value: '{'});
2845
+ testVim('._insert_cw', function(cm, vim, helpers) {
2846
+ helpers.doKeys('c', 'w');
2847
+ cm.replaceRange('test', cm.getCursor());
2848
+ helpers.doKeys('<Esc>');
2849
+ cm.setCursor(0, 3);
2850
+ helpers.doKeys('2', 'l');
2851
+ helpers.doKeys('.');
2852
+ eq('test test word3', cm.getValue());
2853
+ helpers.assertCursorAt(0, 8);
2854
+ }, { value: 'word1 word2 word3' });
2855
+ testVim('._insert_cw_repeat', function(cm, vim, helpers) {
2856
+ // For some reason, repeat cw in desktop VIM will does not repeat insert mode
2857
+ // changes. Will conform to that behavior.
2858
+ helpers.doKeys('c', 'w');
2859
+ cm.replaceRange('test', cm.getCursor());
2860
+ helpers.doKeys('<Esc>');
2861
+ cm.setCursor(0, 4);
2862
+ helpers.doKeys('l');
2863
+ helpers.doKeys('2', '.');
2864
+ eq('test test', cm.getValue());
2865
+ helpers.assertCursorAt(0, 8);
2866
+ }, { value: 'word1 word2 word3' });
2867
+ testVim('._delete', function(cm, vim, helpers) {
2868
+ cm.setCursor(0, 5);
2869
+ helpers.doKeys('i');
2870
+ helpers.doInsertModeKeys('Backspace');
2871
+ helpers.doKeys('<Esc>');
2872
+ helpers.doKeys('.');
2873
+ eq('zace', cm.getValue());
2874
+ helpers.assertCursorAt(0, 1);
2875
+ }, { value: 'zabcde'});
2876
+ testVim('._delete_repeat', function(cm, vim, helpers) {
2877
+ cm.setCursor(0, 6);
2878
+ helpers.doKeys('i');
2879
+ helpers.doInsertModeKeys('Backspace');
2880
+ helpers.doKeys('<Esc>');
2881
+ helpers.doKeys('2', '.');
2882
+ eq('zzce', cm.getValue());
2883
+ helpers.assertCursorAt(0, 1);
2884
+ }, { value: 'zzabcde'});
2885
+ testVim('._visual_>', function(cm, vim, helpers) {
2886
+ cm.setCursor(0, 0);
2887
+ helpers.doKeys('V', 'j', '>');
2888
+ cm.setCursor(2, 0)
2889
+ helpers.doKeys('.');
2890
+ eq(' 1\n 2\n 3\n 4', cm.getValue());
2891
+ helpers.assertCursorAt(2, 2);
2892
+ }, { value: '1\n2\n3\n4'});
2893
+ testVim('f;', function(cm, vim, helpers) {
2894
+ cm.setCursor(0, 0);
2895
+ helpers.doKeys('f', 'x');
2896
+ helpers.doKeys(';');
2897
+ helpers.doKeys('2', ';');
2898
+ eq(9, cm.getCursor().ch);
2899
+ }, { value: '01x3xx678x'});
2900
+ testVim('F;', function(cm, vim, helpers) {
2901
+ cm.setCursor(0, 8);
2902
+ helpers.doKeys('F', 'x');
2903
+ helpers.doKeys(';');
2904
+ helpers.doKeys('2', ';');
2905
+ eq(2, cm.getCursor().ch);
2906
+ }, { value: '01x3xx6x8x'});
2907
+ testVim('t;', function(cm, vim, helpers) {
2908
+ cm.setCursor(0, 0);
2909
+ helpers.doKeys('t', 'x');
2910
+ helpers.doKeys(';');
2911
+ helpers.doKeys('2', ';');
2912
+ eq(8, cm.getCursor().ch);
2913
+ }, { value: '01x3xx678x'});
2914
+ testVim('T;', function(cm, vim, helpers) {
2915
+ cm.setCursor(0, 9);
2916
+ helpers.doKeys('T', 'x');
2917
+ helpers.doKeys(';');
2918
+ helpers.doKeys('2', ';');
2919
+ eq(2, cm.getCursor().ch);
2920
+ }, { value: '0xx3xx678x'});
2921
+ testVim('f,', function(cm, vim, helpers) {
2922
+ cm.setCursor(0, 6);
2923
+ helpers.doKeys('f', 'x');
2924
+ helpers.doKeys(',');
2925
+ helpers.doKeys('2', ',');
2926
+ eq(2, cm.getCursor().ch);
2927
+ }, { value: '01x3xx678x'});
2928
+ testVim('F,', function(cm, vim, helpers) {
2929
+ cm.setCursor(0, 3);
2930
+ helpers.doKeys('F', 'x');
2931
+ helpers.doKeys(',');
2932
+ helpers.doKeys('2', ',');
2933
+ eq(9, cm.getCursor().ch);
2934
+ }, { value: '01x3xx678x'});
2935
+ testVim('t,', function(cm, vim, helpers) {
2936
+ cm.setCursor(0, 6);
2937
+ helpers.doKeys('t', 'x');
2938
+ helpers.doKeys(',');
2939
+ helpers.doKeys('2', ',');
2940
+ eq(3, cm.getCursor().ch);
2941
+ }, { value: '01x3xx678x'});
2942
+ testVim('T,', function(cm, vim, helpers) {
2943
+ cm.setCursor(0, 4);
2944
+ helpers.doKeys('T', 'x');
2945
+ helpers.doKeys(',');
2946
+ helpers.doKeys('2', ',');
2947
+ eq(8, cm.getCursor().ch);
2948
+ }, { value: '01x3xx67xx'});
2949
+ testVim('fd,;', function(cm, vim, helpers) {
2950
+ cm.setCursor(0, 0);
2951
+ helpers.doKeys('f', '4');
2952
+ cm.setCursor(0, 0);
2953
+ helpers.doKeys('d', ';');
2954
+ eq('56789', cm.getValue());
2955
+ helpers.doKeys('u');
2956
+ cm.setCursor(0, 9);
2957
+ helpers.doKeys('d', ',');
2958
+ eq('01239', cm.getValue());
2959
+ }, { value: '0123456789'});
2960
+ testVim('Fd,;', function(cm, vim, helpers) {
2961
+ cm.setCursor(0, 9);
2962
+ helpers.doKeys('F', '4');
2963
+ cm.setCursor(0, 9);
2964
+ helpers.doKeys('d', ';');
2965
+ eq('01239', cm.getValue());
2966
+ helpers.doKeys('u');
2967
+ cm.setCursor(0, 0);
2968
+ helpers.doKeys('d', ',');
2969
+ eq('56789', cm.getValue());
2970
+ }, { value: '0123456789'});
2971
+ testVim('td,;', function(cm, vim, helpers) {
2972
+ cm.setCursor(0, 0);
2973
+ helpers.doKeys('t', '4');
2974
+ cm.setCursor(0, 0);
2975
+ helpers.doKeys('d', ';');
2976
+ eq('456789', cm.getValue());
2977
+ helpers.doKeys('u');
2978
+ cm.setCursor(0, 9);
2979
+ helpers.doKeys('d', ',');
2980
+ eq('012349', cm.getValue());
2981
+ }, { value: '0123456789'});
2982
+ testVim('Td,;', function(cm, vim, helpers) {
2983
+ cm.setCursor(0, 9);
2984
+ helpers.doKeys('T', '4');
2985
+ cm.setCursor(0, 9);
2986
+ helpers.doKeys('d', ';');
2987
+ eq('012349', cm.getValue());
2988
+ helpers.doKeys('u');
2989
+ cm.setCursor(0, 0);
2990
+ helpers.doKeys('d', ',');
2991
+ eq('456789', cm.getValue());
2992
+ }, { value: '0123456789'});
2993
+ testVim('fc,;', function(cm, vim, helpers) {
2994
+ cm.setCursor(0, 0);
2995
+ helpers.doKeys('f', '4');
2996
+ cm.setCursor(0, 0);
2997
+ helpers.doKeys('c', ';', '<Esc>');
2998
+ eq('56789', cm.getValue());
2999
+ helpers.doKeys('u');
3000
+ cm.setCursor(0, 9);
3001
+ helpers.doKeys('c', ',');
3002
+ eq('01239', cm.getValue());
3003
+ }, { value: '0123456789'});
3004
+ testVim('Fc,;', function(cm, vim, helpers) {
3005
+ cm.setCursor(0, 9);
3006
+ helpers.doKeys('F', '4');
3007
+ cm.setCursor(0, 9);
3008
+ helpers.doKeys('c', ';', '<Esc>');
3009
+ eq('01239', cm.getValue());
3010
+ helpers.doKeys('u');
3011
+ cm.setCursor(0, 0);
3012
+ helpers.doKeys('c', ',');
3013
+ eq('56789', cm.getValue());
3014
+ }, { value: '0123456789'});
3015
+ testVim('tc,;', function(cm, vim, helpers) {
3016
+ cm.setCursor(0, 0);
3017
+ helpers.doKeys('t', '4');
3018
+ cm.setCursor(0, 0);
3019
+ helpers.doKeys('c', ';', '<Esc>');
3020
+ eq('456789', cm.getValue());
3021
+ helpers.doKeys('u');
3022
+ cm.setCursor(0, 9);
3023
+ helpers.doKeys('c', ',');
3024
+ eq('012349', cm.getValue());
3025
+ }, { value: '0123456789'});
3026
+ testVim('Tc,;', function(cm, vim, helpers) {
3027
+ cm.setCursor(0, 9);
3028
+ helpers.doKeys('T', '4');
3029
+ cm.setCursor(0, 9);
3030
+ helpers.doKeys('c', ';', '<Esc>');
3031
+ eq('012349', cm.getValue());
3032
+ helpers.doKeys('u');
3033
+ cm.setCursor(0, 0);
3034
+ helpers.doKeys('c', ',');
3035
+ eq('456789', cm.getValue());
3036
+ }, { value: '0123456789'});
3037
+ testVim('fy,;', function(cm, vim, helpers) {
3038
+ cm.setCursor(0, 0);
3039
+ helpers.doKeys('f', '4');
3040
+ cm.setCursor(0, 0);
3041
+ helpers.doKeys('y', ';', 'P');
3042
+ eq('012340123456789', cm.getValue());
3043
+ helpers.doKeys('u');
3044
+ cm.setCursor(0, 9);
3045
+ helpers.doKeys('y', ',', 'P');
3046
+ eq('012345678456789', cm.getValue());
3047
+ }, { value: '0123456789'});
3048
+ testVim('Fy,;', function(cm, vim, helpers) {
3049
+ cm.setCursor(0, 9);
3050
+ helpers.doKeys('F', '4');
3051
+ cm.setCursor(0, 9);
3052
+ helpers.doKeys('y', ';', 'p');
3053
+ eq('012345678945678', cm.getValue());
3054
+ helpers.doKeys('u');
3055
+ cm.setCursor(0, 0);
3056
+ helpers.doKeys('y', ',', 'P');
3057
+ eq('012340123456789', cm.getValue());
3058
+ }, { value: '0123456789'});
3059
+ testVim('ty,;', function(cm, vim, helpers) {
3060
+ cm.setCursor(0, 0);
3061
+ helpers.doKeys('t', '4');
3062
+ cm.setCursor(0, 0);
3063
+ helpers.doKeys('y', ';', 'P');
3064
+ eq('01230123456789', cm.getValue());
3065
+ helpers.doKeys('u');
3066
+ cm.setCursor(0, 9);
3067
+ helpers.doKeys('y', ',', 'p');
3068
+ eq('01234567895678', cm.getValue());
3069
+ }, { value: '0123456789'});
3070
+ testVim('Ty,;', function(cm, vim, helpers) {
3071
+ cm.setCursor(0, 9);
3072
+ helpers.doKeys('T', '4');
3073
+ cm.setCursor(0, 9);
3074
+ helpers.doKeys('y', ';', 'p');
3075
+ eq('01234567895678', cm.getValue());
3076
+ helpers.doKeys('u');
3077
+ cm.setCursor(0, 0);
3078
+ helpers.doKeys('y', ',', 'P');
3079
+ eq('01230123456789', cm.getValue());
3080
+ }, { value: '0123456789'});
3081
+ testVim('HML', function(cm, vim, helpers) {
3082
+ var lines = 35;
3083
+ var textHeight = cm.defaultTextHeight();
3084
+ cm.setSize(600, lines*textHeight);
3085
+ cm.setCursor(120, 0);
3086
+ cm.refresh(); //ace!
3087
+ helpers.doKeys('H');
3088
+ helpers.assertCursorAt(86, 2);
3089
+ helpers.doKeys('L');
3090
+ helpers.assertCursorAt(120, 4);
3091
+ helpers.doKeys('M');
3092
+ helpers.assertCursorAt(103,4);
3093
+ }, { value: (function(){
3094
+ var lines = new Array(100);
3095
+ var upper = ' xx\n';
3096
+ var lower = ' xx\n';
3097
+ upper = lines.join(upper);
3098
+ lower = lines.join(lower);
3099
+ return upper + lower;
3100
+ })()});
3101
+
3102
+ var zVals = [];
3103
+ forEach(['zb','zz','zt','z-','z.','z<CR>'], function(e, idx){
3104
+ var lineNum = 250;
3105
+ var lines = 35;
3106
+ testVim(e, function(cm, vim, helpers) {
3107
+ var k1 = e[0];
3108
+ var k2 = e.substring(1);
3109
+ var textHeight = cm.defaultTextHeight();
3110
+ cm.setSize(600, lines*textHeight);
3111
+ cm.setCursor(lineNum, 0);
3112
+ helpers.doKeys(k1, k2);
3113
+ zVals[idx] = cm.getScrollInfo().top;
3114
+ }, { value: (function(){
3115
+ return new Array(500).join('\n');
3116
+ })()});
3117
+ });
3118
+ testVim('zb<zz', function(cm, vim, helpers){
3119
+ eq(zVals[0]<zVals[1], true);
3120
+ });
3121
+ testVim('zz<zt', function(cm, vim, helpers){
3122
+ eq(zVals[1]<zVals[2], true);
3123
+ });
3124
+ testVim('zb==z-', function(cm, vim, helpers){
3125
+ eq(zVals[0], zVals[3]);
3126
+ });
3127
+ testVim('zz==z.', function(cm, vim, helpers){
3128
+ eq(zVals[1], zVals[4]);
3129
+ });
3130
+ testVim('zt==z<CR>', function(cm, vim, helpers){
3131
+ eq(zVals[2], zVals[5]);
3132
+ });
3133
+
3134
+ var moveTillCharacterSandbox =
3135
+ 'The quick brown fox \n'
3136
+ 'jumped over the lazy dog.'
3137
+ testVim('moveTillCharacter', function(cm, vim, helpers){
3138
+ cm.setCursor(0, 0);
3139
+ // Search for the 'q'.
3140
+ cm.openDialog = helpers.fakeOpenDialog('q');
3141
+ helpers.doKeys('/');
3142
+ eq(4, cm.getCursor().ch);
3143
+ // Jump to just before the first o in the list.
3144
+ helpers.doKeys('t');
3145
+ helpers.doKeys('o');
3146
+ eq('The quick brown fox \n', cm.getValue());
3147
+ // Delete that one character.
3148
+ helpers.doKeys('d');
3149
+ helpers.doKeys('t');
3150
+ helpers.doKeys('o');
3151
+ eq('The quick bown fox \n', cm.getValue());
3152
+ // Delete everything until the next 'o'.
3153
+ helpers.doKeys('.');
3154
+ eq('The quick box \n', cm.getValue());
3155
+ // An unmatched character should have no effect.
3156
+ helpers.doKeys('d');
3157
+ helpers.doKeys('t');
3158
+ helpers.doKeys('q');
3159
+ eq('The quick box \n', cm.getValue());
3160
+ // Matches should only be possible on single lines.
3161
+ helpers.doKeys('d');
3162
+ helpers.doKeys('t');
3163
+ helpers.doKeys('z');
3164
+ eq('The quick box \n', cm.getValue());
3165
+ // After all that, the search for 'q' should still be active, so the 'N' command
3166
+ // can run it again in reverse. Use that to delete everything back to the 'q'.
3167
+ helpers.doKeys('d');
3168
+ helpers.doKeys('N');
3169
+ eq('The ox \n', cm.getValue());
3170
+ eq(4, cm.getCursor().ch);
3171
+ }, { value: moveTillCharacterSandbox});
3172
+ testVim('searchForPipe', function(cm, vim, helpers){
3173
+ CodeMirror.Vim.setOption('pcre', false);
3174
+ cm.setCursor(0, 0);
3175
+ // Search for the '|'.
3176
+ cm.openDialog = helpers.fakeOpenDialog('|');
3177
+ helpers.doKeys('/');
3178
+ eq(4, cm.getCursor().ch);
3179
+ }, { value: 'this|that'});
3180
+
3181
+
3182
+ var scrollMotionSandbox =
3183
+ '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'
3184
+ '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'
3185
+ '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'
3186
+ '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n';
3187
+ testVim('scrollMotion', function(cm, vim, helpers){
3188
+ var prevCursor, prevScrollInfo;
3189
+ cm.setCursor(0, 0);
3190
+ // ctrl-y at the top of the file should have no effect.
3191
+ helpers.doKeys('<C-y>');
3192
+ eq(0, cm.getCursor().line);
3193
+ prevScrollInfo = cm.getScrollInfo();
3194
+ helpers.doKeys('<C-e>');
3195
+ eq(1, cm.getCursor().line);
3196
+ is(prevScrollInfo.top < cm.getScrollInfo().top);
3197
+ // Jump to the end of the sandbox.
3198
+ cm.setCursor(1000, 0);
3199
+ cm.refresh(); //ace!
3200
+ prevCursor = cm.getCursor();
3201
+ // ctrl-e at the bottom of the file should have no effect.
3202
+ helpers.doKeys('<C-e>');
3203
+ eq(prevCursor.line, cm.getCursor().line);
3204
+ cm.refresh(); //ace!
3205
+ prevScrollInfo = cm.getScrollInfo();
3206
+ helpers.doKeys('<C-y>');
3207
+ eq(prevCursor.line - 1, cm.getCursor().line);
3208
+ is(prevScrollInfo.top > cm.getScrollInfo().top);
3209
+ }, { value: scrollMotionSandbox});
3210
+
3211
+ var squareBracketMotionSandbox = ''+
3212
+ '({\n'+//0
3213
+ ' ({\n'+//11
3214
+ ' /*comment {\n'+//2
3215
+ ' */(\n'+//3
3216
+ '#else \n'+//4
3217
+ ' /* )\n'+//5
3218
+ '#if }\n'+//6
3219
+ ' )}*/\n'+//7
3220
+ ')}\n'+//8
3221
+ '{}\n'+//9
3222
+ '#else {{\n'+//10
3223
+ '{}\n'+//11
3224
+ '}\n'+//12
3225
+ '{\n'+//13
3226
+ '#endif\n'+//14
3227
+ '}\n'+//15
3228
+ '}\n'+//16
3229
+ '#else';//17
3230
+ testVim('[[, ]]', function(cm, vim, helpers) {
3231
+ cm.setCursor(0, 0);
3232
+ helpers.doKeys(']', ']');
3233
+ helpers.assertCursorAt(9,0);
3234
+ helpers.doKeys('2', ']', ']');
3235
+ helpers.assertCursorAt(13,0);
3236
+ helpers.doKeys(']', ']');
3237
+ helpers.assertCursorAt(17,0);
3238
+ helpers.doKeys('[', '[');
3239
+ helpers.assertCursorAt(13,0);
3240
+ helpers.doKeys('2', '[', '[');
3241
+ helpers.assertCursorAt(9,0);
3242
+ helpers.doKeys('[', '[');
3243
+ helpers.assertCursorAt(0,0);
3244
+ }, { value: squareBracketMotionSandbox});
3245
+ testVim('[], ][', function(cm, vim, helpers) {
3246
+ cm.setCursor(0, 0);
3247
+ helpers.doKeys(']', '[');
3248
+ helpers.assertCursorAt(12,0);
3249
+ helpers.doKeys('2', ']', '[');
3250
+ helpers.assertCursorAt(16,0);
3251
+ helpers.doKeys(']', '[');
3252
+ helpers.assertCursorAt(17,0);
3253
+ helpers.doKeys('[', ']');
3254
+ helpers.assertCursorAt(16,0);
3255
+ helpers.doKeys('2', '[', ']');
3256
+ helpers.assertCursorAt(12,0);
3257
+ helpers.doKeys('[', ']');
3258
+ helpers.assertCursorAt(0,0);
3259
+ }, { value: squareBracketMotionSandbox});
3260
+ testVim('[{, ]}', function(cm, vim, helpers) {
3261
+ cm.setCursor(4, 10);
3262
+ helpers.doKeys('[', '{');
3263
+ helpers.assertCursorAt(2,12);
3264
+ helpers.doKeys('2', '[', '{');
3265
+ helpers.assertCursorAt(0,1);
3266
+ cm.setCursor(4, 10);
3267
+ helpers.doKeys(']', '}');
3268
+ helpers.assertCursorAt(6,11);
3269
+ helpers.doKeys('2', ']', '}');
3270
+ helpers.assertCursorAt(8,1);
3271
+ cm.setCursor(0,1);
3272
+ helpers.doKeys(']', '}');
3273
+ helpers.assertCursorAt(8,1);
3274
+ helpers.doKeys('[', '{');
3275
+ helpers.assertCursorAt(0,1);
3276
+ }, { value: squareBracketMotionSandbox});
3277
+ testVim('[(, ])', function(cm, vim, helpers) {
3278
+ cm.setCursor(4, 10);
3279
+ helpers.doKeys('[', '(');
3280
+ helpers.assertCursorAt(3,14);
3281
+ helpers.doKeys('2', '[', '(');
3282
+ helpers.assertCursorAt(0,0);
3283
+ cm.setCursor(4, 10);
3284
+ helpers.doKeys(']', ')');
3285
+ helpers.assertCursorAt(5,11);
3286
+ helpers.doKeys('2', ']', ')');
3287
+ helpers.assertCursorAt(8,0);
3288
+ helpers.doKeys('[', '(');
3289
+ helpers.assertCursorAt(0,0);
3290
+ helpers.doKeys(']', ')');
3291
+ helpers.assertCursorAt(8,0);
3292
+ }, { value: squareBracketMotionSandbox});
3293
+ testVim('[*, ]*, [/, ]/', function(cm, vim, helpers) {
3294
+ forEach(['*', '/'], function(key){
3295
+ cm.setCursor(7, 0);
3296
+ helpers.doKeys('2', '[', key);
3297
+ helpers.assertCursorAt(2,2);
3298
+ helpers.doKeys('2', ']', key);
3299
+ helpers.assertCursorAt(7,5);
3300
+ });
3301
+ }, { value: squareBracketMotionSandbox});
3302
+ testVim('[#, ]#', function(cm, vim, helpers) {
3303
+ cm.setCursor(10, 3);
3304
+ helpers.doKeys('2', '[', '#');
3305
+ helpers.assertCursorAt(4,0);
3306
+ helpers.doKeys('5', ']', '#');
3307
+ helpers.assertCursorAt(17,0);
3308
+ cm.setCursor(10, 3);
3309
+ helpers.doKeys(']', '#');
3310
+ helpers.assertCursorAt(14,0);
3311
+ }, { value: squareBracketMotionSandbox});
3312
+ testVim('[m, ]m, [M, ]M', function(cm, vim, helpers) {
3313
+ cm.setCursor(11, 0);
3314
+ helpers.doKeys('[', 'm');
3315
+ helpers.assertCursorAt(10,7);
3316
+ helpers.doKeys('4', '[', 'm');
3317
+ helpers.assertCursorAt(1,3);
3318
+ helpers.doKeys('5', ']', 'm');
3319
+ helpers.assertCursorAt(11,0);
3320
+ helpers.doKeys('[', 'M');
3321
+ helpers.assertCursorAt(9,1);
3322
+ helpers.doKeys('3', ']', 'M');
3323
+ helpers.assertCursorAt(15,0);
3324
+ helpers.doKeys('5', '[', 'M');
3325
+ helpers.assertCursorAt(7,3);
3326
+ }, { value: squareBracketMotionSandbox});
3327
+
3328
+ // Ex mode tests
3329
+ testVim('ex_go_to_line', function(cm, vim, helpers) {
3330
+ cm.setCursor(0, 0);
3331
+ helpers.doEx('4');
3332
+ helpers.assertCursorAt(3, 0);
3333
+ }, { value: 'a\nb\nc\nd\ne\n'});
3334
+ testVim('ex_write', function(cm, vim, helpers) {
3335
+ var tmp = CodeMirror.commands.save;
3336
+ var written;
3337
+ var actualCm;
3338
+ CodeMirror.commands.save = function(cm) {
3339
+ written = true;
3340
+ actualCm = cm;
3341
+ };
3342
+ // Test that w, wr, wri ... write all trigger :write.
3343
+ var command = 'write';
3344
+ for (var i = 1; i < command.length; i++) {
3345
+ written = false;
3346
+ actualCm = null;
3347
+ helpers.doEx(command.substring(0, i));
3348
+ eq(written, true);
3349
+ eq(actualCm, cm);
3350
+ }
3351
+ CodeMirror.commands.save = tmp;
3352
+ });
3353
+ testVim('ex_sort', function(cm, vim, helpers) {
3354
+ helpers.doEx('sort');
3355
+ eq('Z\na\nb\nc\nd', cm.getValue());
3356
+ }, { value: 'b\nZ\nd\nc\na'});
3357
+ testVim('ex_sort_reverse', function(cm, vim, helpers) {
3358
+ helpers.doEx('sort!');
3359
+ eq('d\nc\nb\na', cm.getValue());
3360
+ }, { value: 'b\nd\nc\na'});
3361
+ testVim('ex_sort_range', function(cm, vim, helpers) {
3362
+ helpers.doEx('2,3sort');
3363
+ eq('b\nc\nd\na', cm.getValue());
3364
+ }, { value: 'b\nd\nc\na'});
3365
+ testVim('ex_sort_oneline', function(cm, vim, helpers) {
3366
+ helpers.doEx('2sort');
3367
+ // Expect no change.
3368
+ eq('b\nd\nc\na', cm.getValue());
3369
+ }, { value: 'b\nd\nc\na'});
3370
+ testVim('ex_sort_ignoreCase', function(cm, vim, helpers) {
3371
+ helpers.doEx('sort i');
3372
+ eq('a\nb\nc\nd\nZ', cm.getValue());
3373
+ }, { value: 'b\nZ\nd\nc\na'});
3374
+ testVim('ex_sort_unique', function(cm, vim, helpers) {
3375
+ helpers.doEx('sort u');
3376
+ eq('Z\na\nb\nc\nd', cm.getValue());
3377
+ }, { value: 'b\nZ\na\na\nd\na\nc\na'});
3378
+ testVim('ex_sort_decimal', function(cm, vim, helpers) {
3379
+ helpers.doEx('sort d');
3380
+ eq('d3\n s5\n6\n.9', cm.getValue());
3381
+ }, { value: '6\nd3\n s5\n.9'});
3382
+ testVim('ex_sort_decimal_negative', function(cm, vim, helpers) {
3383
+ helpers.doEx('sort d');
3384
+ eq('z-9\nd3\n s5\n6\n.9', cm.getValue());
3385
+ }, { value: '6\nd3\n s5\n.9\nz-9'});
3386
+ testVim('ex_sort_decimal_reverse', function(cm, vim, helpers) {
3387
+ helpers.doEx('sort! d');
3388
+ eq('.9\n6\n s5\nd3', cm.getValue());
3389
+ }, { value: '6\nd3\n s5\n.9'});
3390
+ testVim('ex_sort_hex', function(cm, vim, helpers) {
3391
+ helpers.doEx('sort x');
3392
+ eq(' s5\n6\n.9\n&0xB\nd3', cm.getValue());
3393
+ }, { value: '6\nd3\n s5\n&0xB\n.9'});
3394
+ testVim('ex_sort_octal', function(cm, vim, helpers) {
3395
+ helpers.doEx('sort o');
3396
+ eq('.8\n.9\nd3\n s5\n6', cm.getValue());
3397
+ }, { value: '6\nd3\n s5\n.9\n.8'});
3398
+ testVim('ex_sort_decimal_mixed', function(cm, vim, helpers) {
3399
+ helpers.doEx('sort d');
3400
+ eq('y\nz\nc1\nb2\na3', cm.getValue());
3401
+ }, { value: 'a3\nz\nc1\ny\nb2'});
3402
+ testVim('ex_sort_decimal_mixed_reverse', function(cm, vim, helpers) {
3403
+ helpers.doEx('sort! d');
3404
+ eq('a3\nb2\nc1\nz\ny', cm.getValue());
3405
+ }, { value: 'a3\nz\nc1\ny\nb2'});
3406
+ // test for :global command
3407
+ testVim('ex_global', function(cm, vim, helpers) {
3408
+ cm.setCursor(0, 0);
3409
+ helpers.doEx('g/one/s//two');
3410
+ eq('two two\n two two\n two two', cm.getValue());
3411
+ helpers.doEx('1,2g/two/s//one');
3412
+ eq('one one\n one one\n two two', cm.getValue());
3413
+ }, {value: 'one one\n one one\n one one'});
3414
+ testVim('ex_global_confirm', function(cm, vim, helpers) {
3415
+ cm.setCursor(0, 0);
3416
+ var onKeyDown;
3417
+ var openDialogSave = cm.openDialog;
3418
+ var KEYCODES = {
3419
+ a: 65,
3420
+ n: 78,
3421
+ q: 81,
3422
+ y: 89
3423
+ };
3424
+ // Intercept the ex command, 'global'
3425
+ cm.openDialog = function(template, callback, options) {
3426
+ // Intercept the prompt for the embedded ex command, 'substitute'
3427
+ cm.openDialog = function(template, callback, options) {
3428
+ onKeyDown = options.onKeyDown;
3429
+ };
3430
+ callback('g/one/s//two/gc');
3431
+ };
3432
+ helpers.doKeys(':');
3433
+ var close = function() {};
3434
+ onKeyDown({keyCode: KEYCODES.n}, '', close);
3435
+ onKeyDown({keyCode: KEYCODES.y}, '', close);
3436
+ onKeyDown({keyCode: KEYCODES.a}, '', close);
3437
+ onKeyDown({keyCode: KEYCODES.q}, '', close);
3438
+ onKeyDown({keyCode: KEYCODES.y}, '', close);
3439
+ eq('one two\n two two\n one one\n two one\n one one', cm.getValue());
3440
+ }, {value: 'one one\n one one\n one one\n one one\n one one'});
3441
+ // Basic substitute tests.
3442
+ testVim('ex_substitute_same_line', function(cm, vim, helpers) {
3443
+ cm.setCursor(1, 0);
3444
+ helpers.doEx('s/one/two/g');
3445
+ eq('one one\n two two', cm.getValue());
3446
+ }, { value: 'one one\n one one'});
3447
+ testVim('ex_substitute_full_file', function(cm, vim, helpers) {
3448
+ cm.setCursor(1, 0);
3449
+ helpers.doEx('%s/one/two/g');
3450
+ eq('two two\n two two', cm.getValue());
3451
+ }, { value: 'one one\n one one'});
3452
+ testVim('ex_substitute_input_range', function(cm, vim, helpers) {
3453
+ cm.setCursor(1, 0);
3454
+ helpers.doEx('1,3s/\\d/0/g');
3455
+ eq('0\n0\n0\n4', cm.getValue());
3456
+ }, { value: '1\n2\n3\n4' });
3457
+ testVim('ex_substitute_visual_range', function(cm, vim, helpers) {
3458
+ cm.setCursor(1, 0);
3459
+ // Set last visual mode selection marks '< and '> at lines 2 and 4
3460
+ helpers.doKeys('V', '2', 'j', 'v');
3461
+ helpers.doEx('\'<,\'>s/\\d/0/g');
3462
+ eq('1\n0\n0\n0\n5', cm.getValue());
3463
+ }, { value: '1\n2\n3\n4\n5' });
3464
+ testVim('ex_substitute_empty_query', function(cm, vim, helpers) {
3465
+ // If the query is empty, use last query.
3466
+ cm.setCursor(1, 0);
3467
+ cm.openDialog = helpers.fakeOpenDialog('1');
3468
+ helpers.doKeys('/');
3469
+ helpers.doEx('s//b/g');
3470
+ eq('abb ab2 ab3', cm.getValue());
3471
+ }, { value: 'a11 a12 a13' });
3472
+ testVim('ex_substitute_javascript', function(cm, vim, helpers) {
3473
+ CodeMirror.Vim.setOption('pcre', false);
3474
+ cm.setCursor(1, 0);
3475
+ // Throw all the things that javascript likes to treat as special values
3476
+ // into the replace part. All should be literal (this is VIM).
3477
+ helpers.doEx('s/\\(\\d+\\)/$$ $\' $` $& \\1/g')
3478
+ eq('a $$ $\' $` $& 0 b', cm.getValue());
3479
+ }, { value: 'a 0 b' });
3480
+ testVim('ex_substitute_empty_arguments', function(cm,vim,helpers) {
3481
+ cm.setCursor(0, 0);
3482
+ helpers.doEx('s/a/b/g');
3483
+ cm.setCursor(1, 0);
3484
+ helpers.doEx('s');
3485
+ eq('b b\nb a', cm.getValue());
3486
+ }, {value: 'a a\na a'});
3487
+
3488
+ // More complex substitute tests that test both pcre and nopcre options.
3489
+ function testSubstitute(name, options) {
3490
+ testVim(name + '_pcre', function(cm, vim, helpers) {
3491
+ cm.setCursor(1, 0);
3492
+ CodeMirror.Vim.setOption('pcre', true);
3493
+ helpers.doEx(options.expr);
3494
+ eq(options.expectedValue, cm.getValue());
3495
+ }, options);
3496
+ // If no noPcreExpr is defined, assume that it's the same as the expr.
3497
+ var noPcreExpr = options.noPcreExpr ? options.noPcreExpr : options.expr;
3498
+ testVim(name + '_nopcre', function(cm, vim, helpers) {
3499
+ cm.setCursor(1, 0);
3500
+ CodeMirror.Vim.setOption('pcre', false);
3501
+ helpers.doEx(noPcreExpr);
3502
+ eq(options.expectedValue, cm.getValue());
3503
+ }, options);
3504
+ }
3505
+ testSubstitute('ex_substitute_capture', {
3506
+ value: 'a11 a12 a13',
3507
+ expectedValue: 'a1111 a1212 a1313',
3508
+ // $n is a backreference
3509
+ expr: 's/(\\d+)/$1$1/g',
3510
+ // \n is a backreference.
3511
+ noPcreExpr: 's/\\(\\d+\\)/\\1\\1/g'});
3512
+ testSubstitute('ex_substitute_capture2', {
3513
+ value: 'a 0 b',
3514
+ expectedValue: 'a $00 b',
3515
+ expr: 's/(\\d+)/$$$1$1/g',
3516
+ noPcreExpr: 's/\\(\\d+\\)/$\\1\\1/g'});
3517
+ testSubstitute('ex_substitute_nocapture', {
3518
+ value: 'a11 a12 a13',
3519
+ expectedValue: 'a$1$1 a$1$1 a$1$1',
3520
+ expr: 's/(\\d+)/$$1$$1/g',
3521
+ noPcreExpr: 's/\\(\\d+\\)/$1$1/g'});
3522
+ testSubstitute('ex_substitute_nocapture2', {
3523
+ value: 'a 0 b',
3524
+ expectedValue: 'a $10 b',
3525
+ expr: 's/(\\d+)/$$1$1/g',
3526
+ noPcreExpr: 's/\\(\\d+\\)/\\$1\\1/g'});
3527
+ testSubstitute('ex_substitute_nocapture', {
3528
+ value: 'a b c',
3529
+ expectedValue: 'a $ c',
3530
+ expr: 's/b/$$/',
3531
+ noPcreExpr: 's/b/$/'});
3532
+ testSubstitute('ex_substitute_slash_regex', {
3533
+ value: 'one/two \n three/four',
3534
+ expectedValue: 'one|two \n three|four',
3535
+ expr: '%s/\\//|'});
3536
+ testSubstitute('ex_substitute_pipe_regex', {
3537
+ value: 'one|two \n three|four',
3538
+ expectedValue: 'one,two \n three,four',
3539
+ expr: '%s/\\|/,/',
3540
+ noPcreExpr: '%s/|/,/'});
3541
+ testSubstitute('ex_substitute_or_regex', {
3542
+ value: 'one|two \n three|four',
3543
+ expectedValue: 'ana|twa \n thraa|faar',
3544
+ expr: '%s/o|e|u/a/g',
3545
+ noPcreExpr: '%s/o\\|e\\|u/a/g'});
3546
+ testSubstitute('ex_substitute_or_word_regex', {
3547
+ value: 'one|two \n three|four',
3548
+ expectedValue: 'five|five \n three|four',
3549
+ expr: '%s/(one|two)/five/g',
3550
+ noPcreExpr: '%s/\\(one\\|two\\)/five/g'});
3551
+ testSubstitute('ex_substitute_backslashslash_regex', {
3552
+ value: 'one\\two \n three\\four',
3553
+ expectedValue: 'one,two \n three,four',
3554
+ expr: '%s/\\\\/,'});
3555
+ testSubstitute('ex_substitute_slash_replacement', {
3556
+ value: 'one,two \n three,four',
3557
+ expectedValue: 'one/two \n three/four',
3558
+ expr: '%s/,/\\/'});
3559
+ testSubstitute('ex_substitute_backslash_replacement', {
3560
+ value: 'one,two \n three,four',
3561
+ expectedValue: 'one\\two \n three\\four',
3562
+ expr: '%s/,/\\\\/g'});
3563
+ testSubstitute('ex_substitute_multibackslash_replacement', {
3564
+ value: 'one,two \n three,four',
3565
+ expectedValue: 'one\\\\\\\\two \n three\\\\\\\\four', // 2*8 backslashes.
3566
+ expr: '%s/,/\\\\\\\\\\\\\\\\/g'}); // 16 backslashes.
3567
+ testSubstitute('ex_substitute_braces_word', {
3568
+ value: 'ababab abb ab{2}',
3569
+ expectedValue: 'ab abb ab{2}',
3570
+ expr: '%s/(ab){2}//g',
3571
+ noPcreExpr: '%s/\\(ab\\)\\{2\\}//g'});
3572
+ testSubstitute('ex_substitute_braces_range', {
3573
+ value: 'a aa aaa aaaa',
3574
+ expectedValue: 'a a',
3575
+ expr: '%s/a{2,3}//g',
3576
+ noPcreExpr: '%s/a\\{2,3\\}//g'});
3577
+ testSubstitute('ex_substitute_braces_literal', {
3578
+ value: 'ababab abb ab{2}',
3579
+ expectedValue: 'ababab abb ',
3580
+ expr: '%s/ab\\{2\\}//g',
3581
+ noPcreExpr: '%s/ab{2}//g'});
3582
+ testSubstitute('ex_substitute_braces_char', {
3583
+ value: 'ababab abb ab{2}',
3584
+ expectedValue: 'ababab ab{2}',
3585
+ expr: '%s/ab{2}//g',
3586
+ noPcreExpr: '%s/ab\\{2\\}//g'});
3587
+ testSubstitute('ex_substitute_braces_no_escape', {
3588
+ value: 'ababab abb ab{2}',
3589
+ expectedValue: 'ababab ab{2}',
3590
+ expr: '%s/ab{2}//g',
3591
+ noPcreExpr: '%s/ab\\{2}//g'});
3592
+ testSubstitute('ex_substitute_count', {
3593
+ value: '1\n2\n3\n4',
3594
+ expectedValue: '1\n0\n0\n4',
3595
+ expr: 's/\\d/0/i 2'});
3596
+ testSubstitute('ex_substitute_count_with_range', {
3597
+ value: '1\n2\n3\n4',
3598
+ expectedValue: '1\n2\n0\n0',
3599
+ expr: '1,3s/\\d/0/ 3'});
3600
+ testSubstitute('ex_substitute_not_global', {
3601
+ value: 'aaa\nbaa\ncaa',
3602
+ expectedValue: 'xaa\nbxa\ncxa',
3603
+ expr: '%s/a/x/'});
3604
+ function testSubstituteConfirm(name, command, initialValue, expectedValue, keys, finalPos) {
3605
+ testVim(name, function(cm, vim, helpers) {
3606
+ var savedOpenDialog = cm.openDialog;
3607
+ var savedKeyName = CodeMirror.keyName;
3608
+ var onKeyDown;
3609
+ var recordedCallback;
3610
+ var closed = true; // Start out closed, set false on second openDialog.
3611
+ function close() {
3612
+ closed = true;
3613
+ }
3614
+ // First openDialog should save callback.
3615
+ cm.openDialog = function(template, callback, options) {
3616
+ recordedCallback = callback;
3617
+ }
3618
+ // Do first openDialog.
3619
+ helpers.doKeys(':');
3620
+ // Second openDialog should save keyDown handler.
3621
+ cm.openDialog = function(template, callback, options) {
3622
+ onKeyDown = options.onKeyDown;
3623
+ closed = false;
3624
+ };
3625
+ // Return the command to Vim and trigger second openDialog.
3626
+ recordedCallback(command);
3627
+ // The event should really use keyCode, but here just mock it out and use
3628
+ // key and replace keyName to just return key.
3629
+ CodeMirror.keyName = function (e) { return e.key; }
3630
+ keys = keys.toUpperCase();
3631
+ for (var i = 0; i < keys.length; i++) {
3632
+ is(!closed);
3633
+ onKeyDown({ key: keys.charAt(i) }, '', close);
3634
+ }
3635
+ try {
3636
+ eq(expectedValue, cm.getValue());
3637
+ helpers.assertCursorAt(finalPos);
3638
+ is(closed);
3639
+ } catch(e) {
3640
+ throw e
3641
+ } finally {
3642
+ // Restore overriden functions.
3643
+ CodeMirror.keyName = savedKeyName;
3644
+ cm.openDialog = savedOpenDialog;
3645
+ }
3646
+ }, { value: initialValue });
3647
+ };
3648
+ testSubstituteConfirm('ex_substitute_confirm_emptydoc',
3649
+ '%s/x/b/c', '', '', '', makeCursor(0, 0));
3650
+ testSubstituteConfirm('ex_substitute_confirm_nomatch',
3651
+ '%s/x/b/c', 'ba a\nbab', 'ba a\nbab', '', makeCursor(0, 0));
3652
+ testSubstituteConfirm('ex_substitute_confirm_accept',
3653
+ '%s/a/b/cg', 'ba a\nbab', 'bb b\nbbb', 'yyy', makeCursor(1, 1));
3654
+ testSubstituteConfirm('ex_substitute_confirm_random_keys',
3655
+ '%s/a/b/cg', 'ba a\nbab', 'bb b\nbbb', 'ysdkywerty', makeCursor(1, 1));
3656
+ testSubstituteConfirm('ex_substitute_confirm_some',
3657
+ '%s/a/b/cg', 'ba a\nbab', 'bb a\nbbb', 'yny', makeCursor(1, 1));
3658
+ testSubstituteConfirm('ex_substitute_confirm_all',
3659
+ '%s/a/b/cg', 'ba a\nbab', 'bb b\nbbb', 'a', makeCursor(1, 1));
3660
+ testSubstituteConfirm('ex_substitute_confirm_accept_then_all',
3661
+ '%s/a/b/cg', 'ba a\nbab', 'bb b\nbbb', 'ya', makeCursor(1, 1));
3662
+ testSubstituteConfirm('ex_substitute_confirm_quit',
3663
+ '%s/a/b/cg', 'ba a\nbab', 'bb a\nbab', 'yq', makeCursor(0, 3));
3664
+ testSubstituteConfirm('ex_substitute_confirm_last',
3665
+ '%s/a/b/cg', 'ba a\nbab', 'bb b\nbab', 'yl', makeCursor(0, 3));
3666
+ testSubstituteConfirm('ex_substitute_confirm_oneline',
3667
+ '1s/a/b/cg', 'ba a\nbab', 'bb b\nbab', 'yl', makeCursor(0, 3));
3668
+ testSubstituteConfirm('ex_substitute_confirm_range_accept',
3669
+ '1,2s/a/b/cg', 'aa\na \na\na', 'bb\nb \na\na', 'yyy', makeCursor(1, 0));
3670
+ testSubstituteConfirm('ex_substitute_confirm_range_some',
3671
+ '1,3s/a/b/cg', 'aa\na \na\na', 'ba\nb \nb\na', 'ynyy', makeCursor(2, 0));
3672
+ testSubstituteConfirm('ex_substitute_confirm_range_all',
3673
+ '1,3s/a/b/cg', 'aa\na \na\na', 'bb\nb \nb\na', 'a', makeCursor(2, 0));
3674
+ testSubstituteConfirm('ex_substitute_confirm_range_last',
3675
+ '1,3s/a/b/cg', 'aa\na \na\na', 'bb\nb \na\na', 'yyl', makeCursor(1, 0));
3676
+ //:noh should clear highlighting of search-results but allow to resume search through n
3677
+ testVim('ex_noh_clearSearchHighlight', function(cm, vim, helpers) {
3678
+ cm.openDialog = helpers.fakeOpenDialog('match');
3679
+ helpers.doKeys('?');
3680
+ helpers.doEx('noh');
3681
+ eq(vim.searchState_.getOverlay(),null,'match-highlighting wasn\'t cleared');
3682
+ helpers.doKeys('n');
3683
+ helpers.assertCursorAt(0, 11,'can\'t resume search after clearing highlighting');
3684
+ }, { value: 'match nope match \n nope Match' });
3685
+ testVim('set_boolean', function(cm, vim, helpers) {
3686
+ CodeMirror.Vim.defineOption('testoption', true, 'boolean');
3687
+ // Test default value is set.
3688
+ is(CodeMirror.Vim.getOption('testoption'));
3689
+ try {
3690
+ // Test fail to set to non-boolean
3691
+ CodeMirror.Vim.setOption('testoption', '5');
3692
+ fail();
3693
+ } catch (expected) {};
3694
+ // Test setOption
3695
+ CodeMirror.Vim.setOption('testoption', false);
3696
+ is(!CodeMirror.Vim.getOption('testoption'));
3697
+ });
3698
+ testVim('ex_set_boolean', function(cm, vim, helpers) {
3699
+ CodeMirror.Vim.defineOption('testoption', true, 'boolean');
3700
+ // Test default value is set.
3701
+ is(CodeMirror.Vim.getOption('testoption'));
3702
+ try {
3703
+ // Test fail to set to non-boolean
3704
+ helpers.doEx('set testoption=22');
3705
+ fail();
3706
+ } catch (expected) {};
3707
+ // Test setOption
3708
+ helpers.doEx('set notestoption');
3709
+ is(!CodeMirror.Vim.getOption('testoption'));
3710
+ });
3711
+ testVim('set_string', function(cm, vim, helpers) {
3712
+ CodeMirror.Vim.defineOption('testoption', 'a', 'string');
3713
+ // Test default value is set.
3714
+ eq('a', CodeMirror.Vim.getOption('testoption'));
3715
+ try {
3716
+ // Test fail to set non-string.
3717
+ CodeMirror.Vim.setOption('testoption', true);
3718
+ fail();
3719
+ } catch (expected) {};
3720
+ try {
3721
+ // Test fail to set 'notestoption'
3722
+ CodeMirror.Vim.setOption('notestoption', 'b');
3723
+ fail();
3724
+ } catch (expected) {};
3725
+ // Test setOption
3726
+ CodeMirror.Vim.setOption('testoption', 'c');
3727
+ eq('c', CodeMirror.Vim.getOption('testoption'));
3728
+ });
3729
+ testVim('ex_set_string', function(cm, vim, helpers) {
3730
+ CodeMirror.Vim.defineOption('testoption', 'a', 'string');
3731
+ // Test default value is set.
3732
+ eq('a', CodeMirror.Vim.getOption('testoption'));
3733
+ try {
3734
+ // Test fail to set 'notestoption'
3735
+ helpers.doEx('set notestoption=b');
3736
+ fail();
3737
+ } catch (expected) {};
3738
+ // Test setOption
3739
+ helpers.doEx('set testoption=c')
3740
+ eq('c', CodeMirror.Vim.getOption('testoption'));
3741
+ });
3742
+ // TODO: Reset key maps after each test.
3743
+ testVim('ex_map_key2key', function(cm, vim, helpers) {
3744
+ helpers.doEx('map a x');
3745
+ helpers.doKeys('a');
3746
+ helpers.assertCursorAt(0, 0);
3747
+ eq('bc', cm.getValue());
3748
+ }, { value: 'abc' });
3749
+ testVim('ex_unmap_key2key', function(cm, vim, helpers) {
3750
+ helpers.doEx('unmap a');
3751
+ helpers.doKeys('a');
3752
+ eq('vim-insert', cm.getOption('keyMap'));
3753
+ }, { value: 'abc' });
3754
+ testVim('ex_unmap_key2key_does_not_remove_default', function(cm, vim, helpers) {
3755
+ try {
3756
+ helpers.doEx('unmap a');
3757
+ fail();
3758
+ } catch (expected) {}
3759
+ helpers.doKeys('a');
3760
+ eq('vim-insert', cm.getOption('keyMap'));
3761
+ }, { value: 'abc' });
3762
+ testVim('ex_map_key2key_to_colon', function(cm, vim, helpers) {
3763
+ helpers.doEx('map ; :');
3764
+ var dialogOpened = false;
3765
+ cm.openDialog = function() {
3766
+ dialogOpened = true;
3767
+ }
3768
+ helpers.doKeys(';');
3769
+ eq(dialogOpened, true);
3770
+ });
3771
+ testVim('ex_map_ex2key:', function(cm, vim, helpers) {
3772
+ helpers.doEx('map :del x');
3773
+ helpers.doEx('del');
3774
+ helpers.assertCursorAt(0, 0);
3775
+ eq('bc', cm.getValue());
3776
+ }, { value: 'abc' });
3777
+ testVim('ex_map_ex2ex', function(cm, vim, helpers) {
3778
+ helpers.doEx('map :del :w');
3779
+ var tmp = CodeMirror.commands.save;
3780
+ var written = false;
3781
+ var actualCm;
3782
+ CodeMirror.commands.save = function(cm) {
3783
+ written = true;
3784
+ actualCm = cm;
3785
+ };
3786
+ helpers.doEx('del');
3787
+ CodeMirror.commands.save = tmp;
3788
+ eq(written, true);
3789
+ eq(actualCm, cm);
3790
+ });
3791
+ testVim('ex_map_key2ex', function(cm, vim, helpers) {
3792
+ helpers.doEx('map a :w');
3793
+ var tmp = CodeMirror.commands.save;
3794
+ var written = false;
3795
+ var actualCm;
3796
+ CodeMirror.commands.save = function(cm) {
3797
+ written = true;
3798
+ actualCm = cm;
3799
+ };
3800
+ helpers.doKeys('a');
3801
+ CodeMirror.commands.save = tmp;
3802
+ eq(written, true);
3803
+ eq(actualCm, cm);
3804
+ });
3805
+ testVim('ex_map_key2key_visual_api', function(cm, vim, helpers) {
3806
+ CodeMirror.Vim.map('b', ':w', 'visual');
3807
+ var tmp = CodeMirror.commands.save;
3808
+ var written = false;
3809
+ var actualCm;
3810
+ CodeMirror.commands.save = function(cm) {
3811
+ written = true;
3812
+ actualCm = cm;
3813
+ };
3814
+ // Mapping should not work in normal mode.
3815
+ helpers.doKeys('b');
3816
+ eq(written, false);
3817
+ // Mapping should work in visual mode.
3818
+ helpers.doKeys('v', 'b');
3819
+ eq(written, true);
3820
+ eq(actualCm, cm);
3821
+
3822
+ CodeMirror.commands.save = tmp;
3823
+ });
3824
+ testVim('ex_imap', function(cm, vim, helpers) {
3825
+ CodeMirror.Vim.map('jk', '<Esc>', 'insert');
3826
+ helpers.doKeys('i');
3827
+ is(vim.insertMode);
3828
+ helpers.doKeys('j', 'k');
3829
+ is(!vim.insertMode);
3830
+ })
3831
+
3832
+ // Testing registration of functions as ex-commands and mapping to <Key>-keys
3833
+ testVim('ex_api_test', function(cm, vim, helpers) {
3834
+ var res=false;
3835
+ var val='from';
3836
+ CodeMirror.Vim.defineEx('extest','ext',function(cm,params){
3837
+ if(params.args)val=params.args[0];
3838
+ else res=true;
3839
+ });
3840
+ helpers.doEx(':ext to');
3841
+ eq(val,'to','Defining ex-command failed');
3842
+ CodeMirror.Vim.map('<C-CR><Space>',':ext');
3843
+ helpers.doKeys('<C-CR>','<Space>');
3844
+ is(res,'Mapping to key failed');
3845
+ });
3846
+ // For now, this test needs to be last because it messes up : for future tests.
3847
+ testVim('ex_map_key2key_from_colon', function(cm, vim, helpers) {
3848
+ helpers.doEx('map : x');
3849
+ helpers.doKeys(':');
3850
+ helpers.assertCursorAt(0, 0);
3851
+ eq('bc', cm.getValue());
3852
+ }, { value: 'abc' });
3853
+
3854
+ // Test event handlers
3855
+ testVim('beforeSelectionChange', function(cm, vim, helpers) {
3856
+ cm.setCursor(0, 100);
3857
+ eqPos(cm.getCursor('head'), cm.getCursor('anchor'));
3858
+ }, { value: 'abc' });
3859
+
3860
+
3861
+ });
3862
+
3863
+
3864
+ if (typeof module !== "undefined" && module === require.main) {
3865
+ require("asyncjs").test.testcase(module.exports).exec();
3866
+ }