From: wmorgan Date: Wed, 25 Jul 2007 04:51:39 +0000 (+0000) Subject: divorce completion code from filenames X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=62d0972afe52c249f04c1ed9c47a00d7fa6168cc;p=sup divorce completion code from filenames git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@508 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb index b4b7ef7..dc3b44e 100644 --- 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 "", mode, :height => 10 draw_screen :skip_minibuf => true