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

Allow clients to specify code action arguments where nil values should be treated as :json-false #4194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

robbert-vdh
Copy link
Contributor

This lets us fix #4184 by selectively changing nil code action argument values to :json-false. Once this is merged, HLS needs to set the field to '(:withSig) (and possibly some other values).

Some possible alternatives to this would be to:

  1. Turn boolean-action-arguments into an alist that matches (part of) the command's name. This needs to support partial matches because HLS includes a plugin ID in the command name, and these are not guaranteed to stay constant.
  2. Have it take a function instead, and implement the patching on the client level. This is more flexible, but I don't think the extra generalization is needed. At least not for now.

Supersedes #4191.

@robbert-vdh robbert-vdh changed the title Add a new boolean-action-arguments client param Allow clients to specify code action arguments where nil values should be treated as :json-false Oct 14, 2023
lsp-mode.el Outdated
(lsp-put structure key :json-false)))
;; If `key' does not exist, then we'll silently ignore it
(when-let ((child (lsp-get structure key)))
(lsp--fix-nested-boolean child rest))))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with elisp and its data structures, so maybe there's an existing/better combinator for doing deep queries/updates in nested hash tables.

This lets us fix emacs-lsp#4184 by selectively changing `nil` code action
argument values to `:json-false`. Once this is merged, HLS needs to set
the field to `'(:withSig)` (and possibly some other values).
@robbert-vdh robbert-vdh force-pushed the robbert-vdh/patch-boolean-action-values branch from 85d97a5 to 54b971e Compare October 30, 2023 09:06
@yyoncho
Copy link
Member

yyoncho commented Oct 30, 2023

Thank you for your PR. I would like the implementation to be changed a bit. In this PR the client is supposed to use some description of the fixes to be applied which may or may not cover all cases. (e. g. it may depend on more context and so on). So instead of having the logic here in lsp-mode I would like to be pushed into the client. That can happen if lsp-mode receives a function from the client and then only applies it to the result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parsing and encoding JSON booleans doesn't roundtrip correctly for code actions
2 participants