Nova 11 duplicates code after Format Document

Hi there!

I had a look at the new Format Document command of v11 and I experienced a code duplication with two different language servers.

Considering a file with this content:

class MeController < ApplicationController
  def show
  puts "ciao"
  end
end

I would expect the following result after running the command:

class MeController < ApplicationController
  def show
    puts "ciao"
  end
end

Instead I got this:

class MeController < ApplicationController
  def show
    puts "ciao"
  end
end
class MeController < ApplicationController
  def show
  puts "ciao"
  end
end

If it can help this is the response of the formatting request:

[{"newText":"class MeController < ApplicationController\n  def show\n    puts \"ciao\"\n  end\nend\n","range":{"start":{"character":0,"line":0},"end":{"line":5,"character":0}}}]

Since I can’t configure the feature in any way I consider this a Nova issue. If I can help debugging this in any way let me know.

Thanks!

I’m seeing this behaviour as well with my extension; the textDocument/formatting response of my LSP server is handled correctly in VSC, but in Nova the formatted text is inserted into the document instead of replacing the current contents.

1 Like

Thank you for the bug report. We will investigate.

1 Like

Hi, this still seems to be a bug as of Nova 11.6. I’m not sure what version we were on when this was reported.

I’ve also seen this issue when working with a LSP. The LSP seems to send a reasonable response:

Received JSON-RPC response: number(49) textDocument/formatting
{
  "jsonrpc" : "2.0",
  "result" : [
    {
      "range" : {
        "start" : {
          "character" : 0,
          "line" : 0
        },
        "end" : {
          "character" : 0,
          "line" : 279
        }
      },
      "newText" : "xxx"
    }
  ],
  "id" : 49
}

But I end up with he entire document duplicated at the end