EmmyLuaCodeStyle icon indicating copy to clipboard operation
EmmyLuaCodeStyle copied to clipboard

Line spacing settings have unexpected behaviour

Open Sharparam opened this issue 1 year ago • 3 comments

Expectation

If I set the "line spacing" for something to be fixed(1), there should be one blank line enforced for the relevant items.

Reality

"Line spacing" is actually referring to the number of newlines (\n) that will be enforced, not (blank) lines.

Example

line_space_after_function_statement = fixed(1)

Expectation: There will be exactly 1 empty line after all functions.

I expect this Lua code:

function foo() print("Hello world") end
function bar() print("Hello from bar") end




function baz() print("Hello from baz") end

To format into this:

function foo() print("Hello world") end

function bar() print("Hello from bar") end

function baz() print("Hello from baz") end

But it actually formats into this:

function foo() print("Hello world") end
function bar() print("Hello from bar") end
function baz() print("Hello from baz") end

To get the expected behaviour you have to set the line spacing to 2, which is not very intuitive (especially when compared to other formatting tools).

Sharparam avatar Dec 03 '24 20:12 Sharparam

In version 0.x, the setting was indeed as you expected. After version 1.x, I used std::size_t for most variables. For convenience, I usually consider 0 as an invalid value. and this configuration has been widely used in many projects, so its meaning will not be changed.

CppCXY avatar Dec 04 '24 02:12 CppCXY

Can the documentation then at least be updated to note that "line spacing" is not actually line spacing?

Sharparam avatar Dec 04 '24 05:12 Sharparam

Sure, but I am busy with the development of the language server. Perhaps you could submit a PR?

CppCXY avatar Dec 04 '24 06:12 CppCXY