Alexey-T / CudaText

Cross-platform text editor, written in Free Pascal
Mozilla Public License 2.0
2.39k stars 166 forks source link

Error in default.json on MacOS #5533

Closed JairoMartinezA closed 1 month ago

JairoMartinezA commented 1 month ago

Hi Alex

With the latest sources (CudaText 1.214.6.4, darwin-x86_64-cocoa, fpc 3.2.2), I am getting the following error. The file currently exists, and I have changed the permissions to be similar to the other config files, but the error is still present.

ERROR: error on loading json. Log file: /Users/my_user/Library/Application Support/CudaText/settings/cudax.log
ERROR: error on loading json. Log file: /Users/my_user/Library/Application Support/CudaText/settings/cudax.log
ERROR: error on loading json. Log file: /Users/my_user/Library/Application Support/CudaText/settings/cudax.log
ERROR: error on loading json. Log file: /Users/my_user/Library/Application Support/CudaText/settings/cudax.log
Alexey-T commented 1 month ago

Need more details:

JairoMartinezA commented 1 month ago

Sorry Alex,

I was thinking the error was with log not with some 'wrong' JSON file

_json_loads FAIL: filename "/Users/my_user/Library/Application Support/CudaText/settings_default/default.json", text:

My file:

default.json.zip

Alexey-T commented 1 month ago

so the error is for my default.json too? and how can I repro it? what UI to call?

note: default.json has comments which are usually NOT allowed in JSON.

JairoMartinezA commented 1 month ago

Correct Alex,

After I deleted the comments in that file, the error is no longer present.

Alexey-T commented 1 month ago

And how can I repro the error?

JairoMartinezA commented 1 month ago

The error is with your default.json file. I just downloaded the latest sources and created a new executable version, and voila, the error appears. Maybe it only happens with the MacOS build.

Alexey-T commented 1 month ago

Error appears just on app start? on clean app (no additional plugs)? or should user call Options Editor Lite plugin (which uses cudaxlib API)?

JairoMartinezA commented 1 month ago

Alex, I have re-downloaded the default.json content from GH, and now the error is gone. I was able to recover a previous version (the wrong version), and with this version, the error is present. However, I don't think it's necessary to waste time on this. I compared both versions, and there are some differences.

BUT NOW ALL IS OK AGAIN.

BothFiles.zip

Alexey-T commented 1 month ago

Ok, but I still cannot guess what is wrong with BothFiles.zip files. 2 json files have comments.

JairoMartinezA commented 1 month ago

The guilty value is:

Current Version

//Regular expression, which finds hyperlinks.
"links_regex": "\\b(mailto:)?\\w[\\w\\-\\+\\.]*@\\w[\\w\\-\\.]*\\.\\w{2,}\\b|\\b(https?://|ftp://)\\w[\\w\\-\\.@]*(:\\d+)?(/([~\\w\\.\\-\\+\\/%@!%:]|\\(.*?\\))*)?(\\?\\S*[\\w/\\-\\+])?(\\#[\\w\\-\\./%:!]*)?",

Wrong version

//Regular expression, which finds hyperlinks.
"links_regex": "\\b(mailto:)?\\w[\\w\\-\\+\\.]*@\\w[\\w\\-\\.]*\\.\\w{2,}\\b|\\b(https?://|ftp://)\\w[\\w\\-\\.@]*(:\\d+)?(/([~\w\.\-\+\/%@!%:&\*=\(\)\[\]\{\}\|,;'\"`\$]|\\(.*?\\))*)?(\\?\\S*[\\w/\\-\\+])?(\\#[\\w\\-\\./%:!]*)?",
Alexey-T commented 1 month ago

Hm? they are both OK, I don't see why one of these 2 values is wrong...

JairoMartinezA commented 1 month ago

After that character, one more backslash is added. I haven't really validated the expressions per se; I'm only reflecting the differences.

image

Alexey-T commented 1 month ago

Ah, now I see, yes it was the error.

Alexey-T commented 1 month ago

Wait, error in JSON is still in git. i will fix it ASAP.

Alexey-T commented 1 month ago

Fixed