1
0
mirror of https://github.com/amix/vimrc synced 2025-06-23 06:35:01 +08:00

Updated plugins

This commit is contained in:
amix
2013-05-04 16:32:47 -04:00
parent 687184f0bb
commit 630b462208
16 changed files with 287 additions and 147 deletions

View File

@ -1,3 +1,11 @@
## 2.1 (04/26/2013)
Bugfixes:
- Fix 1 regression where cursors could potentially get out of sync in insert mode
Features:
- Added some logic to debug latency. Fanning out to 30 cursors in insert mode with my vimrc took over 300ms. It's like than 20ms with a plain vimrc. Need to debug what setting is causing the slowing down in insert mode and inform users.
## 2.0 (04/24/2013)
Bugfixes:

View File

@ -87,8 +87,8 @@ highlight link multiple_cursors_visual Visual
## Issues
- Multi key commands like `ciw` do not work at the moment
- Insert mode can be slow. If you are using Neobundle and have many plugins, try switching to Vundle to see if it helps. See https://github.com/Shougo/neobundle.vim/issues/84 for additional info.
- All user input typed before Vim is able to fan out the last operation to all cursors is lost. This is a implementation decision to keep the input perfectly synced in all locations, at the cost of potentially losing user input.
- Performance in terminal vim degrades significantly with more cursors
- Select mode is not implemented
## Changelog

View File

@ -1,5 +1,11 @@
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'spec/multiple_cursors_spec.rb'
end
RSpec::Core::RakeTask.new(:benchmark) do |t|
t.pattern = 'spec/benchmark_spec.rb'
end
task :default => :spec

View File

@ -82,6 +82,10 @@ function! multiple_cursors#debug()
call s:cm.debug()
endfunction
function! multiple_cursors#get_latency_debug_file()
return s:latency_debug_file
endfunction
" Creates a new cursor. Different logic applies depending on the mode the user
" is in and the current state of the buffer.
" 1. In normal mode, a new cursor is created at the end of the word under Vim's
@ -352,6 +356,7 @@ function! s:CursorManager.reset(restore_view) dict
let self.starting_index = -1
let self.saved_winview = []
let self.start_from_find = 0
let s:char = ''
call self.restore_user_settings()
endfunction
@ -425,7 +430,7 @@ function! s:CursorManager.update_current() dict
" Sets the cursor at the right place
exec "normal! gv\<Esc>"
call cur.update_visual_selection(s:get_visual_region(s:pos('.')))
else
elseif s:from_mode ==# 'v' || s:from_mode ==# 'V'
call cur.remove_visual_selection()
endif
let vdelta = line('$') - s:saved_linecount
@ -714,9 +719,6 @@ function! s:revert_mode(from, to)
call s:cm.reapply_visual_selection()
normal! V
endif
if a:to ==# 'i'
startinsert
endif
if a:to ==# 'n' && a:from ==# 'i'
stopinsert
endif
@ -768,9 +770,9 @@ function! s:process_user_inut()
" FIXME(terryma): Undo always places the cursor at the beginning of the line.
" Figure out why.
if s:from_mode ==# 'i' || s:to_mode ==# 'i'
silent! undojoin | call feedkeys(s:char."\<Plug>(a)")
silent! undojoin | call s:feedkeys(s:char."\<Plug>(a)")
else
call feedkeys(s:char."\<Plug>(a)")
call s:feedkeys(s:char."\<Plug>(a)")
endif
" Even when s:char produces invalid input, this method is always called. The
@ -809,9 +811,6 @@ function! s:apply_user_input_next(mode)
" Advance the cursor index
call s:cm.next()
" Update Vim's cursor
call cursor(s:cm.get_current().position)
" We're done if we're made the full round
if s:cm.loop_done()
if s:to_mode ==# 'v' || s:to_mode ==# 'V'
@ -941,6 +940,37 @@ function! s:display_error()
let s:bad_input = 0
endfunction
let s:latency_debug_file = ''
function! s:start_latency_measure()
if g:multi_cursor_debug_latency
let s:start_time = reltime()
endif
endfunction
function! s:skip_latency_measure()
if g:multi_cursor_debug_latency
let s:skip_latency_measure = 1
endif
endfunction
function! s:end_latency_measure()
if g:multi_cursor_debug_latency && !empty(s:char)
if empty(s:latency_debug_file)
let s:latency_debug_file = tempname()
exec 'redir >> '.s:latency_debug_file
silent! echom "Starting latency debug at ".reltimestr(reltime())
redir END
endif
if !s:skip_latency_measure
exec 'redir >> '.s:latency_debug_file
silent! echom "Processing '".s:char."' took ".string(str2float(reltimestr(reltime(s:start_time)))*1000).' ms in '.s:cm.size().' cursors. mode = '.s:from_mode
redir END
endif
endif
let s:skip_latency_measure = 0
endfunction
function! s:wait_for_user_input(mode)
let s:from_mode = a:mode
if empty(a:mode)
@ -958,8 +988,12 @@ function! s:wait_for_user_input(mode)
" Immediately revert the change to leave the user's buffer unchanged
call s:revert_highlight_fix()
call s:end_latency_measure()
let s:char = s:get_char()
call s:start_latency_measure()
" Clears any echoes we might've added
normal! :<Esc>
@ -970,6 +1004,7 @@ function! s:wait_for_user_input(mode)
" If the key is a special key and we're in the right mode, handle it
if index(get(s:special_keys, s:from_mode, []), s:char) != -1
call s:handle_special_key(s:char, s:from_mode)
call s:skip_latency_measure()
else
call s:cm.start_loop()
call s:feedkeys("\<Plug>(i)")

