Skip to content

Commit

Permalink
files search handles full paths
Browse files Browse the repository at this point in the history
  • Loading branch information
cldwalker committed May 1, 2010
1 parent c58019c commit 4681b37
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/bond/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def incremental_filter(input, list, delim)
i = 0; input.gsub(delim) {|e| i+= 1 }
delim_chars = delim.split('').uniq.join('')
current_matches, future_matches = underscore_search(input, list).partition {|e|
e[/^[^#{delim_chars}]+(#{delim}[^#{delim_chars}]+){0,#{i}}$/] }
(current_matches + future_matches.map {|e| e[/^(([^#{delim_chars}]+#{delim}){0,#{i+1}})/, 1] }).uniq
e[/^[^#{delim_chars}]*(#{delim}[^#{delim_chars}]+){0,#{i}}$/] }
(current_matches + future_matches.map {|e| e[/^(([^#{delim_chars}]*#{delim}){0,#{i+1}})/, 1] }).uniq
end
end
end
8 changes: 6 additions & 2 deletions test/search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@

describe "files search" do
before {
complete(:on=>/rm/, :search=>:files) { %w{a1 d1/f2 d1/d2/f1 d2/f1 d2/f1/} }
complete(:on=>/rm/, :search=>:files) { %w{a1 d1/f2 d1/d2/f1 d2/f1 d2/f1/ /f1} }
}
it "completes all paths" do
tab('rm ').should == %w{a1 d1/ d2/}
tab('rm ').should == %w{a1 d1/ d2/ /}
end

it "completes single first level file" do
Expand All @@ -118,5 +118,9 @@
it "completes file and directory with same name" do
tab('rm d2/f').should == %w{d2/f1 d2/f1/}
end

it "completes file with full path" do
tab('rm /f').should == %w{/f1}
end
end
end

0 comments on commit 4681b37

Please sign in to comment.