This is an archive of the discontinued LLVM Phabricator instance.

[clangd] strictly respect formatting range
AbandonedPublic

Authored by qchateau on Mar 4 2021, 2:29 PM.

Details

Reviewers
sammccall
Summary

Clang format will often format a range of code wider then the requested format range. Returning a replacement outside of the requested range can mess with clients. Keeping the formatting in range of what the client asks gives more expected results and will limit the impact of partial formatting in diffs.

A specific example: a problem often occurs when using VSCode in "format modified lines" mode. The client will ask clangd to format two non-continugous lines, separately. Clangd replies to both requests with replacements for both lines, effectively providing four replacements in total. VSCode will either apply replacements twice (messing up the results) or simply error out and skip the formatting.

Diff Detail

Event Timeline

qchateau created this revision.Mar 4 2021, 2:29 PM
qchateau requested review of this revision.Mar 4 2021, 2:29 PM
qchateau updated this revision to Diff 328314.Mar 4 2021, 2:48 PM

fix tests

qchateau abandoned this revision.Sep 15 2021, 12:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 15 2021, 12:57 PM