From nobody at rubyforge.org Sun Feb 14 07:28:24 2010 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sun, 14 Feb 2010 07:28:24 -0500 (EST) Subject: [Muby-submits] [286] trunk/lib/muby: better completer Message-ID: <20100214122824.7CF9D18582E1@rubyforge.org> Revision: 286 Author: zond Date: 2010-02-14 07:28:24 -0500 (Sun, 14 Feb 2010) Log Message: ----------- better completer Modified Paths: -------------- trunk/lib/muby/configuration.rb trunk/lib/muby/user_methods.rb Modified: trunk/lib/muby/configuration.rb =================================================================== --- trunk/lib/muby/configuration.rb 2010-01-26 14:31:34 UTC (rev 285) +++ trunk/lib/muby/configuration.rb 2010-02-14 12:28:24 UTC (rev 286) @@ -4,7 +4,7 @@ module Muby - VERSION = "0.7.15" unless defined?(Muby::VERSION) + VERSION = "0.7.16" unless defined?(Muby::VERSION) # # The class that encapsulates all configuration. Modified: trunk/lib/muby/user_methods.rb =================================================================== --- trunk/lib/muby/user_methods.rb 2010-01-26 14:31:34 UTC (rev 285) +++ trunk/lib/muby/user_methods.rb 2010-02-14 12:28:24 UTC (rev 286) @@ -260,8 +260,18 @@ Muby::InputWindow.get_instance.reload! end + def least_common(ary) + rval = ary.first + ary.each do |s| + while s.index(rval) == nil + rval = rval[0...-1] + end + end + rval + end + def complete! - unless @handle_mode == :history_search! + if @handle_mode != :history_search! && @buffer.to_s != "" last_word = @buffer.match(/(\w*)$/)[1] completions = Muby::Completer.get_instance.complete(last_word) if completions.size == 1 @@ -269,6 +279,8 @@ @cursorPosition = @buffer.size update else + @buffer.gsub!(last_word, least_common(completions)) + @cursorPosition = @buffer.size info(completions.inspect) end end