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

dotnet format logs no change nessesary with dotnet #327

Open
Rikthepixel opened this issue Apr 4, 2024 · 7 comments
Open

dotnet format logs no change nessesary with dotnet #327

Rikthepixel opened this issue Apr 4, 2024 · 7 comments

Comments

@Rikthepixel
Copy link

Rikthepixel commented Apr 4, 2024

Which configuration?

Type (custom or builtin): builtin
Filetype: cs
Formatter: dotnetformat

Configuration(s):

Builtin dotnet format

{
  logging = true,
  log_level = vim.log.levels.DEBUG,
  filetype = {
    cs = {
      require("formatter.filetypes.cs").dotnetformat
    },
  },
}

Attempted custom configuration with ignore_exitcode and no_append

{
  logging = true,
  log_level = vim.log.levels.DEBUG,
  filetype = {
    cs = {
      function()
        return {
          exe = "dotnet",
          args = {
            "format",
            "whitespace",
            "--include",
          },
          no_append = true,
          ignore_exitcode = true,
          stdin = false,
        }
      end,
    },
  },
}

Expected behavior

When the formatter is ran the contents of the file should be changed the and result in the same changes as running dotnet format whitespace --include .\Test.cs in the commandline.

Initial file content

if(true){  Console.WriteLine();
}

File content after format

if (true)
{
    Console.WriteLine();
}

Actual behaviour

When the formatter is ran, formatter.nvim logs that nothing has changed. When checking the tempfile it does seem that it hasn't changed. Though when manually dotnet format whitespace --include .\Test.cs the it does get formatted correctly.

Additional context

formatter.nvim logs no change nessesary with dotnet. Which seems to mean that the tempfile hasn't changed. I tried to modify the plugin to try to debug it, though it just confirmed what the log said. Maybe the formatter.nvim is reading the file out before dotnet format is finished formatting?

@protomorphine
Copy link

have the same issue with latest formatter.nvim

@mhartington
Copy link
Owner

Hmm yeah I'm able to replicate this as well. I wonder if it's something with the formatters arguments

@OuthBack
Copy link
Contributor

OuthBack commented Oct 6, 2024

I'm facing the same issue with rubocop, but I can't debug properly.
I've been trying the rubocop cli and it seems an issue with the stdin. But just with the flag --auto-correct. With --fix-layout it works properly.

@OuthBack
Copy link
Contributor

OuthBack commented Oct 7, 2024

I'm changing the files. It seems the stdout is not being setted to the output. So it is equal to the input and the error message says the no changes happened.

@OuthBack
Copy link
Contributor

OuthBack commented Oct 7, 2024

This code is not running

if ignore_exitcode or data == 0 then
  if current_output == nil then
    current_output = { "" }
  end
  log.info(string.format("Finished running %s", name))
  output = transform and transform(current_output) or current_output
end

@OuthBack
Copy link
Contributor

OuthBack commented Oct 7, 2024

I changed and it worked @Rikthepixel @mhartington

if ignore_exitcode or data ~= 0 then
  if current_output == nil then
    current_output = { "" }
  end
  log.info(string.format("Finished running %s", name))
  output = transform and transform(current_output) or current_output
end

I don't know the impacts, but I will run the tests and create a PR later.

@OuthBack
Copy link
Contributor

The PR was reverted

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

4 participants