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

Syntax validation and crash issue with error form #60

Closed
nicolasr75 opened this issue Apr 17, 2024 · 8 comments
Closed

Syntax validation and crash issue with error form #60

nicolasr75 opened this issue Apr 17, 2024 · 8 comments
Labels
bug Something isn't working question Further information is requested

Comments

@nicolasr75
Copy link

First of all thanks for this great plugin, a lot of useful functions!

I might be missing something but what I'm actually looking for is a simple syntax validation.
Background is this: some of the users of my software need to edit JSON content. I recommended them to use Notepad++ with the JSON Tools plugin. They should edit their JSON in Notepad++ and afterwards copy it to my software. The question is: how could they perform a syntax check before that? Opening the JSON tree viewer will check for errors but is there a more direct way to do it?

The function "See most recent syntax errors..." seems to keep previous errors even if they have been resolved.

@molsonkiko
Copy link
Owner

molsonkiko commented Apr 17, 2024

Have you tried automatically checking for errors after editing (auto_validate setting)? I regard that feature as somewhat experimental because it uses a second thread and thus opens the potential for race conditions, but I've had that feature turned on continuously for the past month or so, and I haven't noticed any weird behavior.

You may also wish to make the parser very strict so it doesn't tolerate any errors according to the original JSON specification. To do that, you can set the logger_level setting to STRICT. By default the parser is somewhat lax, and it doesn't flag certain classes of common errors that some parsers may tolerate.

If you don't need automatic syntax validation, and you just want to be able to easily re-validate the document on demand, you can open the error form, click the form, and press Enter to re-validate the document.

I strongly recommend installing v7.1 if you haven't already done so. It sounds like you're using a pretty old version of the plugin.

@molsonkiko molsonkiko added the question Further information is requested label Apr 17, 2024
@nicolasr75
Copy link
Author

Thanks for the quick respone. You are right, I was on 6.1. The problem was that Notepad++ itself needed an update to provide me the newest version of Json Tools. Now I'm on 7.1

Using the error form and re-validate with Enter seems to work for me. The XML Tools plugin has a menu item "Check XML syntax now" which to me seems a little more intuitive than having to remember selecting the form and pressing Enter.

A different problem is, however, that bringing up the error form after confirming the message box crashes Notepad++ for me. Maybe it's the race condition you were talking about. I will do some more tests and post another issue about that.

@molsonkiko
Copy link
Owner

molsonkiko commented Apr 18, 2024

A different problem is, however, that bringing up the error form after confirming the message box crashes Notepad++ for me.

Thank you for pointing that out! I never noticed this crash bug before, or I certainly would not have released version 7.1 without fixing it.

I believe I have fixed this issue with my most recent commit. You might try downloading this github actions artifact to see if that fixes your issue. I would like to release a fix to the plugin manager as soon as I am confident that the issue is really fixed.

The XML Tools plugin has a menu item "Check XML syntax now" which to me seems a little more intuitive than having to remember selecting the form and pressing Enter.

I agree, and my new commit has a new syntax-checking command to address this complaint.

@molsonkiko molsonkiko added the bug Something isn't working label Apr 18, 2024
@molsonkiko molsonkiko changed the title Syntax validation Syntax validation and crash issue with error form Apr 18, 2024
@nicolasr75
Copy link
Author

Thanks so much, that new function is really helpful.

I somehow can't get the error box to automatically appear. But I had this problem already with 7.1. auto_validate is set to true and offer_to_show_lint too. I see in the status bar that the validation is happening with the correct delay but the message box doesn't appear.

Regarding the crash:
if I explicitly check the syntax, it displays the error box and opening the error form does not produce a crash anymore.
Tested it about ten times with and without restart of Notepad++.

@molsonkiko
Copy link
Owner

Thanks for testing! I'm glad you're not seeing the crashes anymore.

I somehow can't get the error box to automatically appear. But I had this problem already with 7.1. auto_validate is set to true and offer_to_show_lint too. I see in the status bar that the validation is happening with the correct delay but the message box doesn't appear.

Yes, I couldn't figure out how to keep Notepad++ from crashing if the error form was opened from a message box that came from the automatic validation, so I made it so that the automatic validation can't create that message box. Sorry.

It is possible to avoid this issue, but the only way I know of involves creating an empty invisible form when JsonTools first starts up (for reasons I don't want to get into, it's weird C# stuff). I've tried that approach, and the form briefly appearing and flashing out of view when Notepad++ starts is annoying and noticeably slows down startup time, so unless I can come up with a less irritating solution, I will keep that feature removed.

@nicolasr75
Copy link
Author

It's fine for me :-) Bringing up message boxes during typing reminds me of the Excel VBA editor that pops up message boxes complaining about syntax errors and makes me yell back "Yeah, I know it's wrong, I'm not yet done!!!" ;-)
The status bar is a good way to keep it a little bit less "aggressive".

@molsonkiko
Copy link
Owner

@nicolasr75
Based on your feedback and my own testing, I believe this is fixed in JsonTools v7.2, which should be in the next release of the Notepad++ plugin list. If nobody else replies to this issue in the next couple weeks, I will assume this issue is fixed and close it.

Thanks again for your help!

@molsonkiko
Copy link
Owner

molsonkiko commented May 16, 2024

It's been a week since Notepad++ 8.6.6 went live with JsonTools 7.2 in the plugin manager, and nobody's reported that this issue still exists, so I'm declaring it fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants