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

LS Config Editor allows saving invalid json #668

Open
fbricon opened this issue Dec 6, 2024 · 2 comments
Open

LS Config Editor allows saving invalid json #668

fbricon opened this issue Dec 6, 2024 · 2 comments
Labels
bug Something isn't working UI user-defined LS

Comments

@fbricon
Copy link
Contributor

fbricon commented Dec 6, 2024

If you write some invalid json in the LS config editor, the error is shown, but the configuration can still be applied/saved:

Image

@fbricon fbricon added bug Something isn't working UI user-defined LS labels Dec 6, 2024
@angelozerr
Copy link
Contributor

To support validation correctly, we should have a "master" which shows a list of errors (one for Server Configuration, one for Client Configuration, etc) and have a link which select the proper tab and the proper UI widget.

We should disable also the Save action.

@SCWells72 have you some idea how to implement that?

@SCWells72
Copy link
Contributor

SCWells72 commented Dec 6, 2024

@SCWells72 have you some idea how to implement that?

When that happens in the context of a Configurable, the apply() method can throw ConfigurationException if there are issues with the configuration to be applied. So, for example, LanguageServerConfigurable#apply() should ask its consistituent components to validate themselves. Since these same components are used in the tool window, the save action could take the same approach, catching a thrown ConfigurationException and highlighting the errant component, in this case, the JsonTextField that contains invalid JSON.

UPDATE: I forgot that ConfigurationException doesn't know about the specific JComponent for which a validation error was raised. That's DialogWrapper#doValidateAll(). But the same concept holds of having each major panel perform its own validation, and have the larger tabbed panel collect validation errors from the contained panels and show them if present instead of saving, or in the case of LanguageServerConfigurable, it would throw a ConfigurationException with the validation errors.

Let me know if that doesn't make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working UI user-defined LS
Projects
None yet
Development

No branches or pull requests

3 participants