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

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 12 03:49:20 PDT 2019


sammccall created this revision.
sammccall added reviewers: ilya-biryukov, hokein.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, ioeric, mgorny.
Herald added a project: clang.

The existing implementation (which triggers on }) is fairly simple and
has flaws:

- doesn't trigger frequently/regularly enough (particularly in editors that type the } for you)
- often reformats too much code around the edit
- has jarring cases that I don't have clear ideas for fixing

This implementation is designed to trigger on newline, which feels to me more
intuitive than } or ;.
It does have allow for reformatting after other characters - it has a
basic behavior and a model for adding specialized behavior for
particular characters. But at least initially I'd stick to advertising
\n in the capabilities.

This also handles comment splitting: when you insert a line break inside
a line comment, it will make the new line into an aligned line comment.

Working on tests, but want people to patch it in and try it - it's hard to
see if "feel" is right purely by looking at a test.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D60605

Files:
  clangd/CMakeLists.txt
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/Format.cpp
  clangd/Format.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60605.194838.patch
Type: text/x-patch
Size: 14587 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190412/2c327f86/attachment-0001.bin>


More information about the cfe-commits mailing list