Window Terminal sporadically fails to trim trailing white spaces. #22213

Open
opened 2026-01-31 08:06:42 +00:00 by claunia · 16 comments
Owner

Originally created by @jeffpkamp on GitHub (Sep 4, 2024).

Windows Terminal version

1.20.11781.0

Windows build number

10.0.19043 Build 19043

Other Software

This happens no matter where I am copying from.

Steps to reproduce

Open terminal, copy and paste into a new terminal window. The behavior is sporadic, but happens with often. It makes it very hard to work in the terminal.

Expected Behavior

pasted text will have the excess white space at the end of the line removed

Actual Behavior

pasted text is treated like it was a single line that wrapped around, leading to long white spaces and no line breaks.

Behavior is sporadic. The problem is on the copy window side.

Example: Below data was copied and pasted. Some of the white space is removed, some is not.

                                                                                                                               secondary={}                                                                                                                      r=requests.get(HTML).content.decode().split("\n")                                                                                 for x in r[1:]:
    if x:
        if "NONE" not in x:
            x=re.split("[\t ]",x)
            pos=x[0].replace("_"," ")
            if pos not in secondary:
                secondary[pos]=set()
            for v in x[1:]:
                if "(" not in v:
                    secondary[pos]=secondary[pos]|set([v])

I add a few newlines above the text and now it copies correctly, but this is not a consistent fix

secondary={}
r=requests.get(HTML).content.decode().split("\n")
for x in r[1:]:
    if x:
        if "NONE" not in x:
            x=re.split("[\t ]",x)
            pos=x[0].replace("_"," ")
            if pos not in secondary:
                secondary[pos]=set()
            for v in x[1:]:
                if "(" not in v:
                    secondary[pos]=secondary[pos]|set([v])
Originally created by @jeffpkamp on GitHub (Sep 4, 2024). ### Windows Terminal version 1.20.11781.0 ### Windows build number 10.0.19043 Build 19043 ### Other Software This happens no matter where I am copying from. ### Steps to reproduce Open terminal, copy and paste into a new terminal window. The behavior is sporadic, but happens with often. It makes it very hard to work in the terminal. ### Expected Behavior pasted text will have the excess white space at the end of the line removed ### Actual Behavior pasted text is treated like it was a single line that wrapped around, leading to long white spaces and no line breaks. Behavior is sporadic. The problem is on the copy window side. Example: Below data was copied and pasted. Some of the white space is removed, some is not. ``` secondary={} r=requests.get(HTML).content.decode().split("\n") for x in r[1:]: if x: if "NONE" not in x: x=re.split("[\t ]",x) pos=x[0].replace("_"," ") if pos not in secondary: secondary[pos]=set() for v in x[1:]: if "(" not in v: secondary[pos]=secondary[pos]|set([v]) ``` I add a few newlines above the text and now it copies correctly, but this is not a consistent fix ``` secondary={} r=requests.get(HTML).content.decode().split("\n") for x in r[1:]: if x: if "NONE" not in x: x=re.split("[\t ]",x) pos=x[0].replace("_"," ") if pos not in secondary: secondary[pos]=set() for v in x[1:]: if "(" not in v: secondary[pos]=secondary[pos]|set([v]) ```
claunia added the Issue-BugProduct-TerminalPriority-2Area-TerminalControl labels 2026-01-31 08:06:43 +00:00
Author
Owner

@jeffpkamp commented on GitHub (Sep 4, 2024):

Sorry, just noted this behavior. Sometimes it puts a newline in where the line wraps.

@jeffpkamp commented on GitHub (Sep 4, 2024): Sorry, just noted this behavior. Sometimes it puts a newline in where the line wraps.
Author
Owner

@zadjii-msft commented on GitHub (Sep 4, 2024):

Does this repro on 1.22/?

https://github.com/microsoft/terminal/releases/tag/v1.22.2362.0

@zadjii-msft commented on GitHub (Sep 4, 2024): Does this repro on 1.22/? https://github.com/microsoft/terminal/releases/tag/v1.22.2362.0
Author
Owner

@jeffpkamp commented on GitHub (Sep 5, 2024):

Got it installed. Give me a few days to test it out and see if the buggy behavior appears

@jeffpkamp commented on GitHub (Sep 5, 2024): Got it installed. Give me a few days to test it out and see if the buggy behavior appears
Author
Owner

@jeffpkamp commented on GitHub (Sep 9, 2024):

