migueldeicaza / XtermSharp

XTerm emulator as a .NET library
MIT License
161 stars 34 forks source link

Buffer recycling glitch #48

Closed sgmunn closed 4 years ago

sgmunn commented 4 years ago

I am still trying to understand the root issue here, but if you set the scroll back to something low, like 5, and cause the buffer to start recycling rows there are 2 glitches that happen. The first is a blank line inserted in the display buffer and the second is a ghosting of the first line of data.

Screen Recording 2020-03-02 at 02 48 PM

Debugging this in UpdateDisplay, the buffer has 53 lines, the first contains the ghosted data, the last contains a blank line (which maps to what we see as line[0] is recycled).

Screen Shot 2020-03-02 at 2 58 02 PM

With a breakpoint in UpdateDisplay that stops when the content we are updating contains the string "Xterm" and a breakpoint in Terminal.Scroll(bool) on line 301 (buffer.Lines.Recycle ().CopyFrom (newLine)), we see that the str contains the text before we start to recycle lines. What appears to be happening is that the terminal view's buffer is being loaded with text from the terminal buffer, the terminal buffer is full. CircularList.Push bumps startIndex immediately after adding an element when length == array.Length.

It is possible that CircularList.startIndex is being incremented too soon, since no additional items has been added yet. Actually, this might be the case, looking at xterm.js, length is incremented after the check to adjust startIndex.