llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

clang-format -lines modifies code outside the specified range

Open just-some-entity opened this issue 1 year ago • 1 comments

When using an editor with “format on paste” enabled via clang-format, pasting an incomplete line, like in the example below, causes the following line to be indented, even if -lines is set to target only the pasted line. Pasting a partial line while using format-on-paste to adjust its indentation is a fairly reasonable workflow in my opinion, so it would be nice to either "fix" this behaviour or add a clang-format option to disable it.

QWindow* // pasted line


    class RhiResourceManager

just-some-entity avatar Nov 03 '25 05:11 just-some-entity

@llvm/issue-subscribers-clang-format

Author: entity (just-some-entity)

When using an editor with “format on paste” enabled via clang-format, pasting an incomplete line, like in the example below, causes the following line to be indented, even if -lines is set to target only the pasted line. Pasting a partial line while using format-on-paste to adjust its indentation is a fairly reasonable workflow in my opinion, so it would be nice to either "fix" this behaviour or add a clang-format option to disable it.
QWindow* // pasted line


    class RhiResourceManager

llvmbot avatar Nov 03 '25 05:11 llvmbot