Skip to content

Commit

Permalink
Reverting lazy-initialization code, pending investigation
Browse files Browse the repository at this point in the history
This commit rolls back the recently-added lazy-initialization code due
to a report of a segfault; due to the fact that a lot of people use
Pathogen or similar to track the HEAD of master, I'd rather be
conservative about this and roll it back immediately, and then
investigate. The lazy-initialization code itself has been moved onto a
topic branch (lazy-initialization).

The bug report:

  https://wincent.com/issues/1837

Signed-off-by: Wincent Colaiuta <win@wincent.com>
  • Loading branch information
wincent committed Jun 30, 2011
1 parent 6f0641b commit 3c0dc0a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 39 deletions.
1 change: 0 additions & 1 deletion .mailmap
@@ -1,2 +1 @@
Kien Nguyen Duc <contact@ndkien.com>
Sung Pae <sung@metablu.com> Sung Pae <sung@metablu.com>
6 changes: 0 additions & 6 deletions doc/command-t.txt
Expand Up @@ -566,7 +566,6 @@ Other contributors that have submitted patches include (in alphabetical
order): order):


Daniel Hahler Daniel Hahler
Kien Nguyen Duc
Lucas de Vries Lucas de Vries
Matthew Todd Matthew Todd
Mike Lundy Mike Lundy
Expand Down Expand Up @@ -651,11 +650,6 @@ POSSIBILITY OF SUCH DAMAGE.


HISTORY *command-t-history* HISTORY *command-t-history*


1.2.2 (not yet released)

- perform Ruby initialization lazily on first use, minimizing impact on Vim
startup time (patch from Kien Nguyen Duc)

1.2.1 (30 April 2011) 1.2.1 (30 April 2011)


- Remove duplicate copy of the documentation that was causing "Duplicate tag" - Remove duplicate copy of the documentation that was causing "Duplicate tag"
Expand Down
60 changes: 28 additions & 32 deletions plugin/command-t.vim
Expand Up @@ -48,7 +48,6 @@ endfunction


function s:CommandTShowBufferFinder() function s:CommandTShowBufferFinder()
if has('ruby') if has('ruby')
call s:CommandTLazyInitialize()
ruby $command_t.show_buffer_finder ruby $command_t.show_buffer_finder
else else
call s:CommandTRubyWarning() call s:CommandTRubyWarning()
Expand All @@ -57,7 +56,6 @@ endfunction


function s:CommandTShowFileFinder(arg) function s:CommandTShowFileFinder(arg)
if has('ruby') if has('ruby')
call s:CommandTLazyInitialize()
ruby $command_t.show_file_finder ruby $command_t.show_file_finder
else else
call s:CommandTRubyWarning() call s:CommandTRubyWarning()
Expand All @@ -66,42 +64,15 @@ endfunction


function s:CommandTFlush() function s:CommandTFlush()
if has('ruby') if has('ruby')
call s:CommandTLazyInitialize()
ruby $command_t.flush ruby $command_t.flush
else else
call s:CommandTRubyWarning() call s:CommandTRubyWarning()
endif endif
endfunction endfunction


function s:CommandTLazyInitialize() if !has('ruby')
if !exists("g:command_t_initialized") finish
let g:command_t_initialized = 1 endif
ruby << EOF
# require Ruby files
begin
# prepare controller
require 'command-t/vim'
require 'command-t/controller'
$command_t = CommandT::Controller.new
rescue LoadError
load_path_modified = false
::VIM::evaluate('&runtimepath').to_s.split(',').each do |path|
lib = "#{path}/ruby"
if !$LOAD_PATH.include?(lib) and File.exist?(lib)
$LOAD_PATH << lib
load_path_modified = true
end
end
retry if load_path_modified

# could get here if C extension was not compiled, or was compiled
# for the wrong architecture or Ruby version
require 'command-t/stub'
$command_t = CommandT::Stub.new
end
EOF
endif
endfunction


function CommandTHandleKey(arg) function CommandTHandleKey(arg)
ruby $command_t.handle_key ruby $command_t.handle_key
Expand Down Expand Up @@ -166,3 +137,28 @@ endfunction
function CommandTCursorStart() function CommandTCursorStart()
ruby $command_t.cursor_start ruby $command_t.cursor_start
endfunction endfunction

ruby << EOF
# require Ruby files
begin
# prepare controller
require 'command-t/vim'
require 'command-t/controller'
$command_t = CommandT::Controller.new
rescue LoadError
load_path_modified = false
::VIM::evaluate('&runtimepath').to_s.split(',').each do |path|
lib = "#{path}/ruby"
if !$LOAD_PATH.include?(lib) and File.exist?(lib)
$LOAD_PATH << lib
load_path_modified = true
end
end
retry if load_path_modified

# could get here if C extension was not compiled, or was compiled
# for the wrong architecture or Ruby version
require 'command-t/stub'
$command_t = CommandT::Stub.new
end
EOF

0 comments on commit 3c0dc0a

Please sign in to comment.