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

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### Bugs fixed

- [#3763](https://github.com/clojure-emacs/cider/issues/3763): Fix `cider-docview-render` completion popup error when symbol being completed does not have a docstring.

## 1.16.1 (2024-12-03)

### Changes
Expand Down
9 changes: 5 additions & 4 deletions cider-doc.el
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,11 @@ in a COMPACT format is specified, FOR-TOOLTIP if specified."
"doc-first-sentence-fragments" (nrepl-dict-get info "doc-first-sentence-fragments"))))
(fetched-doc (nrepl-dict-get info "doc"))
(doc (or rendered-fragments
(if compact
(cider-docstring--trim
(cider-docstring--format fetched-doc))
fetched-doc)
(when fetched-doc
(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.

"Not documented.")))
(url (nrepl-dict-get info "url"))
Expand Down
Loading