Skip to content

DidChange not working as expected #85

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

Closed
hendrikmennen opened this issue Oct 15, 2021 · 6 comments · Fixed by #89
Closed

DidChange not working as expected #85

hendrikmennen opened this issue Oct 15, 2021 · 6 comments · Fixed by #89
Assignees
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@hendrikmennen
Copy link

I am trying to implement this LS into my own IDE.
While clangd itself works flawlessly, this LS does not.

In this example I just create new lines in an empty file:

Creating a newline in 1:0 works.
Creating a newline in the new 2:0 does not, and gives me a invalid change range.

Here is the full log for the simple scenario.

[01:66:19] Arduino LS: 2021/10/15 12:54:50 IDE --> textDocument/didChange notif8 ←[93m locked←[0m
[01:66:19] Arduino LS: 2021/10/15 12:54:50 --> didChange(file:///c:/Users/HendrikMennen/Documents/VHDPlus/Projects/ArduinoTest/ArduinoTest.ino@123)
[01:66:19] Arduino LS: 2021/10/15 12:54:50      > 1:0-1:0 -> "\r\n"
[01:66:19] Arduino LS: 2021/10/15 12:54:50     --> didChange(file:///C:/Users/HendrikMennen/AppData/Local/Temp/arduino-language-server3008026257/sketch/ArduinoTest.ino.cpp@6)
[01:66:19] Arduino LS: 2021/10/15 12:54:50          > 3:0-3:0 -> "\r\n"
[01:66:19] Arduino LS: 2021/10/15 12:54:50 ←[91mIDE     LS --> CL: NOTIFICATION textDocument/didChange: ←[0m
[01:66:19] Arduino LS: 2021/10/15 12:54:50 IDE --> textDocument/didChange notif8 ←[93m unlocked←[0m
[01:66:19] Arduino LS: 2021/10/15 12:54:50 ←[92mIDE     LS <-- CL: NOTIFICATION textDocument/publishDiagnostics: ←[0m
[01:66:19] Arduino LS: 2021/10/15 12:54:50 CLG <-- textDocument/publishDiagnostics notif179 (queued)
[01:66:19] Arduino LS: 2021/10/15 12:54:50 CLG <-- textDocument/publishDiagnostics notif179 ←[93m read-locked←[0m
[01:66:19] Arduino LS: 2021/10/15 12:54:50 CLG <-- textDocument/publishDiagnostics notif179 (running)
[01:66:19] Arduino LS: 2021/10/15 12:54:50 CLG <-- textDocument/publishDiagnostics notif179 publishDiagnostics(file:///C:/Users/HendrikMennen/AppData/Local/Temp/arduino-language-server3008026257/sketch/ArduinoTest.ino.cpp):
[01:66:19] Arduino LS: 2021/10/15 12:54:50 CLG <-- textDocument/publishDiagnostics notif179 > 0:0 - 1: drv_unknown_argument_with_suggestion
[01:66:19] Arduino LS: 2021/10/15 12:54:50 CLG <-- textDocument/publishDiagnostics notif179 > 0:0 - 1: drv_unknown_argument
[01:66:19] Arduino LS: 2021/10/15 12:54:50 CLG <-- textDocument/publishDiagnostics notif179 > 0:0 - 1: drv_unknown_argument_with_suggestion
[01:66:19] Arduino LS: 2021/10/15 12:54:50 CLG <-- textDocument/publishDiagnostics notif179 > 0:0 - 1: drv_unknown_argument
[01:66:19] Arduino LS: 2021/10/15 12:54:50 CLG <-- textDocument/publishDiagnostics notif179 > 0:9 - 1: expected_fn_body
[01:66:19] Arduino LS: 2021/10/15 12:54:50 CLG <-- textDocument/publishDiagnostics notif179 > 2:0 - 1: unknown_typename
[01:66:19] Arduino LS: 2021/10/15 12:54:50 CLG <-- textDocument/publishDiagnostics notif179 > 5:0 - 1: expected_unqualified_id
[01:66:19] Arduino LS: 2021/10/15 12:54:50     URI: converted 0:0-0:0 to /not-ino:0:0-0:0
[01:66:19] Arduino LS: 2021/10/15 12:54:50     URI: converted 0:0-0:0 to /not-ino:0:0-0:0
[01:66:19] Arduino LS: 2021/10/15 12:54:50     URI: converted 0:0-0:0 to /not-ino:0:0-0:0
[01:66:19] Arduino LS: 2021/10/15 12:54:50     URI: converted 0:0-0:0 to /not-ino:0:0-0:0
[01:66:19] Arduino LS: 2021/10/15 12:54:50     URI: converted 0:9-0:10 to /not-ino:0:9-0:10
[01:66:19] Arduino LS: 2021/10/15 12:54:50     URI: converted 2:0-2:2 to C:\Users\HendrikMennen\Documents\VHDPlus\Projects\ArduinoTest\ArduinoTest.ino:0:0-0:2
[01:66:19] Arduino LS: 2021/10/15 12:54:50     URI: is in preprocessed section
[01:66:19] Arduino LS: 2021/10/15 12:54:50          converted 5:0-5:0 to /not-ino:0:0-0:0
[01:66:19] Arduino LS: 2021/10/15 12:54:50 CLG <-- textDocument/publishDiagnostics notif179 to IDE: publishDiagnostics(file:///c:/Users/HendrikMennen/Documents/VHDPlus/Projects/ArduinoTest/ArduinoTest.ino):
[01:66:19] Arduino LS: 2021/10/15 12:54:50 CLG <-- textDocument/publishDiagnostics notif179 > 0:0 - 1: unknown_typename
[01:66:19] Arduino LS: 2021/10/15 12:54:50 ←[91mIDE <-- LS     CL: NOTIFICATION textDocument/publishDiagnostics: ←[0m
[01:66:19] Arduino LS: 2021/10/15 12:54:50 CLG <-- textDocument/publishDiagnostics notif179 ←[93m read-unlocked←[0m
[01:66:20] Arduino LS: 2021/10/15 12:54:51 ←[92mIDE --> LS     CL: NOTIFICATION textDocument/didChange: ←[0m
[01:66:20] Arduino LS: 2021/10/15 12:54:51 IDE --> textDocument/didChange notif9 ←[93m locked←[0m
[01:66:20] Arduino LS: 2021/10/15 12:54:51 --> didChange(file:///c:/Users/HendrikMennen/Documents/VHDPlus/Projects/ArduinoTest/ArduinoTest.ino@124)
[01:66:20] Arduino LS: 2021/10/15 12:54:51      > 2:0-2:0 -> "\r\n"
[01:66:20] Arduino LS: 2021/10/15 12:54:51     --E error: invalid change range file:///c:/Users/HendrikMennen/Documents/VHDPlus/Projects/ArduinoTest/ArduinoTest.ino:2:0-2:0
[01:66:20] Arduino LS: 2021/10/15 12:54:51 IDE --> textDocument/didChange notif9 ←[93m unlocked←[0m
[01:66:20] Arduino LS: 2021/10/15 12:54:51 jsonrpc2 handler: notification "textDocument/didChange" handling error: invalid change range file:///c:/Users/HendrikMennen/Documents/VHDPlus/Projects/ArduinoTest/ArduinoTest.ino:2:0-2:0

If anyone knows why this is happening, please tell me :)

As I said, my way of handling didChange does work with plain clangd and other language servers aswell so I don't see the reason why this could fail.

@hendrikmennen
Copy link
Author

It has something to do with line numbers, seems like the language server does not like me creating code in lines that are below the original document.

If my document had 5 lines at the beginning, I will get invalid change range at line 6 or 7.
Very weird. Maybe this LS does not recognize \n as newline?

@ubidefeo
Copy link

hi @hendrikmennen

The language server is undergoing a massive rewrite.
As you may guess this is targeting our specific use cases and the IDE 2.0

At this point in time that is all we'll be focusing on.
A possible future implementation might be for VS Code but it's way too early to know.

We appreciate your effort in willing to give it a shot for your editor (which one, by the way?),
so I hope as we work around the bugs in our implementation you'll find a more solid codebase for your own ✌🏼

@hendrikmennen
Copy link
Author

Thank you for the response.
My editor is VHDPlus IDE, which is made for FPGAs.
I am currently working on supporting Arduino, so our users can conveniently program extensions (for example Wifi Extension using esp8266).
Is this language server not the one currently used in Arduino IDE 2.0?

@ubidefeo
Copy link

My editor is VHDPlus IDE, which is made for FPGAs.
I am currently working on supporting Arduino, so our users can conveniently program extensions (for example Wifi Extension using esp8266).

cool!

Is this language server not the one currently used in Arduino IDE 2.0?

it is, but there's heavy development going on these past few weeks.
This current version came with Theia and was adapted to work towards our needs but it's not proven to be very reliable, so our CLI Go ninja decided to make it his own mission to fix it :)

Not sure when we'll release it but it's undergoing some internal test and will be pushed to this repository when it's worthy of being bundled with the IDE 😉

@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Nov 17, 2021
@hendrikmennen
Copy link
Author

Just to let you know.
The issue only exists if I try to edit .ino files.
all other files (cpp, h, ...) work without problems.

@ubidefeo
Copy link

.ino files are handled like unicorns.
There's a lot of special treatment going on there, for instance automatic forward declaration during the parsing and many more things.
Hope the next revision will work better for your use case :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants