zulip-terminal icon indicating copy to clipboard operation
zulip-terminal copied to clipboard

Add support for copying code snippets

Open rsashank opened this issue 1 year ago • 5 comments

What does this PR do, and why?

Introduces the ability to copy code snippets, building upon the groundwork laid by @yuktasarode, @kingjuno, and @neiljp in previous pull requests: #1134 #1353.

This PR incorporates feedback from earlier pull requests. It introduces the k keybinding for copying code from a Message Information Popup. This PR also resolves the previous issue of a flashing cursor on the button.

Additionally, it includes a minor refactoring in copy_to_clipboard to address return carriage differences in WSL.

External discussion & connections

  • [x] Discussed in #zulip-terminal in Copy code snippets #T1353 #T1134 (fix #T1123)
  • [x] Fully fixes #1123
  • [ ] Partially fixes issue #
  • [x] Builds upon previous unmerged work in PR #1353
  • [ ] Is a follow-up to work in PR #
  • [ ] Requires merge of PR #
  • [ ] Merge will enable work on #

How did you test this?

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

Self-review checklist for each commit

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

https://github.com/zulip/zulip-terminal/assets/110327345/91606268-c1d9-46d8-b6d0-43d9e50deb66

rsashank avatar Dec 25 '23 20:12 rsashank

I removed the expected_code_width parameter from the test_create_code_snippet_buttons test. The expected width of code snippets seems to vary across different versions of Ubuntu and MacOS.

Should I reintroduce the test with platform-specific expected code widths, or is it acceptable to leave it removed?

rsashank avatar Dec 25 '23 21:12 rsashank

@zulipbot add "PR needs review"

rsashank avatar Dec 25 '23 21:12 rsashank

Updated this PR :) @zulipbot add "PR needs review"

rsashank avatar Apr 14 '24 09:04 rsashank

ERROR: Label "PR needs review" already exists and was thus not added to this pull request.

zulipbot avatar Apr 14 '24 09:04 zulipbot

Thanks for the detailed feedback @Niloth-p!

I've updated the PR. I still need to figure out where the language data was tagged in the previous version of Zulip markup, but I believe everything else should be addressed now. :)

rsashank avatar Jun 05 '24 08:06 rsashank