diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2018-06-06 12:38:37 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2018-06-06 12:38:37 +0000 |
| commit | bc7cbb78952137ad8a7f42538a7d2be0af1e8ac1 (patch) | |
| tree | 04389e11159c9ca895578d334b54d799a8171fd2 /clang-tools-extra/clangd/FuzzyMatch.cpp | |
| parent | 9337b41cb5cd79fb57d97578b3c5e26a117ddfaf (diff) | |
| download | bcm5719-llvm-bc7cbb78952137ad8a7f42538a7d2be0af1e8ac1.tar.gz bcm5719-llvm-bc7cbb78952137ad8a7f42538a7d2be0af1e8ac1.zip | |
[clangd] Boost fuzzy match score by 2x (so a maximum of 2) when the query is the full identifier name.
Summary: Fix a couple of bugs in tests an in Quality to keep tests passing.
Reviewers: ioeric
Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits
Differential Revision: https://reviews.llvm.org/D47815
llvm-svn: 334089
Diffstat (limited to 'clang-tools-extra/clangd/FuzzyMatch.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/FuzzyMatch.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang-tools-extra/clangd/FuzzyMatch.cpp b/clang-tools-extra/clangd/FuzzyMatch.cpp index 152f1799777..0fc2e32c523 100644 --- a/clang-tools-extra/clangd/FuzzyMatch.cpp +++ b/clang-tools-extra/clangd/FuzzyMatch.cpp @@ -101,7 +101,13 @@ Optional<float> FuzzyMatcher::match(StringRef Word) { Scores[PatN][WordN][Match].Score); if (isAwful(Best)) return None; - return ScoreScale * std::min(PerfectBonus * PatN, std::max<int>(0, Best)); + float Score = + ScoreScale * std::min(PerfectBonus * PatN, std::max<int>(0, Best)); + // If the pattern is as long as the word, we have an exact string match, + // since every pattern character must match something. + if (WordN == PatN) + Score *= 2; // May not be perfect 2 if case differs in a significant way. + return Score; } // Segmentation of words and patterns. |

