WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Git diff leaves some dangling characters in the output of subsequent commands in some situations

Open doodead opened this issue 9 years ago • 7 comments

This may be related to #1756.

Brief description

Commands ran after a git diff in some specific situations may leave some dangling characters mingled with the output.

Expected results

A command ran after I press q on the git diff to only output its own output.

Actual results

The output is mangled with the output of the previous git diff.

Something like this:

❯ git status                                                                
On branch master                                                            
Your branch is up-to-date with 'origin/master'.                             
Changes not staged for commit:                                              
  (use "git add <file>..." to update what will be committed)                
  (use "git checkout -- <file>..." to discard changes in working directory) 
     start_color                                                            
@@ -16,4modified:   src/grid_displayers/pancurses/character.rs              
        modified:   src/grid_displayers/pancurses/mod.rs                    
 use modmodified:   src/grid_displayers/pancurses/pancurses.rs              
 use grimodified:   src/main.rsayer;                                        
-use super::Character;                                                      
Untracked files:r;                                                          
  (use "git add <file>..." to include in what will be committed)            
 pub struct Pancurses {                                                     
-    trusrc/grid_displayers/pancurses/color.rs                              
+    main_window: Window,                                                   
no changes added to commit (use "git add" and/or "git commit -a")           
+    cell_color: i16,                                                       

Build number

15048

Reproduction steps

I can consistently reproduce this with these specific steps:

  • Run git diff with a not so small diff (at least two pages seem ideal) so that it pages the output with less
  • Press page down once
  • Press page up once
  • Press q once
  • Run git status (any command with blank spaces in its output seem to do)

Strangely enough, I can't reproduce this if I only press page down and q. Scrolling down and up with the arrow keys also don't work, I can only reproduce it by specifically pressing the page down page up combo and then quitting less and running another command.

Last but not least, simply paging a long output through less and doing these steps is also not enough to reproduce it.

Required packages and commands to install

  • git

doodead avatar Mar 08 '17 18:03 doodead

@mateusmedeiros Just to double check, what you're seeing looks like this, correct?

image

Because that looks bad to me. I very much hope this is related to #1756, and not it's own separate thing. I'll investigate.

(MSFT:11209943)

zadjii-msft avatar Mar 08 '17 22:03 zadjii-msft

@zadjii-msft Yep, exactly like that.

doodead avatar Mar 08 '17 22:03 doodead

I get this exact same thing following the reproduction steps above. I end up having to clear the screen a lot, which seems to work most of the time. Any updates? Thanks!

marc2982 avatar May 12 '17 17:05 marc2982

Well I think I see how this happens, but not exactly why it's wrong yet.

It looks like when you press PgUp in the git diff, it uses ESC M, "Reverse Index" to move up into the history. This causes conhost to move it's viewport up into the history. This however, doesn't delete any lines from the buffer that fall off the bottom.

Essentially, after hitting PgDn, PgUp, youre buffer looks like this: (where your viewport is 4 lines tall of an 8 line diff)

Diff line 1 -- Top of viewport
Diff line 2
Diff line 3
Diff line 4 -- bottom line of viewport
Diff line 5
Diff line 6
Diff line 7
Diff line 8

So, although you can't see 5-8, they're there. So, when you return to bash and run git status, the new content gets printed over the old content, not deleting the old lines.

Now I just need to go boot up some VM's and figure out what we're supposed to be doing here. I believe that the right answer is to not move the viewport up, but I can't be sure.

zadjii-msft avatar May 30 '17 22:05 zadjii-msft

Hey, I checked this in earlier this week, should be out to Insiders sometime in the next month.

zadjii-msft avatar Jun 08 '17 23:06 zadjii-msft

@zadjii-msft That's good to know, thank you very much. 😄

doodead avatar Jun 09 '17 18:06 doodead

Thanks so much!! 😄

marc2982 avatar Jun 12 '17 15:06 marc2982