Skip to content

Commit

Permalink
Merge pull request #100 from todesking/fix-global-arg-completion
Browse files Browse the repository at this point in the history
Fix completion error about global variables
  • Loading branch information
segfault committed Aug 11, 2012
2 parents 547bea7 + a373648 commit 46c9e4e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions autoload/rubycomplete.vim
Expand Up @@ -364,6 +364,10 @@ class VimRubyCompletion
print txt if @@debug
end

def escape_vim_singlequote_string(str)
str.gsub(/'/,"\\'")
end

def get_buffer_entity_list( type )
# this will be a little expensive.
loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading")
Expand Down Expand Up @@ -526,9 +530,9 @@ class VimRubyCompletion
end

def clean_sel(sel, msg)
sel.delete_if { |x| x == nil }
sel.uniq!
sel.grep(/^#{Regexp.quote(msg)}/) if msg != nil
ret = sel.reject{|x|x.nil?}.uniq
ret = ret.grep(/^#{Regexp.quote(msg)}/) if msg != nil
ret
end

def get_rails_view_methods
Expand Down Expand Up @@ -779,7 +783,7 @@ class VimRubyCompletion
rg.step(150) do |x|
stpos = 0+x
enpos = 150+x
valid[stpos..enpos].each { |c| outp += "{'word':'%s','item':'%s','kind':'%s'}," % [ c[:name], c[:name], c[:type] ] }
valid[stpos..enpos].each { |c| outp += "{'word':'%s','item':'%s','kind':'%s'}," % [ c[:name], c[:name], c[:type] ].map{|x|escape_vim_singlequote_string(x)} }
outp.sub!(/,$/, '')

VIM::command("call extend(g:rubycomplete_completions, [%s])" % outp)
Expand Down

0 comments on commit 46c9e4e

Please sign in to comment.