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

Closed
opened 2026-01-31 07:54:29 +00:00 by claunia · 4 comments
Owner

Originally created by @helpimnotdrowning on GitHub (May 25, 2024).

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

Originally created by @helpimnotdrowning on GitHub (May 25, 2024). ### 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): ```pwsh class A { $x $y } ls | % { [A]@{ x = $_ } } ``` ### Expected Behavior The following text to appear in the shell: ![image](https://github.com/microsoft/terminal/assets/35247379/4f4d1bfe-8017-429c-a486-60a46f5ab546) ![image](https://github.com/microsoft/terminal/assets/35247379/44c0421a-0d28-403c-8ebb-52c8788a3a94) (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](https://github.com/microsoft/terminal/assets/35247379/d6d66c34-f5e6-4fed-bfd0-c993daab9455) Note how the tabs in the class definition have dissapeared, turning the code from ```pwsh class A { $x $y } ``` into ```pwsh 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, ```pwsh ls | % { [A]@{ x = $_ } } ``` becomes ```pwsh 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](https://github.com/microsoft/terminal/assets/35247379/2c219502-7b44-4d00-9165-94e59255c09d) it instead errors out. ![image](https://github.com/microsoft/terminal/assets/35247379/abbd5b17-5eed-4ef1-b56e-6d6075e6c4ec) Powershell/linux over ssh also tab-completes in a similar way: ![image](https://github.com/microsoft/terminal/assets/35247379/ad937388-66b0-4227-b1a5-20b1b8a160a8) Similarly for cmd, ![image](https://github.com/microsoft/terminal/assets/35247379/2a1b08ea-44a0-42e5-bcd8-fc73e4fede31) 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](https://github.com/microsoft/terminal/assets/35247379/971ac520-d31b-4e28-ad35-99eeb3b7a2b8) , as does bash/linux over ssh: ![image](https://github.com/microsoft/terminal/assets/35247379/85cb7a94-2e72-444d-afc0-060839a54218)
claunia added the Issue-BugResolution-External labels 2026-01-31 07:54:30 +00:00
Author
Owner

@github-actions[bot] commented on GitHub (May 25, 2024):

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.

@github-actions[bot] commented on GitHub (May 25, 2024): 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: - [Strip or replace tabs when pasting (#6134)](https://github.com/microsoft/terminal/issues/6134), similarity score: 0.81 > Note: You can give me feedback by thumbs upping or thumbs downing this comment.
Author
Owner

@lhecker commented on GitHub (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: https://github.com/PowerShell/PSReadLine/issues/1471
For some reason though, that doesn't seem to work for tabs. I think we can consider that a PSReadLine issue.

@lhecker commented on GitHub (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: https://github.com/PowerShell/PSReadLine/issues/1471 For some reason though, that doesn't seem to work for tabs. I think we can consider that a PSReadLine issue.
Author
Owner

@carlos-zamora commented on GitHub (May 29, 2024):

Thanks for filing! As Leonard mentioned above, we're gonna mark this as /dup of https://github.com/PowerShell/PSReadLine/issues/1471

@carlos-zamora commented on GitHub (May 29, 2024): Thanks for filing! As Leonard mentioned above, we're gonna mark this as /dup of https://github.com/PowerShell/PSReadLine/issues/1471
Author
Owner

@microsoft-github-policy-service[bot] commented on GitHub (May 29, 2024):

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[bot] commented on GitHub (May 29, 2024): 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! <!-- Policy app identification https://img.shields.io/static/v1?label=PullRequestIssueManagement. -->
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21773