Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line spacing settings have unexpected behaviour #191

Open
Sharparam opened this issue Dec 3, 2024 · 3 comments
Open

Line spacing settings have unexpected behaviour #191

Sharparam opened this issue Dec 3, 2024 · 3 comments

Comments

@Sharparam
Copy link

Sharparam commented Dec 3, 2024

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).

@CppCXY
Copy link
Owner

CppCXY commented Dec 4, 2024

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.

@Sharparam
Copy link
Author

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

@CppCXY
Copy link
Owner

CppCXY commented Dec 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants