]> git.armaanb.net Git - st.git/commitdiff
Fix selection: selscroll
authorJakub Leszczak <szatan@gecc.xyz>
Wed, 6 May 2020 11:36:59 +0000 (13:36 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Tue, 12 May 2020 13:38:17 +0000 (15:38 +0200)
st.c

diff --git a/st.c b/st.c
index 7c15d5f68fdc6d52b75b14d0c0d63ad78215a318..0d35613e04222564ab5fee489df6e1812b0a027f 100644 (file)
--- a/st.c
+++ b/st.c
@@ -1106,27 +1106,17 @@ selscroll(int orig, int n)
        if (sel.ob.x == -1)
                return;
 
-       if (BETWEEN(sel.ob.y, orig, term.bot) || BETWEEN(sel.oe.y, orig, term.bot)) {
-               if ((sel.ob.y += n) > term.bot || (sel.oe.y += n) < term.top) {
+       if (BETWEEN(sel.nb.y, orig, term.bot) != BETWEEN(sel.ne.y, orig, term.bot)) {
+               selclear();
+       } else if (BETWEEN(sel.nb.y, orig, term.bot)) {
+               sel.ob.y += n;
+               sel.oe.y += n;
+               if (sel.ob.y < term.top || sel.ob.y > term.bot ||
+                   sel.oe.y < term.top || sel.oe.y > term.bot) {
                        selclear();
-                       return;
-               }
-               if (sel.type == SEL_RECTANGULAR) {
-                       if (sel.ob.y < term.top)
-                               sel.ob.y = term.top;
-                       if (sel.oe.y > term.bot)
-                               sel.oe.y = term.bot;
                } else {
-                       if (sel.ob.y < term.top) {
-                               sel.ob.y = term.top;
-                               sel.ob.x = 0;
-                       }
-                       if (sel.oe.y > term.bot) {
-                               sel.oe.y = term.bot;
-                               sel.oe.x = term.col;
-                       }
+                       selnormalize();
                }
-               selnormalize();
        }
 }