lib/ver/methods/completion.rb in ver-2010.02 vs lib/ver/methods/completion.rb in ver-2010.08
- old
+ new
@@ -36,12 +36,12 @@
end
def aspell(text)
text.store(self, :last_used, :aspell)
- pos = text.index('insert - 1 chars')
- from, to = pos.wordstart, pos.wordend
+ from = text.index('insert - 1 chars wordstart')
+ to = text.index('insert - 1 chars wordend')
word = text.get(from, to)
complete text do
[from, to, aspell_completions(text, word)]
end
@@ -83,11 +83,11 @@
end
def word(text)
text.store(self, :last_used, :word)
- y, x = text.index('insert').split
+ y, x = *text.index('insert')
x = (x - 1).abs
from, to = text.index("#{y}.#{x} wordstart"), text.index("#{y}.#{x} wordend")
words = word_completions(text, from, to)
@@ -138,11 +138,11 @@
text.search_all(/^.*#{needle}.*$/).map{|match, *_| match }.uniq
end
# TODO: use filename_under_cursor, that should be much more accurate.
def file_completions(text, from, to)
- y = text.index(from).y
+ lineno = text.index(from).line
line = text.get(from, to)
return [] unless match = line.match(/(?<pre>.*?)(?<path>\/[^\s"'{}()\[\]]*)(?<post>.*?)/)
from, to = match.offset(:path)
path = match[:path]
@@ -154,10 +154,10 @@
list.map! do |item|
item << '/' if File.directory?(item)
item.sub(path, '/')
end
- return "#{y}.#{to - 1}", "#{y}.#{to}", list
+ return "#{lineno}.#{to - 1}", "#{lineno}.#{to}", list
end
def word_completions(text, from, to)
prefix = text.get(from, to).strip
return [] if prefix.empty?