thqby / vscode-autohotkey2-lsp

Autohotkey v2 Language Support using vscode-lsp.
https://marketplace.visualstudio.com/items?itemName=thqby.vscode-autohotkey2-lsp
GNU Lesser General Public License v3.0
210 stars 21 forks source link

Server initialization failure after changing anything in .json file #490

Closed GroggyOtter closed 6 months ago

GroggyOtter commented 6 months ago

The last updated introduced some kind of bug whereby if you alter the ahk2.json file, it causes the server to no longer connect.

I uninstalled, deleted, and reinstalled the addon. It works.

Opened ahk2.json, deleted a space, put the space back in, saved, and reloaded VS Code.

Got this:

[Error - 10:34:17 AM] Restarting server failed
  Message: Request initialize failed with message: Unexpected token '', "{
    "dire"... is not valid JSON
  Code: -32603 
[Error - 10:34:19 AM] Server process exited with code 1.
[Error - 10:34:19 AM] The AutoHotkey2 server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

Changing the contents of ahk2.d.ahk doesn't cause the problem, either. Only altering the .json file.

Edit: This apparently does happen with 2.3.7 now and I can't figure out why.
I've changed lots of stuff in the last week but today is when it started acting up. I'm confused.

thqby commented 6 months ago

Can you upload faulty json?

GroggyOtter commented 6 months ago

It's the default ahk2.json file that comes with the update. All I did was remove a whitespace and replace. Character for character, it's identical to what you get with a fresh install.

GroggyOtter commented 6 months ago
Unexpected token '', "{
    "dire"... is not valid JSON

The JSON file is valid. There's something going on with the parsing before it. {"dire" is the start of the JSON file. This part prior might be the problem: '', " I'm showing:
0027 FEFF 0027 002C 0020 0022 FEFF FEFF is odd to see. Is that due to the file having a BOM?

thqby commented 6 months ago

Yes, with utf8-bom.

Saving as utf8-bom causes this issue.

GroggyOtter commented 6 months ago

I don't understand why it all of a sudden started happening in the last 24 hours. I've edited those files tons of times and this is the first time this has happened. What changed?

fade2gray commented 6 months ago

Have you maybe deleted the json and recreated it from a new text file in Windows explorer?

https://www.autohotkey.com/boards/viewtopic.php?f=82&t=120681

thqby commented 6 months ago

Have you set the default save encoding for the file?

GroggyOtter commented 6 months ago

Have you maybe deleted the json and recreated it from a new text file in Windows explorer?

https://www.autohotkey.com/boards/viewtopic.php?f=82&t=120681


Have you set the default save encoding for the file?


Per my previous post, I uninstalled the addon, deleted everything, did a full reinstall to ensure fresh files were pulled for the addon, opened the json file in vs code, deleted and replaced a space, and saved it.
This causes an error. There is no good reason those steps should produce an error.

If the initial file has no bom to start with, then opening and saving it shouldn't add one to the file.

Plus, I haven't altered my VS Code settings in quite some time, so unless there was some core change to VS code that silently happened in the last couple days, I have no clue what would cause this.

I've done this process literally hundreds of times while making/maintaining/updating my enhanced definition files and this is the first time I've gotten these errors.
Something changed and I don't know what.

thqby commented 6 months ago

If the initial file has no bom to start with, then opening and saving it shouldn't add one to the file.

Yes, modifying and saving here will not add bom.

Has the file encoding of the status bar in the lower right corner of your interface changed?