From adb31abef2d974304db7a06a11bb91c5d0b6e0d3 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Sun, 24 Jun 2012 15:11:58 -0700 Subject: [PATCH] Fixing a bug with word-boundary ratio calculation --- cpp/ycm/Result.cpp | 6 +++--- cpp/ycm/tests/Completer_test.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cpp/ycm/Result.cpp b/cpp/ycm/Result.cpp index 1203cc20..340c7f55 100644 --- a/cpp/ycm/Result.cpp +++ b/cpp/ycm/Result.cpp @@ -36,11 +36,11 @@ int NumWordBoundaryCharMatches( const std::string &query, while ( j < query.size() && i < word_boundary_chars.size() ) { if ( toupper( query[ j ] ) == toupper( word_boundary_chars[ i ] ) ) - ++i; - ++j; + ++j; + ++i; } - return i; + return j; } } // unnamed namespace diff --git a/cpp/ycm/tests/Completer_test.cpp b/cpp/ycm/tests/Completer_test.cpp index cbf87f10..ae5e5f03 100644 --- a/cpp/ycm/tests/Completer_test.cpp +++ b/cpp/ycm/tests/Completer_test.cpp @@ -116,6 +116,18 @@ TEST( CompleterTest, CompleteMatchForWordBoundaryCharsWins ) TEST( CompleterTest, RatioUtilizationTieBreak ) { + EXPECT_THAT( Completer( Candidates( + "aGaaFooBarQux", + "aBaafbq" ) ).CandidatesForQuery( "fbq" ), + ElementsAre( "aGaaFooBarQux", + "aBaafbq" ) ); + + EXPECT_THAT( Completer( Candidates( + "aFooBarQux", + "afbq" ) ).CandidatesForQuery( "fbq" ), + ElementsAre( "aFooBarQux", + "afbq" ) ); + EXPECT_THAT( Completer( Candidates( "FooBarQux", "FooBarQuxZaa" ) ).CandidatesForQuery( "fbq" ),