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

clang-format: Add AlignConsecutiveShortCaseLabels

Open Hedede opened this issue 4 years ago • 3 comments

I suggest adding an option to align consecutive short case labels.

I have code like this:

constexpr string_view describe(log::level level)
{
	switch (level) {
	case log::info:     return "info:     ";
	case log::warning:  return "warning:  ";
	case log::error:    return "error:    ";
	case log::critical: return "critical: ";
	default:            return "";
	};
}

clang-format formats removes all alignment like this:

constexpr string_view describe(log::level level)
{
	switch (level) {
	case log::info: return "info:     ";
	case log::warning: return "warning:  ";
	case log::error: return "error:    ";
	case log::critical: return "critical: ";
	default: return "";
	};
}

I want to keep the alignment.

Hedede avatar May 15 '22 13:05 Hedede

@llvm/issue-subscribers-clang-format

llvmbot avatar May 15 '22 13:05 llvmbot

This desired feature came up in my attempt to introduce use of clang-format to my codebase at work. I would be willing to work on this and make a patch as long as the consensus is that it would be a desirable feature (I assume by this still being open, that's the case?).

galenelias avatar May 30 '23 03:05 galenelias

https://reviews.llvm.org/D151761

galenelias avatar May 30 '23 23:05 galenelias