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

Leading tabs in pasted text can be interpreted as tab-completion instead of tab character (\t) #17322

Closed
helpimnotdrowning opened this issue May 25, 2024 · 4 comments
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Resolution-External For issues that are outside this codebase

Comments

@helpimnotdrowning
Copy link

Windows Terminal version

1.21.1272.0

Windows build number

10.0.26120.0

Other Software

Powershell 7.4.2 (Windows and Linux)
Clink (for CMD) 1.6.13.eb61b2
SSH server OpenSSH_9.2p1 Debian-2+deb12u2, OpenSSL 3.0.11 19 Sep 2023
SSH client OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2

Steps to reproduce

Paste the following text into a shell (pwsh, cmd, linux pwsh/ssh, NOT cygwin bash, linux bash/ssh):

class A {
	$x
	$y
}

ls | % {
	[A]@{
		x = $_
	}
}

Expected Behavior

The following text to appear in the shell:
image
image
(4 space characters were used in place of tabs when pasting for these examples)

Actual Behavior

Tab characters are interpreted (but the 1st one per line is ignored, running tab-completion, instead of pasting the real tab (\t)
image
Note how the tabs in the class definition have dissapeared, turning the code from

class A {
	$x
	$y
}

into

class A {
$x
$y
}

The first tab is ignored in these lines, but the functionality does not change since only the whitespace was deleted.
However, with the second part,

ls | % {
	[A]@{
		x = $_
	}
}

becomes

ls | % {
[A]@{
yx = $_
x}
}

Once again, the first tab is ignored, but now the functionality has changed: the second tab in line 2 was interpreted as tab-completion, turning the line x = $_ into yx = $_ and line 3's } into x}

Instead of normal operation,
image

it instead errors out.
image

Powershell/linux over ssh also tab-completes in a similar way:
image

Similarly for cmd,
image
where .android/ and .cache./ are the 1st and 2nd directories in my ~; here, the 1st tab is not ignored and is used for tab-completion

--

cygwin bash works as expected:
image

, as does bash/linux over ssh:
image

@helpimnotdrowning helpimnotdrowning 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 May 25, 2024
Copy link

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@helpimnotdrowning helpimnotdrowning changed the title Weird behavior when pasting lines with leading tab (\t) Leading tabs in pasted text can be interpreted as tab-completion instead of tab character (\t) May 25, 2024
@lhecker
Copy link
Member

lhecker commented May 27, 2024

There's no difference between your tab key and tab character. When you press the tab key it simply emits a \t to the shell. But PSReadLine can technically differentiate between a paste from the clipboard and manual typing by parsing the bracketed paste sequence: PowerShell/PSReadLine#1471
For some reason though, that doesn't seem to work for tabs. I think we can consider that a PSReadLine issue.

@carlos-zamora
Copy link
Member

Thanks for filing! As Leonard mentioned above, we're gonna mark this as /dup of PowerShell/PSReadLine#1471

Copy link
Contributor

Hi! We've identified this issue as a duplicate of one that exists on somebody else's Issue Tracker. Please make sure you subscribe to the referenced external issue for future updates. Thanks for your report!

@microsoft-github-policy-service microsoft-github-policy-service bot added Resolution-External For issues that are outside this codebase and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels May 29, 2024
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-External For issues that are outside this codebase
Projects
None yet
Development

No branches or pull requests

3 participants