[PATCH] D40060: [clangd] Fuzzy match scorer

Evgeny Gryaznov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 27 09:18:36 PST 2017


inspirer added inline comments.


================
Comment at: clangd/FuzzyMatch.cpp:254
+  // Penalty: matching inside a segment (and previous char wasn't matched).
+  if (WordRole[W] == Tail && P && !Matched[P - 1][W - 1])
+    S -= 3;
----------------
You need a third boolean dimension in your DP table for this condition to work - "matches".

Consider matching "Abde" against "AbdDe". The result should be [Ab]d[De] and not [Abd]D[e]. While evaluating Abd against AbdD, you will have to choose between two ways to represent the match and no matter what you choose, scoring in this line will not know whether your previous char matched, since you merged two branches and kept only one of them.

This scoring works OK-ish since you check "if (Diag >= Left)" above and so you Matched table is full of trues, but you matches will gravitate towards the ends of the candidate string if you decide to show them in the UI.


https://reviews.llvm.org/D40060





More information about the cfe-commits mailing list