]> git.cworth.org Git - sup/commitdiff
divorce completion code from filenames
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Wed, 25 Jul 2007 04:51:39 +0000 (04:51 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Wed, 25 Jul 2007 04:51:39 +0000 (04:51 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@508 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/buffer.rb

index b4b7ef785dce68e33b1a983650a1e5eeb6435df1..dc3b44e6e385cfe1bf7709c347542d53a95c402e 100644 (file)
@@ -393,20 +393,16 @@ class BufferManager
 
     while true
       c = Ncurses.nonblocking_getch
-      next unless c  # getch timeout
+      next unless c # getch timeout
       break unless tf.handle_input c # process keystroke
 
       if tf.new_completions?
         kill_buffer completion_buf if completion_buf
         
-        prefix_len =
-          if tf.value =~ /\/$/
-            0
-          else
-            File.basename(tf.value).length
-          end
+        shorts = tf.completions.map { |full, short| short }
+        prefix_len = shorts.shared_prefix.length
 
-        mode = CompletionMode.new tf.completions.map { |full, short| short }, :header => "Possible completions for \"#{tf.value}\": ", :prefix_len => prefix_len
+        mode = CompletionMode.new shorts, :header => "Possible completions for \"#{tf.value}\": ", :prefix_len => prefix_len
         completion_buf = spawn "<completions>", mode, :height => 10
 
         draw_screen :skip_minibuf => true