emacs-lsp / lsp-ui

UI integrations for lsp-mode
https://emacs-lsp.github.io/lsp-ui
GNU General Public License v3.0
1.03k stars 141 forks source link

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

Closed erikarvstedt closed 1 year ago

erikarvstedt commented 1 year ago

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 commented 1 year ago

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

yyoncho commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

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

erikarvstedt commented 1 year ago

Alright, then this PR can be merged.

yyoncho commented 1 year ago

Alright, then this PR can be merged.

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

erikarvstedt commented 1 year ago

Fixed.