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

unnecessary newline added when format on paste is enabled #1606

Closed
xiangnanscu opened this issue Oct 1, 2022 · 3 comments
Closed

unnecessary newline added when format on paste is enabled #1606

xiangnanscu opened this issue Oct 1, 2022 · 3 comments
Labels
bug Something isn't working feat/formatter Related to code formatter
Milestone

Comments

@xiangnanscu
Copy link

xiangnanscu commented Oct 1, 2022

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows WSL

What is the issue affecting?

Formatting

Expected Behaviour

When I refine my code I usually need to copy and paste some code in an inserting style. In this case, could the ext check if there is a line in the next position so doesn't add newline? format on paste is a useful option, I don't want to turn it off.

local function foo()
  -- try to paste 'local a= 1' here
  local b = 2
end

expected:

local function foo()
  local a = 1
  local b = 2
end

Actual Behaviour

local function foo()
  local a = 1

  local b = 2
end

Reproduction steps

just as above

Additional Notes

No response

Log File

No response

@carsakiller carsakiller added the feat/formatter Related to code formatter label Oct 1, 2022
@carsakiller
Copy link
Collaborator

Formatting is provided by https://github.com/CppCXY/EmmyLuaCodeStyle, this may be an issue with that project.

@ltWolfik
Copy link

ltWolfik commented Oct 3, 2022

Seems, the problem originates from config insert_final_newline option. When a line is formatted - the EmmyLuaCodeStyle adds newline because of insert_final_newline = true

The same problem when Format selection is used. Possible workaround - to disable insert_final_newline for lua in editorconfig. But the perfect solution would be ignore insert_final_newline when doing Format selection or on pasting.

@CppCXY
Copy link
Contributor

CppCXY commented Oct 4, 2022

Seems, the problem originates from config insert_final_newline option. When a line is formatted - the EmmyLuaCodeStyle adds newline because of insert_final_newline = true

The same problem when Format selection is used. Possible workaround - to disable insert_final_newline for lua in editorconfig. But the perfect solution would be ignore insert_final_newline when doing Format selection or on pasting.

that's not my problem,this is a bug, but It is currently a holiday, and after the holidays the author will fix that.

@sumneko sumneko added the bug Something isn't working label Oct 9, 2022
@sumneko sumneko added this to the 3.6.0 milestone Oct 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feat/formatter Related to code formatter
Projects
None yet
Development

No branches or pull requests

5 participants