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

Formatted content is incorrectly replaced after formatting the selected content. #351

Open
kxccc opened this issue Nov 1, 2024 · 1 comment

Comments

@kxccc
Copy link

kxccc commented Nov 1, 2024

Which configuration?
Type (custom or builtin): builtin
Filetype: objc
Formatter: clangformat

After updating this plugin, I noticed that when formatting selected content instead of the entire file, the formatted content is replaced at the first line of the file, rather than in its original position. I am certain that this issue was introduced in the commit b0edd69.

@hernancerm
Copy link

hernancerm commented Nov 24, 2024

Issue with Stylua

I'm seeing a very similar issue with Stylua on the latest of master (eb89a1f). Below is an example.

Visually select the 2nd line of a file containing this Lua code:

print("Hello world!")
      print("Bye world!")

Run the Format command. Below is the output I get; the first line was modified.

"Hello world!")
      print("Bye world!")

Configuration:

require("formatter").setup({
  filetype = {
    lua = {
      require("formatter.filetypes.lua").stylua
    }
  }
})

Stylua version: 2.0.1

Commit which introduced the bug

A Git bisect agrees with @kxccc on b0edd69 being the first bad commit. I used eb89a1f as bad and 73c1968 as good.

When using the parent commit of the first bad one, there is no issue. Here is the output with the same config:

print("Hello world!")
print("Bye world!")

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