--- a/st.c +++ b/st.c @@ -1477,6 +1477,8 @@ kscrollup(const Arg* a) { if(term.scr <= histsize - n) { term.scr += n; + if (term.scr > term.histi) + term.scr = term.histi; selscroll(0, n); tfulldirt(); }