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: Do not call cider-docstring fns unless we have a doc #3764

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

Conversation

vedang
Copy link
Contributor

@vedang vedang commented Dec 18, 2024

Sometimes, there is no "doc" attribute in the nrepl-dict. In such cases, fetched-doc is nil, which causes cider-docstring--* functions to error.

We should only call these functions when we have a docstring to render.

Fixes: #3763

Replace this placeholder text with a summary of the changes in your PR.
The more detailed you are, the better.


Before submitting the PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):

  • The commits are consistent with our contribution guidelines
  • [-] You've added tests (if possible) to cover your change(s)
  • [-] All tests are passing (eldev test)
  • [-] All code passes the linter (eldev lint) which is based on elisp-lint and includes
  • [-] You've updated the changelog (if adding/changing user-visible functionality)
  • [-] You've updated the user manual (if adding/changing user-visible functionality)

Thanks!

Sometimes, there is no "doc" attribute in the nrepl-dict. In such
cases, `fetched-doc` is nil, which causes `cider-docstring--*`
functions to error.

We should only call these functions when we have a docstring to
render.

Fixes: clojure-emacs#3763
Copy link
Member

@vemv vemv left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

(if compact
(cider-docstring--trim
(cider-docstring--format fetched-doc))
fetched-doc))
(unless compact
Copy link
Member

Choose a reason for hiding this comment

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

Btw, this unless looks weird to me. Shouldn't this also check fetched-doc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding of the code is:

  1. Return rendered-fragments if we already have them
  2. Else return the fetched-doc (handle optional compact flag, depending on where the doc is being rendered)
  3. Else return "Not documented" for when we are rendering in Help buffer, or return nothing if rendering an e.g. completion popup.

Only code-path 2 deals with fetched-doc. Others don't.

Copy link
Member

Choose a reason for hiding this comment

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

This part I get - I'm just confused how can a check about compact be related to the presence or absence of a docstring. I know it's not directly related to your PR - it's just something that looks wrong to me, so I thought I should mention it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the caller is asking for a compact docstring, and no docstring exists, return nil. If the caller is asking for an "expanded" docstring, and no docstring exists, return "not documented".

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, yeah - I get this part. I was just wondering why "not documented" is not a good option in both cases. Anyways, not a big deal.

@bbatsov
Copy link
Member

bbatsov commented Dec 22, 2024

Just add a changelog for your bigfix and we're good go.

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.

Completion Popup causes cider-docview-render to error when symbol being completed does not have a docstring.
3 participants