diff --git a/ruby/command-t/match.c b/ruby/command-t/match.c index 03644677..df7a6460 100644 --- a/ruby/command-t/match.c +++ b/ruby/command-t/match.c @@ -1,4 +1,4 @@ -// Copyright 2010-2013 Wincent Colaiuta. All rights reserved. +// Copyright 2010-2014 Wincent Colaiuta. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: @@ -125,11 +125,10 @@ double recursive_match(matchinfo_t *m, // sharable meta-data } score += score_for_char; - last_idx = haystack_idx + 1; + last_idx = ++haystack_idx; break; } } - if (!found) { score = 0.0; goto memoize; diff --git a/ruby/command-t/matcher.c b/ruby/command-t/matcher.c index 9417f16a..1fcc844c 100644 --- a/ruby/command-t/matcher.c +++ b/ruby/command-t/matcher.c @@ -127,7 +127,6 @@ void *match_thread(void *thread_args) return NULL; } - VALUE CommandTMatcher_sorted_matches_for(int argc, VALUE *argv, VALUE self) { long i, limit, path_count, thread_count; diff --git a/spec/command-t/matcher_spec.rb b/spec/command-t/matcher_spec.rb index bb95eef5..db21ebea 100644 --- a/spec/command-t/matcher_spec.rb +++ b/spec/command-t/matcher_spec.rb @@ -1,4 +1,4 @@ -# Copyright 2010-2013 Wincent Colaiuta. All rights reserved. +# Copyright 2010-2014 Wincent Colaiuta. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -203,5 +203,19 @@ def ordered_matches(paths, query) TODO ] end + + it "doesn't incorrectly accept repeats of the last-matched character" do + # https://github.com/wincent/Command-T/issues/82 + matcher = matcher(*%w[ash/system/user/config.h]) + matcher.sorted_matches_for('usercc').should == [] + + # simpler test case + matcher = matcher(*%w[foobar]) + matcher.sorted_matches_for('fooooo').should == [] + + # minimal repro + matcher = matcher(*%w[ab]) + matcher.sorted_matches_for('aa').should == [] + end end end