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

Fix peek--get-references for lsp-use-plists #743

Merged
merged 1 commit into from Jan 16, 2023

Conversation

erikarvstedt
Copy link
Contributor

@erikarvstedt erikarvstedt commented Jan 16, 2023

This fixes lsp-ui-peek-find-definitions/references when lsp-use-plists is t and a single item is returned by the server.

Copy of commit msg

When lsp-use-plists is t, lsp-request returns a single plist (of form (:key val ...) or a list of plists.

Previously, when lsp-use-plists was t and a single plist was returned, the plist wasn't wrapped into a list, causing the subsequent code to fail.

@erikarvstedt
Copy link
Contributor Author

erikarvstedt commented Jan 16, 2023

@yyoncho, can lsp-request ever return a vector for methods textDocument/references or textDocument/definition?
If no, we can simplify the fixed fn.

@yyoncho
Copy link
Member

yyoncho commented Jan 16, 2023

@erikarvstedt the solution is usually to use seq methods to handle the cases when it is unclear whether the result is list or vector.

@erikarvstedt
Copy link
Contributor Author

erikarvstedt commented Jan 16, 2023

@yyoncho, using seq doesn't help in this specific case.

Which JSON objects in server responses are deserialised as vectors?
textDocument/{references,definition} will probably never return vectors as the top-level object, right?

@yyoncho
Copy link
Member

yyoncho commented Jan 16, 2023

@erikarvstedt vector is returned for json vectors when using native json deserialization. When it is not used - you get list.

@erikarvstedt
Copy link
Contributor Author

Alright, then this PR can be merged.

@yyoncho
Copy link
Member

yyoncho commented Jan 16, 2023

Alright, then this PR can be merged.

In general lsp-use-plists should not be used outside of lsp-protocol.el

@erikarvstedt
Copy link
Contributor Author

Fixed.

When `lsp-use-plists` is t, `lsp-request` returns a single plist
(of form (:key val ...) or a list of plists.

Previously, when `lsp-use-plists` was t and a single plist was returned,
the plist wasn't wrapped into a list, causing the subsequent code to
fail.
@yyoncho yyoncho merged commit 295d898 into emacs-lsp:master Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants