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

lsp-format insert unknown character #26

Open
wingyplus opened this issue Jan 9, 2020 · 3 comments
Open

lsp-format insert unknown character #26

wingyplus opened this issue Jan 9, 2020 · 3 comments
Assignees

Comments

@wingyplus
Copy link

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"
  }
]
@wingyplus wingyplus changed the title lsp-format insert unknown character and make some source code loss lsp-format insert unknown character Jan 9, 2020
@vladdu
Copy link
Collaborator

vladdu commented Jan 9, 2020

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

@vladdu vladdu self-assigned this Jan 9, 2020
@vladdu
Copy link
Collaborator

vladdu commented Jan 9, 2020

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?

@wingyplus
Copy link
Author

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

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