erlang / sourcer

An Erlang language server, providing IDE services.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lsp-format insert unknown character

wingyplus opened this issue · comments

I use sourcer with emacs lsp-mode and replacing elixir_ls that come from elixir-ls organization with sourcer. After I write this source:

% hello_module.erl
-module(hello_module).
-export([hello/0]).

hello() ->
    X = "hello",
    io:format("~s~n", [X]).

And then I invoke lsp-format-buffer to format source. Sourcer edit my source with extra character:

�����������������������������������������% hello_module.erl
-module(hello_module).
-export([hello/0]).

hello() ->
    io:format("~s~n", ["Hello, World"]).

The trace log is here:

[Trace - 11:37:53 PM] Sending request 'textDocument/formatting - (235)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/wingyplus/workspace/erlang-playground/hello_module.erl"
  },
  "options": {
    "tabSize": 8,
    "insertSpaces": false
  }
}


[Trace - 11:37:53 PM] Received response 'textDocument/formatting - (235)' in 20ms.
Result: [
  {
    "range": {
      "start": {
        "line": 0,
        "character": 0
      },
      "end": {
        "line": 9991,
        "character": 0
      }
    },
    "newText": "\u0006\u0006\u0006\u0006\u0006\u0006\u0006\u0006\u0006\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000% hello_module.erl\n-module(hello_module).\n-export([hello/0]).\n\nhello() ->\n    io:format(\"~s~n\", [\"Hello, World\"]).\n"
  }
]

Weird, I don't know where those characters could come from... I will look at this.

I can't see anything in the code that would add those characters, so my guess is that it's from the communication from the emacs client, somehow.

If you delete those characters and reformat, does it happen again?
If you create a new file and enter the text and reformat, do you get the same result?

@vladdu As I try, it always happens after I cleared those character and called format again.