Skip to content

editor: Limit CopyHighlightJson to selection#46555

Merged
SomeoneToIgnore merged 6 commits intozed-industries:mainfrom
ian-h-chamberlain:fix/copy-highlight-json-selection
Mar 31, 2026
Merged

editor: Limit CopyHighlightJson to selection#46555
SomeoneToIgnore merged 6 commits intozed-industries:mainfrom
ian-h-chamberlain:fix/copy-highlight-json-selection

Conversation

@ian-h-chamberlain
Copy link
Copy Markdown
Contributor

@ian-h-chamberlain ian-h-chamberlain commented Jan 11, 2026

Closes #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: #20525 (comment)

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

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 11, 2026
@zed-industries-bot
Copy link
Copy Markdown
Contributor

zed-industries-bot commented Jan 11, 2026

Messages
📖

This PR includes links to the following GitHub Issues: #20525
If this PR aims to close an issue, please include a Closes #ISSUE line at the top of the PR body.

Generated by 🚫 dangerJS against 0fd1235

@maxdeviant maxdeviant changed the title Fix: limit "copy highlight JSON" to selection Limit "copy highlight JSON" to selection Jan 11, 2026
@ian-h-chamberlain ian-h-chamberlain force-pushed the fix/copy-highlight-json-selection branch from e7b066d to 8d05f4d Compare January 12, 2026 03:03
@ian-h-chamberlain ian-h-chamberlain force-pushed the fix/copy-highlight-json-selection branch from 8d05f4d to 7fd0ea0 Compare February 1, 2026 05:28
@ian-h-chamberlain ian-h-chamberlain force-pushed the fix/copy-highlight-json-selection branch from 7fd0ea0 to defd403 Compare March 3, 2026 06:46
@SomeoneToIgnore
Copy link
Copy Markdown
Contributor

Passing by and noticing that this lacks any testing at all which most probably does not help to get this reviewed.

@SomeoneToIgnore SomeoneToIgnore self-assigned this Mar 24, 2026
@MrSubidubi MrSubidubi changed the title Limit "copy highlight JSON" to selection editor: Limit CopyHighlightJson to selection Mar 27, 2026
The final line of selection wasn't always included, depending how chunks were
laid out. We just needed to push a final line if any of its chunks are
non-empty.
@ian-h-chamberlain
Copy link
Copy Markdown
Contributor Author

Passing by and noticing that this lacks any testing at all which most probably does not help to get this reviewed.

Good point, it took me a while to figure out the best way to write tests against this feature but I think what I've got now should help!

Copy link
Copy Markdown
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Thank you, looks really nice overall, one small thing to clear and we're ready to merge.

Copy link
Copy Markdown
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Nice, thank you for the simplification!

@SomeoneToIgnore SomeoneToIgnore enabled auto-merge (squash) March 31, 2026 08:32
@SomeoneToIgnore SomeoneToIgnore merged commit 361428a into zed-industries:main Mar 31, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hightlighting text to copy into the Linux primary clipboard truncates or includes too many characters

4 participants