microsoft / microsoft/terminal

Copy on Select ignore trailing whitespaces

Open
#6,869 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-TerminalControl Issue-Bug Priority-2 Product-Terminal
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

Description of the new feature/enhancement

While copying on select, auto ignore trailing whitespaces on each line.

Why?

In my .vimrc, I draw 80 column and 120 column line via background color like this:

image

function! SetColumnWarnOnResized()
  highlight Normal ctermbg=NONE
  if &columns > 120
    let &colorcolumn="81,".join(range(120, &columns), ",") " Set the column warns on 80 and 120+
  else
    let &colorcolumn="81" " Set the column warns on 80
  endif
endfunction
au VimResized * call SetColumnWarnOnResized()
call SetColumnWarnOnResized()     

When I select and copy these words in the screenshot above, Windows Terminal will fill my clipboard with many whitespaces like this (notice that wired whitespaces):

Some texts here...
And here...                                                                                                                                                         Notice the 80 col line in my vim --------------------------------------------->
And the 120 col line ================================================================================================>       

And this only happend sometimes (not always), I don't know if this is a bug?

Related issues

This issues may relatives to these issues:

  • #2944
  • #3088

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the selection and clipboard behavior in Windows Terminal with Vim's colored columns, including cases where the issue occurs only sometimes. Read related issues #2944 and #3088 for prior context, then trace the copy-on-select path. Done means copied lines consistently omit trailing whitespace without changing meaningful internal or leading spaces.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.