Skip to content

Conversation

kyu08
Copy link
Contributor

@kyu08 kyu08 commented Aug 10, 2025

PR Description

Sometimes, I want to copy the error message to clipboard to search google or ask to LLM about the error message.

So I added CopyToClipboard command to ConfirmationController and I have confirmed that this command copies the content of the window to the clipboard.

image

Please check if the PR fulfills these requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

@kyu08 kyu08 marked this pull request as ready for review August 10, 2025 10:51
@kyu08 kyu08 force-pushed the copy-confirmation-text branch from e927974 to c544f39 Compare August 11, 2025 12:18
@stefanhaller stefanhaller added the enhancement New feature or request label Aug 11, 2025
@stefanhaller
Copy link
Collaborator

Nice, seems useful.

Two things:

  • there's no feedback when pressing the key; usually we show a toast in the status line, but apparently toasts are suppressed when a popup is showing? Would have to investigate why, or if it's possible to change that.
  • I feel the <c-o> keybinding should not be between enter and esc, but to the right of esc, which is by far the more important key to know about. However, then it ends up between the two esc bindings, so that would have to be solved first.

@kyu08
Copy link
Contributor Author

kyu08 commented Aug 11, 2025

Thanks for the feedback!

  • there's no feedback when pressing the key; usually we show a toast in the status line, but apparently toasts are suppressed when a popup is showing? Would have to investigate why, or if it's possible to change that.

I'll look into it.

  • I feel the keybinding should not be between enter and esc, but to the right of esc, which is by far the more important key to know about.

That's right! This is fixed in e7505c4.
EDIT: I squashed this change into 8ee1f35 when I rebased onto master.

However, then it ends up between the two esc bindings, so that would have to be solved first.

So how about adding an implementation like this first, then merging this PR, and then deleting unnecessary key bindings?

@kyu08
Copy link
Contributor Author

kyu08 commented Aug 11, 2025

  • there's no feedback when pressing the key; usually we show a toast in the status line, but apparently toasts are suppressed when a popup is showing? Would have to investigate why, or if it's possible to change that.

I found the cause. self.c.OS().CopyToClipboard(text) does not simply call the Toast() method .
So it might be fine to just call it in the Handler.
Fixed in 494edfc.
EDIT: I squashed this change into 8ee1f35 when I rebased onto master.

@kyu08 kyu08 force-pushed the copy-confirmation-text branch 2 times, most recently from f60838c to 494edfc Compare August 11, 2025 14:43
@kyu08
Copy link
Contributor Author

kyu08 commented Aug 12, 2025

After merging #4819, I will reopen this PR.

@kyu08 kyu08 marked this pull request as draft August 12, 2025 15:19
@kyu08 kyu08 force-pushed the copy-confirmation-text branch 2 times, most recently from da55e1f to e74f515 Compare August 15, 2025 00:06
@kyu08
Copy link
Contributor Author

kyu08 commented Aug 15, 2025

@stefanhaller
I have rebased onto master and I have confirmed that the key bindings line looks okay.
 2025-08-15 at 9 00 32

And this is a message when <c-o> is pressed.
 2025-08-15 at 9 12 33

I used Popup panel content because this ui element is called PopupPanel in the source code and I thought this term would be easy for users to understand as well.

@kyu08 kyu08 marked this pull request as ready for review August 15, 2025 00:19
@stefanhaller stefanhaller force-pushed the copy-confirmation-text branch from e74f515 to 196e5bf Compare August 15, 2025 09:16
Copy link
Collaborator

@stefanhaller stefanhaller left a comment

Choose a reason for hiding this comment

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

Nice, looks mostly good. I added a fixup to disable the command for editable prompts (e.g. new branch name); while it would technically be possible to copy the branch name that you just typed, I don't think this is the intended use, and I'd rather not see the extra keybinding appear in the status bar in this case.

Also took that opportunity to move the handler to a method.

Finally, I added another fixup to add an integration test.

I hope you don't mind my changing your PRs so much, but for me this is a more efficient way of working than to tell you what I would like to see changed.

return err
}

self.c.Toast(fmt.Sprintf("Window content %s", self.c.Tr.CopiedToClipboard))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be i18n'ed too. I added 79f1d7c to do this. We can't use the existing Tr.CopiedToClipboard text here, this is only for hashes or branch names etc., so we need to add a new text for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hope you don't mind my changing your PRs so much, but for me this is a more efficient way of working than to tell you what I would like to see changed.

Thank you for your thoughtful consideration.
It's totally fine for me.

Your support actually helped make the code much better. Thank you so much. And your changes looks good to me too.

stefanhaller and others added 3 commits August 15, 2025 17:17
This was needed in an earlier version of the test, when we asserted the file
content in a more complicated way. It should have been removed in caca62b.
@stefanhaller stefanhaller force-pushed the copy-confirmation-text branch from 196e5bf to fc84b77 Compare August 15, 2025 15:17
@stefanhaller stefanhaller enabled auto-merge August 15, 2025 15:17
@stefanhaller stefanhaller merged commit 011ff85 into jesseduffield:master Aug 15, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants