# hover_popover: Fix markdown selection for info and diagnostic popovers \(\#28642\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/b864a9b0ae633006a44c02b723fe6fad07e84b93)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: b864a9b0ae633006a44c02b723fe6fad07e84b93

Requested commit: b864a9b0ae633006a44c02b723fe6fad07e84b93

Commit: b864a9b0ae633006a44c02b723fe6fad07e84b93

Tree: 38b20d34c20be99be8d1a81ab432265e6b007469

Author: Smit Barmase

Committer: GitHub

## Message

```
hover_popover: Fix markdown selection for info and diagnostic popovers (#28642)

Closes #28638

This PR fixes markdown selection for the info and diagnostic popovers.

In the editor popover, after the changes in
https://github.com/zed-industries/zed/pull/28255, the markdown selection
state updates correctly, but it no longer triggers the editor element to
repaint like it used to. This is fixed by adding a subscription to
listen for markdown entity changes and triggering a repaint for the
editor.

I assume markdown selection works elsewhere because:

1. Either the `Markdown` entity is directly part of a struct that
implements the `Render` trait, causing it to repaint whenever the
markdown state changes. See
[here](https://github.com/zed-industries/zed/blob/d1ffda9bfeccfdf9bea3f76251350bf9cf7f6e1b/crates/ui_prompt/src/ui_prompt.rs#L65).
2. OR it's wrapped around component like Popover which implements
`RenderOnce` trait. See
[here](https://github.com/zed-industries/zed/blob/d1ffda9bfeccfdf9bea3f76251350bf9cf7f6e1b/crates/editor/src/code_context_menus.rs#L645).

Whereas info and diagnostic popovers does not do both. I do think we can
change it to use `Popover` component, but for now this works as quick
fix.

Extras:
- Remove unnecessary struct cloning.
- Refactor rendering logic to use `when_some`.

Release Notes:

- Fixed issue where selection wasn't working for info and diagnostic
popovers.
```

## Parents

- [e4844b281d52a181802bb800f19d74853469766a](https://git.cafe/gitcafe/zed/commit/e4844b281d52a181802bb800f19d74853469766a?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/b864a9b0ae633006a44c02b723fe6fad07e84b93?format=markdown)
