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

Open
opened 2026-01-31 07:54:26 +00:00 by claunia · 0 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:27 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21770