View File

@ -1,21 +0,0 @@
MultipleCursorsFind multiple_cursors.txt /*MultipleCursorsFind*
g:multi_cursor_exit_from_insert_mode multiple_cursors.txt /*g:multi_cursor_exit_from_insert_mode*
g:multi_cursor_exit_from_visual_mode multiple_cursors.txt /*g:multi_cursor_exit_from_visual_mode*
g:multi_cursor_next_key multiple_cursors.txt /*g:multi_cursor_next_key*
g:multi_cursor_prev_key multiple_cursors.txt /*g:multi_cursor_prev_key*
g:multi_cursor_quit_key multiple_cursors.txt /*g:multi_cursor_quit_key*
g:multi_cursor_skip_key multiple_cursors.txt /*g:multi_cursor_skip_key*
g:multi_cursor_start_key multiple_cursors.txt /*g:multi_cursor_start_key*
g:multi_cursor_use_default_mapping multiple_cursors.txt /*g:multi_cursor_use_default_mapping*
multiple-cursors-contents multiple_cursors.txt /*multiple-cursors-contents*
multiple-cursors-contributing multiple_cursors.txt /*multiple-cursors-contributing*
multiple-cursors-credit multiple_cursors.txt /*multiple-cursors-credit*
multiple-cursors-global-options multiple_cursors.txt /*multiple-cursors-global-options*
multiple-cursors-intro multiple_cursors.txt /*multiple-cursors-intro*
multiple-cursors-issues multiple_cursors.txt /*multiple-cursors-issues*
multiple-cursors-license multiple_cursors.txt /*multiple-cursors-license*
multiple-cursors-mappings multiple_cursors.txt /*multiple-cursors-mappings*
multiple-cursors-references multiple_cursors.txt /*multiple-cursors-references*
multiple-cursors-usage multiple_cursors.txt /*multiple-cursors-usage*
vim-multiple-cursors multiple_cursors.txt /*vim-multiple-cursors*
vim-multiple-cursors.txt multiple_cursors.txt /*vim-multiple-cursors.txt*

View File

@ -30,6 +30,7 @@ let s:settings = {
\ 'exit_from_visual_mode': 1,
\ 'exit_from_insert_mode': 1,
\ 'use_default_mapping': 1,
\ 'debug_latency': 0,
\ }
let s:settings_if_default = {

View File

@ -0,0 +1,141 @@
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<CR>"
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' }
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<CR>'
# type ':profile! file *multiple_cursors.vim<CR>'
type ':let g:multi_cursor_debug_latency=1<CR>'
type 'VG<C-n>Vchellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello<Esc>'
type ':echo multiple_cursors#get_latency_debug_file()<CR>'
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

View File

@ -256,4 +256,18 @@ describe "Multiple Cursors" do
hell
EOF
end
specify "#multiline visual mode" do
before <<-EOF
hello
hello
EOF
type 'Vj<C-n>A world<Esc>'
after <<-EOF
hello world
hello world
EOF
end
end