cosmic-term icon indicating copy to clipboard operation
cosmic-term copied to clipboard

Ctrl+C stops working when text is selected in the terminal

Open man0lis opened this issue 1 year ago • 15 comments

Steps to reproduce:

  • mark some text in the terminal
  • hit ctrl+c

As long as text is selected, the running program will not receive the SIGINT signal which ctrl+c should be sending.

man0lis avatar Jul 02 '24 20:07 man0lis

Intentional behavior, see: https://github.com/pop-os/cosmic-term/pull/195

leviport avatar Jul 02 '24 21:07 leviport

I thought almost every terminal uses Shift+Ctrl+C for copy specifically because Ctrl+C has a special meaning in terminals. Very strange decision to not make this configurable, since most other terminals do not behave this way. I guess I will use another terminal then.

man0lis avatar Jul 02 '24 21:07 man0lis

You can also Ctrl+Shift+C, but the terminal is smart enough to infer intent to copy when text is selected.

mmstick avatar Jul 02 '24 21:07 mmstick

I was wondering about that. Why have the Ctrl+Shift+C shortcut in the first place. To copy specific text you have to select the text, so the terminal will always allow using Ctrl+C for copying.

But why I opened the issue in the first place, and why i still think this is a bug/should to be configurable:

Imagin the follwoing: you mark something to copy it. Then run a command, but realize it is wrong and is destroying data. What do you do? You hit the emergency stop (Ctrl+C), but because the selection was made previously you can't abort the process. The seconds it takes to realize what is happening and fixing it will destroy more data. The problem is even bigger because the "smart" copy thinks that marked text that is not even on screen anymore or was marked hours ago is intended for copying and thus disables Ctrl+C.

Because for most people Ctrl+C is kind of an emergency stop which should never be blocked, I kindly ask to reconsider making this feature optional.

Or if inferring intent is the goal here, maybe copy with the first input of Ctrl+C and reenable normal Ctrl+C behaviour for the next input. This way a user that hits Ctrl+C multiple times in panic first gets a copy and then a SIGINT.

Or the selection could be cleared if the user types a new command.

man0lis avatar Jul 02 '24 21:07 man0lis

You can remove text selection branch and compile yourself.

https://github.com/pop-os/cosmic-term/blob/0fcf6b4e74637395542058b505b848cf88b9b403/src/main.rs#L1787-L1789

The problem is even bigger because the "smart" copy thinks that marked text that is not even on screen anymore or was marked hours ago is intended for copying and thus disables Ctrl+C.

drwpls avatar Aug 27 '24 02:08 drwpls

I am reopening for discussion on making this feature configurable or "smarter"

jackpot51 avatar Oct 08 '24 13:10 jackpot51

I am reopening for discussion on making this feature configurable or "smarter"

st like this? image

@leviport said that's intentional behavior, what's changed? I'm Alacritty user and it doesn't have smart Ctrl-C, I think you should disable it by default (I had trouble making Interrupt work before seeing this issue).

drwpls avatar Oct 09 '24 02:10 drwpls

Please consider adding an option to disable this.

I've used a lot of terminals and this is the first time I've seen this feature. I suspect that for most users this is more of a bug than a feature, as I am not aware of a single terminal that has this enabled by default.

allddd avatar Dec 27 '24 08:12 allddd

https://github.com/pop-os/cosmic-term/pull/195#issuecomment-2091677370

This is a concerning mindset for a maintainer of this project to have.

If the behavior goes against how every single other existing terminal emulator behaves it shouldn't even be the default, let alone a feature without a toggle of any kind. I think the team working on cosmic-term should re-calibrate what their goals are for this program and what features require toggles.

sebastianrasor avatar Mar 13 '25 00:03 sebastianrasor

This behavior should be able to be disabled, and in my opinion it shouldn't be the default behavior. Are there any reviews required for this or can I just submit a PR adding this option back?

sebastianrasor avatar Mar 13 '25 00:03 sebastianrasor

goes against how every single other existing terminal emulator behaves

Since i stumbled across this issue looking for a terminal with basically this feature, heres some other terminal emulators i know of which support this:

  • Kitty (with map ctrl+c copy_and_clear_or_interrupt)
  • WezTerm (example lua script for ClearSelection)
  • Windows Terminal (by default, and its somehow also the only terminal emulator i've ever used which just worked and had all the features i want)

laundmo avatar Mar 13 '25 20:03 laundmo

I have changed Ctrl+C to clear the selection after copying, so another Ctrl+C will always interrupt. This should make it less of a problem for users who do not expect it.

@sebastianrasor Do not take https://github.com/pop-os/cosmic-term/pull/195#issuecomment-2091677370 out of context, that comment was specifically answering if the configurability was needed for the initial implementation. At the time, it was determined not to be needed, as we wanted to see what the response would be. This is the whole purpose of having a public alpha testing phase.

As you can see, I reopened this issue due to receiving feedback on the feature, and I plainly stated that we are open to having it be configurable in https://github.com/pop-os/cosmic-term/issues/236#issuecomment-2399915161. If someone is interested in implementing this feature, please open a PR.

Try to avoid insensitive comments such as those in https://github.com/pop-os/cosmic-term/issues/236#issuecomment-2719456873, I will not tolerate them and will potentially ban users who I feel are using abusive language.

jackpot51 avatar Mar 13 '25 20:03 jackpot51

@jackpot51 i just compiled the version with your Ctrl+C change and it works just as I'd expect, very nice! Now, hitting it twice will send SIGINT.

laundmo avatar Mar 13 '25 22:03 laundmo

All I want is for the open source software that I use to be open to improvement. I appreciate that you have now made it clear that the team is open to a PR to implement this configuration option.

sebastianrasor avatar Mar 13 '25 23:03 sebastianrasor

goes against how every single other existing terminal emulator behaves

Since i stumbled across this issue looking for a terminal with basically this feature, heres some other terminal emulators i know of which support this:

  • Kitty (with map ctrl+c copy_and_clear_or_interrupt)
  • WezTerm (example lua script for ClearSelection)
  • Windows Terminal (by default, and its somehow also the only terminal emulator i've ever used which just worked and had all the features i want)

That's a fair point, I should have said "the majority of other existing terminal emulators."

I also should have clarified that I meant the default behavior of the majority of other existing terminal emulators, because cosmic-term is the very first terminal emulator that I have ever used that has this behavior enabled by default.

I'd like to clarify that I'm not saying that I don't think this behavior shouldn't be an option for those who want it. I only think that users should be able to turn this behavior off and that this behavior should not be the default behavior, as it is a pretty noticeable change from the default behavior of (almost) all other terminal emulators.

sebastianrasor avatar Mar 13 '25 23:03 sebastianrasor