From 51ef581bde5a98050db31343f7ef8c9d85136b22 Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 21 Jan 2018 19:52:37 -0700 Subject: vim files added --- .../vim-multiple-cursors/spec/benchmark_spec.rb | 142 ++++ .../spec/multiple_cursors_spec.rb | 817 +++++++++++++++++++++ .../vim-multiple-cursors/spec/spec_helper.rb | 25 + 3 files changed, 984 insertions(+) create mode 100644 .vim/bundle/vim-multiple-cursors/spec/benchmark_spec.rb create mode 100644 .vim/bundle/vim-multiple-cursors/spec/multiple_cursors_spec.rb create mode 100644 .vim/bundle/vim-multiple-cursors/spec/spec_helper.rb (limited to '.vim/bundle/vim-multiple-cursors/spec') diff --git a/.vim/bundle/vim-multiple-cursors/spec/benchmark_spec.rb b/.vim/bundle/vim-multiple-cursors/spec/benchmark_spec.rb new file mode 100644 index 0000000..73c81c5 --- /dev/null +++ b/.vim/bundle/vim-multiple-cursors/spec/benchmark_spec.rb @@ -0,0 +1,142 @@ +require 'vimrunner' +require 'vimrunner/rspec' + +Vimrunner::RSpec.configure do |config| + + # Use a single Vim instance for the test suite. Set to false to use an + # instance per test (slower, but can be easier to manage). + config.reuse_server = false + + # Decide how to start a Vim instance. In this block, an instance should be + # spawned and set up with anything project-specific. + config.start_vim do + # vim = Vimrunner.start + # vim = Vimrunner::Server.new("/usr/local/bin/vim").start + + # Or, start a GUI instance: + vim = Vimrunner.start_gvim + + # Setup your plugin in the Vim instance + plugin_path = File.expand_path('../..', __FILE__) + vim.add_plugin(plugin_path, 'plugin/multiple_cursors.vim') + + # The returned value is the Client available in the tests. + vim + end +end + +def set_file_content(string) + string = normalize_string_indent(string) + File.open(filename, 'w'){ |f| f.write(string) } + vim.edit filename +end + +def get_file_content() + vim.write + IO.read(filename).strip +end + +def before(string) + set_file_content(string) +end + +def after(string) + get_file_content().should eq normalize_string_indent(string) + type ":q" +end + +def type(string) + string.scan(/<.*?>|./).each do |key| + if /<.*>/.match(key) + vim.feedkeys "\\#{key}" + else + vim.feedkeys key + end + end + sleep 0.2 +end + +describe "Multiple Cursors" do + let(:filename) { 'test.txt' } + let(:options) { [] } + + specify "#benchmark" do + before <<-EOF + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + hello + EOF + + # type ':profile start /tmp/test.result' + # type ':profile! file *multiple_cursors.vim' + type ':let g:multi_cursor_debug_latency=1' + + type 'VGVchellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello' + + type ':echo multiple_cursors#get_latency_debug_file()' + sleep 3 + latency_file = vim.command 'echo multiple_cursors#get_latency_debug_file()' + puts 'latency file = ' + latency_file + + after <<-EOF + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello + EOF + end + +end diff --git a/.vim/bundle/vim-multiple-cursors/spec/multiple_cursors_spec.rb b/.vim/bundle/vim-multiple-cursors/spec/multiple_cursors_spec.rb new file mode 100644 index 0000000..2d92e5a --- /dev/null +++ b/.vim/bundle/vim-multiple-cursors/spec/multiple_cursors_spec.rb @@ -0,0 +1,817 @@ +# -*- encoding: utf-8 -*- +require 'spec_helper' + +def set_file_content(string) + string = normalize_string_indent(string) + File.open(filename, 'w'){ |f| f.write(string) } + vim.edit filename +end + +def get_file_content() + vim.write + IO.read(filename).strip +end + +def before(string) + options.each { |x| vim.command(x) } + set_file_content(string) +end + +def after(string) + expect(get_file_content()).to eq normalize_string_indent(string) +end + +def type(string) + string.scan(/<.*?>|./).each do |key| + if /<.*>/.match(key) + vim.feedkeys "\\#{key}" + else + vim.feedkeys key + end + end +end + +describe "Multiple Cursors op pending & exit from insert|visual mode" do + let(:filename) { 'test.txt' } + let(:options) { ['let g:multi_cursor_exit_from_insert_mode = 0', + 'let g:multi_cursor_exit_from_visual_mode = 0'] } + # the default value of g:multi_cursor_normal_maps already works + # for testing operator-pending + + specify "#paste from unnamed register to 3 cursors" do + before <<-EOF + yankme + a b c + a b c + a b c + EOF + + type 'yiwjvwwp' + + after <<-EOF + yankme + a b cyankme + a b cyankme + a b cyankme + EOF + end + + specify "#paste buffer normal caw then p" do + before <<-EOF + hello jan world + hello feb world + hello mar world + EOF + + type 'vwcawbP' + + after <<-EOF + jan hello world + feb hello world + mar hello world + EOF + end + + specify "#paste buffer normal C then ABC then p" do + before <<-EOF + hello jan world + hello feb world + hello mar world + EOF + + type 'vwCABC p' + + after <<-EOF + hello ABC jan world + hello ABC feb world + hello ABC mar world + EOF + end + + specify "#paste buffer normal daw then P" do + before <<-EOF + hello jan world + hello feb world + hello mar world + EOF + + type 'vwdawbP' + + after <<-EOF + jan hello world + feb hello world + mar hello world + EOF + end + + specify "#paste buffer normal D then P" do + before <<-EOF + hello jan world + hello feb world + hello mar world + EOF + + type 'vwwhDbhP' + + after <<-EOF + hello world jan + hello world feb + hello world mar + EOF + end + + specify "#paste buffer normal s then p" do + before <<-EOF + hello jan world + hello feb world + hello mar world + EOF + + type 'vws1p' + + after <<-EOF + hello 1jan world + hello 1feb world + hello 1mar world + EOF + end + +end + +describe "Multiple Cursors when normal_maps is empty" do + let(:filename) { 'test.txt' } + let(:options) { ['let g:multi_cursor_normal_maps = {}'] } + + # Operator-pending commands are handled correctly thanks to their inclusion + # in `g:multi_cursor_normal_maps`. + # + # When an operator-pending command like 'd' is missing from that setting's + # value, then it should result in a no-op, but we should still remain in + # multicursor mode. + specify "#normal mode 'd'" do + before <<-EOF + hello + hello + EOF + + type 'vdx' + + after <<-EOF + hell + hell + EOF + end + +end + +describe "Multiple Cursors when visual_maps is empty" do + let(:filename) { 'test.txt' } + let(:options) { ['let g:multi_cursor_visual_maps = {}'] } + + # Operator-pending commands are handled correctly thanks to their inclusion + # in `g:multi_cursor_visual_maps`. + # + # When an operator-pending command like 'f' is missing from that setting's + # value, then it should result in a no-op, but we should still remain in + # multicursor mode. + specify "#visual mode 'i'" do + before <<-EOF + hello world x + hello world x + EOF + + type 'fwfx' + + after <<-EOF + hello x + hello x + EOF + end + +end + +describe "Multiple Cursors" do + let(:filename) { 'test.txt' } + let(:options) { ['set autoindent'] } + + specify "#paste buffer normal x then p" do + before <<-EOF + jan + feb + mar + EOF + + type 'jjxp' + + after <<-EOF + ajn + efb + amr + EOF + end + + specify "#paste buffer visual y then p" do + before <<-EOF + hello jan world + hello feb world + hello mar world + EOF + + type 'vwvelywhp' + + after <<-EOF + hello jan jan world + hello feb feb world + hello mar mar world + EOF + end + + specify "#paste buffer initial visual y then P" do + before <<-EOF + hello jan world + hello feb world + hello mar world + EOF + + type 'wywbp' + + after <<-EOF + jan jan world + jan feb world + jan mar world + EOF + end + + specify "#paste buffer visual y then P" do + before <<-EOF + hello jan world + hello feb world + hello mar world + EOF + + type 'vwvely^P' + + after <<-EOF + jan hello jan world + feb hello feb world + mar hello mar world + EOF + end + + specify "#paste buffer visual Y then P" do + before <<-EOF + hello jan world + hello feb world + hello mar world + EOF + + type 'vwvY^P' + + after <<-EOF + hello jan world + hello jan world + hello feb world + hello feb world + hello mar world + hello mar world + EOF + end + + specify "#multiline replacement" do + before <<-EOF + hello + hello + hello + EOF + + type 'cworld' + + after <<-EOF + world + world + world + EOF + end + + specify "#single line replacement" do + before <<-EOF + hello hello hello + EOF + + type 'cworld' + + after <<-EOF + world world world + EOF + end + + specify "#mixed line replacement" do + before <<-EOF + hello hello + hello + EOF + + type 'cworld' + + after <<-EOF + world world + world + EOF + end + + specify "#new line in insert mode" do + before <<-EOF + hello + hello + EOF + + type 'chelloworld' + + after <<-EOF + hello + world + hello + world + EOF + end + + specify "#new line in insert mode middle of line" do + before <<-EOF + hello world + hello world + EOF + + type 'vlxi' + + after <<-EOF + hello + world + hello + world + EOF + end + + specify "#multiple new lines on one line in insert mode" do + before <<-EOF + 'a','b','c','d','e' + EOF + + type 'f,vc' + + after <<-EOF + 'a' + 'b' + 'c' + 'd' + 'e' + EOF + end + + specify "#multiple new lines on one line in insert mode with indents" do + before <<-EOF + 'a','b','c','d','e' + EOF + + type '4if,vc:%s/^/^' + + after <<-EOF + ^ 'a' + ^ 'b' + ^ 'c' + ^ 'd' + ^ 'e' + EOF + end + + specify "#normal mode 'o'" do + before <<-EOF + hello + hello + EOF + + type 'voworld' + + after <<-EOF + hello + world + hello + world + EOF + end + + specify "#normal mode 'O'" do + before <<-EOF + hello + hello + EOF + + type 'vOworld' + + after <<-EOF + world + hello + world + hello + EOF + end + + specify "#find command basic" do + before <<-EOF + hello + hello + EOF + + vim.normal ':MultipleCursorsFind hello' + type 'cworld' + + after <<-EOF + world + world + EOF + end + + specify "#find command start-of-line" do + before <<-EOF + hello + world + + hello + world + EOF + + vim.normal ':MultipleCursorsFind ^' + type 'Ibegin' + + after <<-EOF + beginhello + beginworld + begin + beginhello + beginworld + EOF + end + + specify "#find command end-of-line" do + before <<-EOF + hello + world + + hello + world + EOF + + vim.normal ':MultipleCursorsFind $' + type 'Iend' + + after <<-EOF + helloend + worldend + end + helloend + worldend + EOF + end + + specify "#visual line mode replacement" do + before <<-EOF + hello world + hello world + EOF + + type 'Vchi!' + + after <<-EOF + hi! + hi! + EOF + end + + specify "#skip key" do + before <<-EOF + hello + hello + hello + EOF + + type 'cworld' + + after <<-EOF + world + hello + world + EOF + end + + specify "#prev key" do + before <<-EOF + hello + hello + hello + EOF + + type 'cworld' + + after <<-EOF + world + world + hello + EOF + end + + specify "#visual mode 'i'" do + before <<-EOF + hi (hello world jan) bye + hi (hello world feb) bye + hi (hello world mar) bye + EOF + + type 'fwibcone' + + after <<-EOF + hi (one) bye + hi (one) bye + hi (one) bye + EOF + end + + specify "#visual mode 'a'" do + before <<-EOF + hi (hello world jan) bye + hi (hello world feb) bye + hi (hello world mar) bye + EOF + + type 'fwabcone' + + after <<-EOF + hi one bye + hi one bye + hi one bye + EOF + end + + specify "#visual mode 'f'" do + before <<-EOF + hi (hello world jan) bye + hi (hello world feb) bye + hi (hello world mar) bye + EOF + + type 'fwf)cone' + + after <<-EOF + hi (hello one bye + hi (hello one bye + hi (hello one bye + EOF + end + + specify "#visual mode 'F'" do + before <<-EOF + hi (hello world jan) bye + hi (hello world feb) bye + hi (hello world mar) bye + EOF + + type 'fwF(cbefore' + + after <<-EOF + hi beforeorld jan) bye + hi beforeorld feb) bye + hi beforeorld mar) bye + EOF + end + + specify "#visual mode 't'" do + before <<-EOF + hello.jan + hello hi.feb + hello hi bye.mar + EOF + + type 't.cone' + + after <<-EOF + one.jan + one.feb + one.mar + EOF + end + + specify "#visual mode 'T'" do + before <<-EOF + jan.world + feb.hi world + mar.bye hi world + EOF + + type 'fwT.cbefore' + + after <<-EOF + jan.beforeorld + feb.beforeorld + mar.beforeorld + EOF + end + + specify "#visual line mode 'f'" do + before <<-EOF + hello jan world + hello feb world + hello mar world + EOF + + type 'VfwvAafter' + + after <<-EOF + hello jan wafterorld + hello feb wafterorld + hello mar wafterorld + EOF + end + + specify "#visual mode 'I'" do + before <<-EOF + hello world jan + hello world feb + hello world mar + EOF + + type 'wIbefore' + + after <<-EOF + hello beforeworld jan + hello beforeworld feb + hello beforeworld mar + EOF + end + + specify "#visual mode 'A'" do + before <<-EOF + hello world jan + hello world feb + hello world mar + EOF + + type 'wAafter' + + after <<-EOF + hello worldafter jan + hello worldafter feb + hello worldafter mar + EOF + end + + specify "#resize regions visual mode 'I'" do + before <<-EOF + hello world jan + hello world feb + hello world mar + EOF + + type 'whhhIbefore' + + after <<-EOF + hello beforeworld jan + hello beforeworld feb + hello beforeworld mar + EOF + end + + specify "#resize regions visual mode 'A'" do + before <<-EOF + hello world jan + hello world feb + hello world mar + EOF + + type 'whhhAbefore' + + after <<-EOF + hello wobeforerld jan + hello wobeforerld feb + hello wobeforerld mar + EOF + end + + specify "#no word boundries visual mode 'I'" do + before <<-EOF + hello hibye world + hello hibye world + hello hibye world + EOF + + vim.normal ':MultipleCursorsFind bye' + type 'Ibefore' + + after <<-EOF + hello hibeforebye world + hello hibeforebye world + hello hibeforebye world + EOF + end + + specify "#variable-length regions visual mode 'I'" do + before <<-EOF + hello hii world + hello hiiii world + hello hiiiiii world + EOF + + vim.normal ':MultipleCursorsFind \' + type 'Ibefore' + + after <<-EOF + hello beforehii world + hello beforehiiii world + hello beforehiiiiii world + EOF + end + + specify "#normal mode 'I'" do + before <<-EOF + hello + hello + EOF + + type 'vIworld ' + + after <<-EOF + world hello + world hello + EOF + end + + specify "#normal mode 'A'" do + before <<-EOF + hello + hello + EOF + + type 'vA world' + + after <<-EOF + hello world + hello world + EOF + end + + specify "#undo" do + before <<-EOF + hello + hello + EOF + + type 'cworldu' + + after <<-EOF + hello + hello + EOF + end + + specify "#multiline visual mode" do + before <<-EOF + hello + hello + EOF + + type 'VjA world' + + after <<-EOF + hello world + hello world + EOF + end + + specify "#set paste mode" do + before <<-EOF + hello + hello + EOF + + type ':set pastecworld:set nopaste' + + after <<-EOF + world + world + EOF + end + + specify "#multi-byte strings" do + before <<-EOF + こんにちわビム + 世界の中心でビムを叫ぶ + ビム大好き + EOF + + type '/ビムcヴィム' + + after <<-EOF + こんにちわヴィム + 世界の中心でヴィムを叫ぶ + ヴィム大好き + EOF + end + +end diff --git a/.vim/bundle/vim-multiple-cursors/spec/spec_helper.rb b/.vim/bundle/vim-multiple-cursors/spec/spec_helper.rb new file mode 100644 index 0000000..4e0ad99 --- /dev/null +++ b/.vim/bundle/vim-multiple-cursors/spec/spec_helper.rb @@ -0,0 +1,25 @@ +require 'vimrunner' +require 'vimrunner/rspec' + +Vimrunner::RSpec.configure do |config| + + # Use a single Vim instance for the test suite. Set to false to use an + # instance per test (slower, but can be easier to manage). + config.reuse_server = false + + # Decide how to start a Vim instance. In this block, an instance should be + # spawned and set up with anything project-specific. + config.start_vim do + # vim = Vimrunner.start + + # Or, start a GUI instance: + vim = Vimrunner.start_gvim + + # Setup your plugin in the Vim instance + plugin_path = File.expand_path('../..', __FILE__) + vim.add_plugin(plugin_path, 'plugin/multiple_cursors.vim') + + # The returned value is the Client available in the tests. + vim + end +end -- cgit v1.3.1