Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting to tab title leaking to terminal input #16205

Closed
pszlazak opened this issue Oct 20, 2023 · 6 comments
Closed

Pasting to tab title leaking to terminal input #16205

pszlazak opened this issue Oct 20, 2023 · 6 comments
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@pszlazak
Copy link

Windows Terminal version

1.18.2822.0

Windows build number

10.0.22621.0

Other Software

N/A

Steps to reproduce

  • copy some text to the clipboard
  • paste it to tab tile using keyboard shortcut Ctrl+v

Expected Behavior

Clipboard content pasted only to tab title.

Actual Behavior

Clipboard content will be pasted to tab title and to terminal input as shown here: https://i.imgur.com/UlFcGNe.gif

Remark: if clipboard is pasted using right click and context menu, it works OK.

@pszlazak pszlazak added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Oct 20, 2023
@Shivansh20128
Copy link

Hi @pszlazak,
The issue you are talking about is not a bug but rather a feature to make things easier for developers. the behavior you described is due to a feature called "injection" in Windows Terminal. This feature allows you to paste text into the title bar and automatically sends that text to the command prompt as well. It's designed to make it convenient for users to rename the terminal while also executing a command.
As you said, if the clipboard is pasted using the right-click and context menu, it works fine.
However, if you want to use keyboard shortcut keys, here is a way to avoid pasting clipboard text at both places:

  1. Click on the down arrow in the title bar and select "Settings." You should be able to find a "Settings.json" file.
  2. Inside the file, you should be able to find
    {
    "command": "paste",
    "keys": "ctrl+v"
    }
    in the "actions" key.
  3. This setting defines the shortcut to paste inside the terminal. Since Windows also pastes the clipboard text using Ctrl+v, when some text is pasted into the terminal title using Ctrl+v, it gets pasted into the title due to Windows-defined settings as well as inside the terminal due to the setting defined in this "Settings.json" file.
  4. To avoid pasting text at both places, modify this file and change the shortcut key from "ctrl+v" to some other key combination that does not clash with any other shortcut keys.
  5. Save the file and close and open the terminal again.

You should now be able to paste the copied text into the terminal title using "ctrl+v" and into the terminal using the new key combination you defined in the "Settings.json" file.
Thank You

@pszlazak
Copy link
Author

If this is a feature it became present in v1.12.10334.0. Earlier it was not there. This is the first stable version of v1.12.
Previous released preview version v1.12.3472.0 still does not have this feature.

I don't see this feature being announced in release notes of v1.12.10334.0.

It was added by one of following commits: v1.12.3472.0...v1.12.10334.0

@DHowett
Copy link
Member

DHowett commented Oct 23, 2023

This feature allows you to paste text into the title bar and automatically sends that text to the command prompt as well. It's designed to make it convenient for users to rename the terminal while also executing a command.

We definitely don't do this on purpose. This is absolutely a bug (and a somewhat pernicious one, which keeps biting us because of the input architecture hole we dug ourselves into) and not a feature.

@Shivansh20128
Copy link

Okay. It may be a bug.
But I still feel that the current behavior is obvious because when we select the title, we are also selecting the whole terminal. And then when we press Ctrl+v, the text gets pasted in the title because of the default setting of the operating system, as well as inside the terminal because of the setting we have defined in the Settings.json file for the terminal.

@zadjii-msft
Copy link
Member

I'm certain this isn't by design. Pretty sure #14669 has a fix for this, which should be tracked in /dup #14381. Thanks!

@zadjii-msft zadjii-msft closed this as not planned Won't fix, can't repro, duplicate, stale Oct 24, 2023
@microsoft-github-policy-service
Copy link
Contributor

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@microsoft-github-policy-service microsoft-github-policy-service bot added Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
None yet
Development

No branches or pull requests

4 participants