This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Filter completion results by fuzzy-matching identifiers.
ClosedPublic

Authored by sammccall on Nov 9 2017, 4:58 PM.

Details

Summary

This allows us to limit the number of results we return and still allow them
to be surfaced by refining a query (D39852).

The initial algorithm is very conservative - it accepts a completion if the
filter is any case-insensitive sub-sequence. It does not attempt to rank items
based on match quality.

Diff Detail

Repository
rL LLVM

Event Timeline

sammccall created this revision.Nov 9 2017, 4:58 PM
ilya-biryukov edited edge metadata.Nov 22 2017, 7:59 AM

We definitely need to:

  • Rebase this change on top of current head (to account for limits and scoring)
  • Set incomplete=true for fuzzy-matched completion results

Maybe also make fuzzy-matching configurable via a flag? Off-by-default for now, so we could start testing it before we finish optimizing single-identifier edits. When we have it, enable fuzzy-matching by default.

clangd/ClangdUnit.cpp
427 ↗(On Diff #122374)

Debug output sneaked into the commit.

We definitely need to:

  • Rebase this change on top of current head (to account for limits and scoring)

Done. There's very little interaction - for now the match doesn't affect scoring, we're just shifting work from the client to the server.

  • Set incomplete=true for fuzzy-matched completion results

Why? If you complete "foo.b^" then "qux" isn't a valid result. Clients *must* requery when erasing anyway, regardless of isIncomplete - it's only "further typing" that can reuse the result set.

Maybe also make fuzzy-matching configurable via a flag? Off-by-default for now, so we could start testing it before we finish optimizing single-identifier edits. When we have it, enable fuzzy-matching by default.

Why?
I don't think it makes sense to put this behind a flag, unless we're just worried the code is buggy. I'm already concerned about the proliferation of flags for features users *might* care about, this one either works or it doesn't.
This patch just says "don't return qux() if the user presses ctrl-space after foo.b". It doesn't affect the existing behavior when user types "foo." - we'll still request completion, the filter will be empty. And this patch doesn't affect ranking.

sammccall updated this revision to Diff 125009.Nov 30 2017, 1:59 PM

Rebase and remove debug output.

@ilya-biryukov Ping... this is the patch we wanted to land this week, so long result sets are correct for user testing next week.

This revision is now accepted and ready to land.Dec 1 2017, 8:26 AM
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.