我有这个函数:
bool WS::receive(MB *const buffer) const {
updateLastPackage();
if ((!lastPackage_.empty()) &&
(lastPackage_.size() <= buffer->capacity()) &&
(lastUpdate_.getTime() <= settings_.refreshPeriod)) {
buffer->clear();
(*buffer) << lastPackage_;
return true;
}
return false;
}在应用clang-format with my style file之后:
bool WS::receive(MB *const buffer) const {
updateLastPackage();
if ((!lastPackage_.empty()) &&
(lastPackage_.size() <= buffer->capacity()) &&
(lastUpdate_.getTime() <= settings_.refreshPeriod)) {
buffer->clear();
(*buffer) << lastPackage_;
return true;
}
return false;
}您可以看到,当有换行符时,clang-format删除了if条件中的缩进。那么,如何保持缩进不变呢?这也发生在模板上。
我的风格文件,基于LLVM:https://pastebin.com/ZDwZfBud
发布于 2021-03-12 02:17:33
感谢Yksisarvinen。
解决方案:
AlignOperands: false
ContinuationIndentWidth: 8https://stackoverflow.com/questions/66586008
复制相似问题