Skip to content

Conversation

Sushmey
Copy link
Collaborator

@Sushmey Sushmey commented Mar 30, 2023

What does this PR do, and why?

Copying a message using terminal selection does not work across multiple lines, as it also selects text in one or both of the side bars.

It would be useful to be able to copy selected message(s) independently of how the UI is set up.
This could be for quoting in another stream, or external to ZT.

Adding a key to copy message content which can be then pasted. Implemented using preexisting copy_to_clipboard function.

Outstanding aspect(s)

This seems to not work for quotes messages because of the nested list

Unsure as to how to navigate about specific cases like

External discussion & connections

  • Discussed in #zulip-terminal in topic
  • Fully fixes #
  • Partially fixes issue Message content copy[/paste] #546
  • Builds upon previous unmerged work in PR #
  • Is a follow-up to work in PR #
  • Requires merge of PR #
  • Merge will enable work on #

How did you test this?

  • Manually - Behavioral changes
  • Manually - Visual changes
  • Adapting existing automated tests
  • Adding automated tests for new behavior (or missing tests)
  • Existing automated tests should already cover this (only a refactor of tested code)

Self-review checklist for each commit

  • It is a minimal coherent idea
  • It has a commit summary following the documented style (title & body)
  • It has a commit summary describing the motivation and reasoning for the change
  • It individually passes linting and tests
  • It contains test additions for any new behavior
  • It flows clearly from a previous branch commit, and/or prepares for the next commit

Visual changes

asciicast

Adding a key to copy message content which can be then pasted. Implemented using preexisting `copy_to_clipboard` function

Fixes zulip#546
@zulipbot zulipbot added size: M [Automatic label added by zulipbot] GSoC Possible GSoC project component missing feature: user A missing feature for all users, present in another Zulip client labels Mar 30, 2023
@Sushmey
Copy link
Collaborator Author

Sushmey commented Mar 30, 2023

@zulipbot add "PR needs review"

@zulipbot zulipbot added the PR needs review PR requires feedback to proceed label Mar 30, 2023
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@Sushmey We've discussed this in the stream but I wanted to just read over what you'd done so far - though I understand the approach may change, things look fairly reasonable except for the extraction of the content 👍

Comment on lines +1685 to +1695
elif is_command_key("COPY_MESSAGE", key):
rendered_content, *_ = MessageBox.transform_content(
self.msg["content"], self.controller.model.server_url
)
content = []
for word in rendered_content[1]:
if isinstance(word, tuple): # if msg content has markup
content.append(word[1])
else:
content.append(word)
self.controller.copy_to_clipboard("".join(content), "Message Content")
Copy link
Collaborator

Choose a reason for hiding this comment

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

The principle here is just fine, but we do perform a few extra adjustments to content which may not follow the principles that you assume here.

That's likely what gave rise to the crash I reported in the stream.

Comment on lines +399 to +403
('COPY_MESSAGE', {
'keys': ['C'],
'help_text':
'Copy message content to clipboard',
'key_category': 'msg_actions',
Copy link
Collaborator

Choose a reason for hiding this comment

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

We've discussed this in the stream, but

  • c should not need capitalization, with some adjustment, if we stick with that hotkey, though key choice right now is not important
    • though note that we already have c for copying stream email address
    • plus we discussed something similar for the copy non-markdown content version
  • the help_text likely doesn't need to wrap? That's only been done for long lines
  • we may want the COPY_MESSAGE to be more meaningful if we have two versions :)

@neiljp neiljp added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback and removed PR needs review PR requires feedback to proceed labels Apr 18, 2023
@zulipbot
Copy link
Member

Heads up @Sushmey, we just merged some commits that conflict with the changes you made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the upstream/main branch and resolve your pull request's merge conflicts accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GSoC Possible GSoC project component has conflicts missing feature: user A missing feature for all users, present in another Zulip client PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback size: M [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants