[PATCH] D60605: [clangd] Revamp textDocument/onTypeFormatting.

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 6 08:18:19 PDT 2019


ilya-biryukov added a comment.

Sorry for the delay, I'll make sure to take a close look at the change tomorrow.

As mentioned in offline discussions, doing this through `clang-format` seems like the right approach. At the same the markers we put into the files to drive formatting seem fragile, giving results we don't want.
The biggest issue that I can see is that it's super-hard to predict what `clang-format` is going to do in each case and even harder to certify that this should work in general case.

Intuitively, moving the logic to `clang-format` seems like the right thing to do in the long run (e.g. introducing a special cursor marker into clang-format, similar a code completion marker used by clang or something similar).
OTOH, it's hard for me to asses the amount of work needed to do this inside `clang-format` itself (not a `clang-format` expert), and the patch is definitely an improvement to what we had before (I've been using it for awhile now). The problems do get fixed, so I'm totally happy with it landing as is if we commit to fixing those nasty cases until we run out of them.

PS. In the meantime, I've found another case where newline gets eaten:

  class SyntaxTreeTest {
  public:
    ^ 
  };

**Expected:** newline is added.
**Actual:** does not let to add a newline (the added newline is removed).


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60605





More information about the cfe-commits mailing list