[PATCH] D76770: [CodeComplete] Don't replace the rest of line in #include completion.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 26 01:35:33 PDT 2020


hokein added a comment.

In D76770#1941603 <https://reviews.llvm.org/D76770#1941603>, @sammccall wrote:

> Does this regress the case where you complete a file rather than a directory?
>  e.g. `#include "foo/^one.h"`
>  If you select "two.h", then we definitely want to replace "one.h", right?


yes, it has a regression, but we don't change the behavior for the above case. A regression case is like

  #include "foo/^dir1/one.h"
  // with two candidates: dir2 and foo.h

if we choose 2), after completion, `"foo/foo.h/one.h"` (now) vs `foo/foo.h` (before)

> The root here is that we have to decide what to replace independently of the completion item.
>  One compromise might be to replace up to the quote, but if you're completing `"foo/^one.h"` and `bar` is a directory, check if `foo/bar/one.h` exists and offer it as a completion. Seems complicated though.

agree, it doesn't seem to be worth the effort.

> Or we can take the tradeoff here if it's better but it'd be good to understand why.

it was originally reported by one internal user.

I think the new behavior (with this patch)

- is more aligned with mental model of code completion (most people think code completion just inserts the code text at the cursor position )
- keeps the consistent behavior with other code completions, e.g. `foo.^member()` if you select the `member` in code completion, another `member` text will be inserted


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76770/new/

https://reviews.llvm.org/D76770





More information about the cfe-commits mailing list