EmmyLuaCodeStyle icon indicating copy to clipboard operation
EmmyLuaCodeStyle copied to clipboard

一排if-elseif的换行问题

Open CppCXY opened this issue 2 years ago • 2 comments
trafficstars

Discussed in https://github.com/CppCXY/EmmyLuaCodeStyle/discussions/140

Originally posted by MrZ626 September 12, 2023

if a then a()
elseif b then b()
elseif c then c()
else d()
end

有时候我会这么写,但是目前的格式化风格好像不允许这种写法?翻了一圈没找着 会被格式化成

if a then
    a()
elseif b then
    b()
elseif c then
    c()
else
    d()
end

就太长了 还有一些形如function() a() b() end的包含两个语句的短行我也不希望被拆开,可以考虑加个选项不拆分这些情况吗? 最终需求应该是,允许控制每种语句块(if for while)后换行的条件:always必定换行,smart单条语句不换行,never永不主动换行

@CppCXY (不知道discussion会不会通知 保险at一下)

CppCXY avatar Sep 12 '23 12:09 CppCXY

要不要给你个机会自己实现 @MrZ626

CppCXY avatar Sep 12 '23 12:09 CppCXY

可以试下,不过最近这周比较忙,之后就来再细看看

MrZ626 avatar Sep 12 '23 20:09 MrZ626