# editor: Limit \`CopyHighlightJson\` to selection \(\#46555\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 361428a4509b060079f3863d02e519245490677f

Requested commit: 361428a4509b060079f3863d02e519245490677f

Commit: 361428a4509b060079f3863d02e519245490677f

Tree: 5aac32d4ce6d3eae3cdcb92e1ed50fd8f845f7cc

Author: Ian Chamberlain

Committer: GitHub

## Message

```
editor: Limit `CopyHighlightJson` to selection (#46555)

Closes https://github.com/zed-industries/zed/issues/36618

I'm not sure if there is a specific issue for this, but I noticed it
while working on some other PRs, as have some other people:
https://github.com/zed-industries/zed/issues/20525#issuecomment-2469507157

Cause: when running `copy highlight JSON` from the command palette,
input was disabled due to the modal, and the selection method call
always returns `None`. This most likely works as expected when bound to
a keyboard shortcut, but since there is no default shortcut most people
probably don't execute this action that way.

Fix: just grab the selection directly; I don't think this command needs
to be IME-aware, so it doesn't need to use `selected_text_range`.

NOTE: There still seems to be an issue where `VISUAL LINE` mode doesn't
select anything, even when I called `selections.newest_adjusted`, so I
opted to try and keep the implementation closest to what it was doing
before. (edit: actually this might just be the same as #45799?).

Release Notes:

- Fixed `editor: copy highlight JSON` not limiting to the current
selection
```

## Parents

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

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