Pasting tab characters into the Terminal replaces these characters with the name of the first file in the working directory #12870

Closed
opened 2026-01-31 03:27:20 +00:00 by claunia · 14 comments
Owner

Originally created by @TautvydasZilys on GitHub (Mar 4, 2021).

Environment

Windows build number: Microsoft Windows [Version 10.0.19042.804]
Windows Terminal version (if applicable): 1.6.10571.0

Any other software? Terminal configured to use cmd.exe

Steps to reproduce

Copy paste this into the terminal:

	hello

Expected behavior

"hello" gets pasted into the terminal

Actual behavior

"hello" gets prepended with the first file in the directory: ".bash_historyhello"

I reproduced it on all machines I tried it on. It doesn't reproduce when using cmd.exe through the default windows conhost.exe. This issue is especially annoying when copy pasting stuff from websites as they like to contain "invisible" tabs.

Originally created by @TautvydasZilys on GitHub (Mar 4, 2021). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: Microsoft Windows [Version 10.0.19042.804] Windows Terminal version (if applicable): 1.6.10571.0 Any other software? Terminal configured to use cmd.exe ``` # Steps to reproduce Copy paste this into the terminal: ``` hello ``` # Expected behavior "hello" gets pasted into the terminal # Actual behavior "hello" gets prepended with the first file in the directory: ".bash_historyhello" I reproduced it on all machines I tried it on. It doesn't reproduce when using cmd.exe through the default windows conhost.exe. This issue is especially annoying when copy pasting stuff from websites as they like to contain "invisible" tabs.
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (Mar 4, 2021):

Consider setting the no_empty_cmd_completion option in Bash.

@KalleOlaviNiemitalo commented on GitHub (Mar 4, 2021): Consider setting the `no_empty_cmd_completion` option in Bash.
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (Mar 4, 2021):

It doesn't reproduce when using cmd.exe through the default windows conhost.exe.

It does for me, if I uncheck the "Filter clipboard contents on paste" option.

@KalleOlaviNiemitalo commented on GitHub (Mar 4, 2021): > It doesn't reproduce when using cmd.exe through the default windows conhost.exe. It does for me, if I uncheck the "Filter clipboard contents on paste" option.
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (Mar 4, 2021):

For conhost, removal of pasted TAB characters is implemented here: https://github.com/microsoft/terminal/blob/507a84664e6d5449bc31746510128d3136ecc719/src/interactivity/win32/Clipboard.cpp#L338-L343

I don't see similar filtering in TermControl::_SendPastedTextToConnection.

@KalleOlaviNiemitalo commented on GitHub (Mar 4, 2021): For conhost, removal of pasted TAB characters is implemented here: <https://github.com/microsoft/terminal/blob/507a84664e6d5449bc31746510128d3136ecc719/src/interactivity/win32/Clipboard.cpp#L338-L343> I don't see similar filtering in TermControl::_SendPastedTextToConnection.
Author
Owner

@j4james commented on GitHub (Mar 4, 2021):

Paste filtering was only recently added, but we don't currently filter the tab character:
2c603ef953/src/types/utils.cpp (L456-L457)

I didn't think it was necessary, since most *nix terminals don't, but obviously they're not dealing with a cmd shell. I think XTerm replaces the tab character with space, so maybe that's an option we could go with.

cc @skyline75489

@j4james commented on GitHub (Mar 4, 2021): Paste filtering was only recently added, but we don't currently filter the tab character: https://github.com/microsoft/terminal/blob/2c603ef953752b315f3c1e1c4b49368c76390cf3/src/types/utils.cpp#L456-L457 I didn't think it was necessary, since most *nix terminals don't, but obviously they're not dealing with a cmd shell. I think XTerm replaces the tab character with space, so maybe that's an option we could go with. cc @skyline75489
Author
Owner

@DHowett commented on GitHub (Mar 4, 2021):

This one is likely going to bruise a few people. Pasting tabs is important for things that aren't cmd, but it's unpleasant for things that are. :|

@DHowett commented on GitHub (Mar 4, 2021): This one is likely going to bruise a few people. Pasting tabs is important for things that aren't cmd, but it's unpleasant for things that are. :|
Author
Owner

@skyline75489 commented on GitHub (Mar 5, 2021):

So if I'm understanding this correctly, cmd.exe actually filters tab to prevent "inadvertant tab expansion", while most *nix terminals does not do this, but somehow also does not suffer from the tab expansion issue? Forgive me for being an ignorant man, I don't quite get it why cmd.exe is so special.

@skyline75489 commented on GitHub (Mar 5, 2021): So if I'm understanding this correctly, cmd.exe actually filters tab to prevent "inadvertant tab expansion", while most *nix terminals does not do this, but somehow also does not suffer from the tab expansion issue? Forgive me for being an ignorant man, I don't quite get it why cmd.exe is so special.
Author
Owner

@j4james commented on GitHub (Mar 5, 2021):

Typing TAB in a cmd shell autocompletes with the first file in the current directory, while typing TAB in a *nix shell will only have an effect if you've already typed something else on the command line (at least as far as I know - I'm not an expert). So technically pasting a TAB could still do something weird in a *nix shell, but I think it's less likely. And even then the problem could be avoided by enabling bracketed paste, which is not an option in a cmd shell.

@j4james commented on GitHub (Mar 5, 2021): Typing TAB in a cmd shell autocompletes with the first file in the current directory, while typing TAB in a *nix shell will only have an effect if you've already typed something else on the command line (at least as far as I know - I'm not an expert). So technically pasting a TAB could still do something weird in a *nix shell, but I think it's less likely. And even then the problem could be avoided by enabling bracketed paste, which is not an option in a cmd shell.
Author
Owner

@skyline75489 commented on GitHub (Mar 5, 2021):

Well, guess I really don't know cmd or Windows that well.

Like Dustin said, I don't feel quite comfortable just striping Tabs since some folks might actually want to paste a lot of Tabs. Why would XTerm just replacing Tabs with space? Does that frustrates people who just want tabs? Or is there an option for it.

@skyline75489 commented on GitHub (Mar 5, 2021): Well, guess I *really* don't know cmd or Windows that well. Like Dustin said, I don't feel quite comfortable just striping Tabs since some folks might actually want to paste a lot of Tabs. Why would XTerm just replacing Tabs with space? Does that frustrates people who just want tabs? Or is there an option for it.
Author
Owner

@j4james commented on GitHub (Mar 5, 2021):

XTerm has options for just about everything, so it wouldn't surprise me if this was an option too. And it's not just TAB - there are a few other control characters that they replace with space which some terminals just filter out.

@j4james commented on GitHub (Mar 5, 2021): XTerm has options for just about everything, so it wouldn't surprise me if this was an option too. And it's not just TAB - there are a few other control characters that they replace with space which some terminals just filter out.
Author
Owner

@skyline75489 commented on GitHub (Mar 5, 2021):

OK now I honestly have no idea how we should do about it. I’ll just trust Dustin’s decision on this one.

获取 Outlook for iOShttps://aka.ms/o0ukef

@skyline75489 commented on GitHub (Mar 5, 2021): OK now I honestly have no idea how we should do about it. I’ll just trust Dustin’s decision on this one. 获取 Outlook for iOS<https://aka.ms/o0ukef>
Author
Owner

@TautvydasZilys commented on GitHub (Sep 27, 2021):

Is this issue still being triaged? I'm facing it every day and it's very, very annoying.

@TautvydasZilys commented on GitHub (Sep 27, 2021): Is this issue still being triaged? I'm facing it every day and it's very, very annoying.
Author
Owner

@zadjii-msft commented on GitHub (Sep 27, 2021):

Well, I dunno how this fell off the triage queue.

This one's tricky -

  • We probably don't want to filter all tabs, because as mentioned, there's probably someone out there actually pasting tabs in bash for something.
  • Seemingly, this is a special conhost feature, not a COOKED_READ one, because it doesn't work "for free" in cmd in Terminal
  • We probably don't want to just add it to COOKED_READ if it's not something that's already in there, because that'll inevitably break someone else.
  • I wonder if this has to do with QuickEdit mode in conhost, which there's no good analog for in the Terminal.

EDIT 2023:

Let's take a look at conhost's cooked read / clipboard impl.

  • If conhost translates tabs to spaces, then Terminal could consider doing that too if bracketed paste is turned off.
  • If it doesn't then we could add a paste setting for this.

image
hmMmMmMMmmmMMmMMmm

@zadjii-msft commented on GitHub (Sep 27, 2021): Well, I dunno how this fell off the triage queue. This one's tricky - * We probably don't want to filter all tabs, because as mentioned, there's probably someone out there actually pasting tabs in `bash` for something. * Seemingly, this is a special conhost feature, not a `COOKED_READ` one, because it doesn't work "for free" in `cmd` in Terminal * We probably don't want to just add it to `COOKED_READ` if it's not something that's already in there, because that'll inevitably break someone else. * I wonder if this has to do with QuickEdit mode in conhost, which there's no good analog for in the Terminal. EDIT 2023: Let's take a look at conhost's cooked read / clipboard impl. * If conhost translates tabs to spaces, then Terminal could consider doing that too if bracketed paste is turned off. * If it doesn't then we could add a paste setting for this. ![image](https://user-images.githubusercontent.com/18356694/220780249-31bbfb83-fb61-4997-a2ee-31fada2311f9.png) hmMmMmMMmmmMMmMMmm
Author
Owner

@carlos-zamora commented on GitHub (Apr 6, 2023):

/dup #6134

@carlos-zamora commented on GitHub (Apr 6, 2023): /dup #6134
Author
Owner

@microsoft-github-policy-service[bot] commented on GitHub (Apr 6, 2023):

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[bot] commented on GitHub (Apr 6, 2023): 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!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#12870