[PATCH] D95419: [clangd] Fix filename completion at the end of file

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 26 00:22:39 PST 2021


sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks for puzzling this one out, i thought it would be in lexer...



================
Comment at: clang-tools-extra/clangd/CodeComplete.cpp:1127
+  // If preamble doesn't end on a new line, include the following byte in
+  // preamble to enable include completion on a new file. e.g: #include "^
+  bool CompletingInPreamble =
----------------
"include the following byte" doesn't match my mental model, which is that we're on the boundary, and are choosing whether to resolve left out right, i.e *guessing* whether inserted text will become part of the preamble or the main file.

(Of course everyone has their own mental model - but if that seems clearer to you too, maybe reword)

 clearer might be:

```
if (Offset < Size || (!EndsInNewline && Offset == Size))
```

May not even need the comment in this case, up to you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95419



More information about the cfe-commits mailing list