It has worked correctly on the new version for a few days now. I am now testing it out on a different computer just to make sure.

@jeffpkamp commented on GitHub (Sep 9, 2024): It has worked correctly on the new version for a few days now. I am now testing it out on a different computer just to make sure.
Author
Owner

@jeffpkamp commented on GitHub (Sep 9, 2024):

I am still seeing the inappropriate pasting behavior on the new computer I am using it on.

@jeffpkamp commented on GitHub (Sep 9, 2024): I am still seeing the inappropriate pasting behavior on the new computer I am using it on.
Author
Owner

@jeffpkamp commented on GitHub (Sep 13, 2024):

I can confirm I am still seeing the issue on the original computer with the new release of the terminal.

I should also note that sometimes I can get it to stop by doing things like resizing the window? Doesn't always work, but sometimes it does.

@jeffpkamp commented on GitHub (Sep 13, 2024): I can confirm I am still seeing the issue on the original computer with the new release of the terminal. I should also note that sometimes I can get it to stop by doing things like resizing the window? Doesn't always work, but sometimes it does.
Author
Owner

@carlos-zamora commented on GitHub (Sep 25, 2024):

Thanks for filing! What shell or other application are you using /?

@carlos-zamora commented on GitHub (Sep 25, 2024): Thanks for filing! What shell or other application are you using /?
Author
Owner

@jeffpkamp commented on GitHub (Sep 30, 2024):

I am using bash shell. The problem does not seem to matter if I am in the shell environment or copying from a text editor like vim or less. Once it starts, it will persist until I do something that changes the state of the screen like resizing, though this does not get rid of it every time.

@jeffpkamp commented on GitHub (Sep 30, 2024): I am using bash shell. The problem does not seem to matter if I am in the shell environment or copying from a text editor like vim or less. Once it starts, it will persist until I do something that changes the state of the screen like resizing, though this does not get rid of it every time.
Author
Owner

@DHowett commented on GitHub (Sep 30, 2024):

Sorry - are you using WSL, Cygwin, or msys2?

@DHowett commented on GitHub (Sep 30, 2024): Sorry - are you using WSL, Cygwin, or msys2?
Author
Owner

@jeffpkamp commented on GitHub (Sep 30, 2024):

I am using wsl2

@jeffpkamp commented on GitHub (Sep 30, 2024): I am using wsl2
Author
Owner

@mishuang2017 commented on GitHub (Nov 27, 2024):

Steps to reproduce
Open terminal, copy and paste into a new terminal window. The behavior is sporadic, but happens with often. It makes it very hard to work in the terminal.

If I paste 10 lines, sometimes, 1-3 lines are appended in one line. I set vim to nowrap, it seems like I miss 2 lines.

Edition Windows 11 Enterprise
Version 23H2
Installed on ‎2/‎23/‎2024
OS build 22631.4460
Experience Windows Feature Experience Pack 1000.22700.1047.0

Windows Terminal
Version: 1.21.2911.0

@mishuang2017 commented on GitHub (Nov 27, 2024): Steps to reproduce Open terminal, copy and paste into a new terminal window. The behavior is sporadic, but happens with often. It makes it very hard to work in the terminal. If I paste 10 lines, sometimes, 1-3 lines are appended in one line. I set vim to nowrap, it seems like I miss 2 lines. Edition Windows 11 Enterprise Version 23H2 Installed on ‎2/‎23/‎2024 OS build 22631.4460 Experience Windows Feature Experience Pack 1000.22700.1047.0 Windows Terminal Version: 1.21.2911.0
Author
Owner

@anttiah commented on GitHub (Dec 2, 2024):

I'm experiencing this too. Seems to happen especially when I select rectangular block from lines where there are more text on right-hand side outside my selection.

@anttiah commented on GitHub (Dec 2, 2024): I'm experiencing this too. Seems to happen especially when I select rectangular block from lines where there are more text on right-hand side outside my selection.
Author
Owner

@carlos-zamora commented on GitHub (Jan 13, 2025):

We think that this'll be a lot better with v1.22. You can try it out with WT Preview (which you can get over in the releases page). Please let us know if that fixes your issue, thanks! 🙂

@carlos-zamora commented on GitHub (Jan 13, 2025): We think that this'll be a lot better with v1.22. You can try it out with WT Preview (which you can get over in the [releases page](https://github.com/microsoft/terminal/releases)). Please let us know if that fixes your issue, thanks! 🙂
Author
Owner

