Skip to content

LS Config Editor allows saving invalid json #668

Closed

Description

@fbricon

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

Image

Activity

  1. added
    bug
    on Dec 6, 2024
  2. angelozerr commented on Dec 6, 2024

    @angelozerr
    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?

  3. SCWells72 commented on Dec 6, 2024

    @SCWells72
    Contributor

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    UIbuguser-defined LS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions