sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 62d0972afe52c249f04c1ed9c47a00d7fa6168cc
parent 01609d744a2dceb52915c57c5bbf4fca5a410970
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date:   Wed, 25 Jul 2007 04:51:39 +0000

divorce completion code from filenames

git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@508 5c8cc53c-5e98-4d25-b20a-d8db53a31250

Diffstat:
M lib/sup/buffer.rb | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
@@ -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