Hi Shaddy. There you go again.
The reason seems to be that the Debian screen package packages a custom
/etc/screenrc that does not include this explicit term capability:
#
# Do not use xterms alternate window buffer.
# This one would not add lines to the scrollback buffer.
termcap xterm|xterms|xs ti=\E7\E[?47l
terminfo xterm|xterms|xs ti=\E7\E[?47l
If I comment these out, my screen issue is resolved.
I'm not suggesting this is a problem with Cygwin screen... it is using
the upstream settings. In fact, I am not confident to say where the
fault lies. Perhaps screen is right to use these sequences, but the
xterms used (putty and mintty) aren't doing the right thing?
I haven't seen the screen corruption you describe - not sure why. So it's
hard for me to test the fix. But I did comment out those 2 entries, start a
new screen, and attach and detach several times, and it doesn't seem to
cause any harm.
I don't know whose fault the problem is either, but it's probably a
particularity of Cygwin. So I'm happy to package the fix as long as it
doesn't create any problems.