sammccall added a comment.

You may be interested in D60605 <https://reviews.llvm.org/D60605>, which is a 
related idea (adding incremental format-and-indent-on-type to clangd).

These are opposite extremes in some sense: this patch integrates deeply into 
clang-format and that patch entirely layers on top of it, by transforming the 
source code (in hacky ways, in some cases).

I think the cleanest approach is probably some combination: in particular a 
"preserve line break at point" primitive does seem useful, and even if source 
code transforms are used, putting a nice API on this in clang-format would be 
nice. (I'm not sure a separate command-line-tool is justified, though).

If you haven't run into these yet, here are some fun issues I ran into:

- clang-format bails out when brackets aren't sufficiently matched, incremental 
formatting needs to work in such cases
- incremental formatting sometimes wants to make edits both immediately before 
and after the cursor. `tooling::Replacements` can't represent this, they will 
be merged and destroy precise cursor position information.
- user expectations when breaking between `()` are fairly clear. `{}` is the 
same when it acts as a list, but not when it acts as a block!


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

https://reviews.llvm.org/D53072



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to