Git diff leaves some dangling characters in the output of subsequent commands in some situations
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 diffwith a not so small diff (at least two pages seem ideal) so that it pages the output withless - Press
page downonce - Press
page uponce - Press
qonce - 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
@mateusmedeiros Just to double check, what you're seeing looks like this, correct?

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 Yep, exactly like that.
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!
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.
Hey, I checked this in earlier this week, should be out to Insiders sometime in the next month.
@zadjii-msft That's good to know, thank you very much. 😄
Thanks so much!! 😄