@mishuang2017 commented on GitHub (Jan 20, 2025):

Terminal (Unpackaged)
Version: 1.22.241118002-preview

Unfortunately, it still has problem:

# tc -s filter show dev enp8s0f0_0 ingress
filter parent ffff: protocol ip pref 1 flower chain 0
filter parent ffff: protocol ip pref 1 flower chain 0 handle 0x1
  dst_mac e4:1d:2d:fd:8b:02
  eth_type ipv4
  ip_proto icmp
  skip_sw
  in_hw in_hw_count 1
        action order 1: tunnel_key  set
        src_ip 49.0.10.60
        dst_ip 46.0.10.180
        key_id 98
        dst_port 4789
        csum pipe
         index 1 ref 1 bind 1 installed 789 sec used 789 sec
        Action statistics:                                                                                                                                                                          Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
        backlog 0b 0p requeues 0
        used_hw_stats delayed

        action order 2: mirred (Egress Redirect to device vxlan1) stolen
        index 1 ref 1 bind 1 installed 789 sec used 749 sec
        Action statistics:
        Sent 47064 bytes 318 pkt (dropped 0, overlimits 0 requeues 0)
        Sent software 0 bytes 0 pkt
        Sent hardware 47064 bytes 318 pkt
        backlog 0b 0p requeues 0
        used_hw_stats delayed
@mishuang2017 commented on GitHub (Jan 20, 2025): Terminal (Unpackaged) Version: 1.22.241118002-preview Unfortunately, it still has problem: ``` # tc -s filter show dev enp8s0f0_0 ingress filter parent ffff: protocol ip pref 1 flower chain 0 filter parent ffff: protocol ip pref 1 flower chain 0 handle 0x1 dst_mac e4:1d:2d:fd:8b:02 eth_type ipv4 ip_proto icmp skip_sw in_hw in_hw_count 1 action order 1: tunnel_key set src_ip 49.0.10.60 dst_ip 46.0.10.180 key_id 98 dst_port 4789 csum pipe index 1 ref 1 bind 1 installed 789 sec used 789 sec Action statistics: Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 used_hw_stats delayed action order 2: mirred (Egress Redirect to device vxlan1) stolen index 1 ref 1 bind 1 installed 789 sec used 749 sec Action statistics: Sent 47064 bytes 318 pkt (dropped 0, overlimits 0 requeues 0) Sent software 0 bytes 0 pkt Sent hardware 47064 bytes 318 pkt backlog 0b 0p requeues 0 used_hw_stats delayed ```
Author
Owner

@caffeinejolt commented on GitHub (Apr 16, 2025):

Just wanted to add... it will be so GREAT when this gets fixed. Makes me miss mintty when I create rectangular selections.

@caffeinejolt commented on GitHub (Apr 16, 2025): Just wanted to add... it will be so GREAT when this gets fixed. Makes me miss mintty when I create rectangular selections.
Author
Owner

@AltitudeApps commented on GitHub (Apr 26, 2025):

It would be helpful to me if the option to either trim trailing white space, or not trim trailing white space, could be exposed in something like a right-click menu.

I often find myself needing to quickly check the field width of items printed to the screen.

Image

The white space being trimmed in this case is "trailing" only from the perspective of the copy/paste buffer, not the screen buffer.

My workaround is to select one extra character, paste, then backspace over the extra character.

Image

--

My dream feature would be to somehow have the screen buffer remember exactly the white space which preceded the newline character, so that I could cat a file to the terminal, select the text, paste it into another text editor, and get precisely the same file.

@AltitudeApps commented on GitHub (Apr 26, 2025): It would be helpful to me if the option to either trim trailing white space, or *not* trim trailing white space, could be exposed in something like a right-click menu. I often find myself needing to quickly check the field width of items printed to the screen. ![Image](https://github.com/user-attachments/assets/7d188334-b994-4d34-b530-74c571437b5d) The white space being trimmed in this case is "trailing" only from the perspective of the copy/paste buffer, not the screen buffer. My workaround is to select one extra character, paste, then backspace over the extra character. ![Image](https://github.com/user-attachments/assets/0ab5bb73-1713-4f32-8409-5a9ce2d0e7a0) -- My dream feature would be to somehow have the screen buffer remember exactly the white space which preceded the newline character, so that I could cat a file to the terminal, select the text, paste it into another text editor, and get precisely the same file.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#22213