X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=st.c;h=61388177c25b58d47995b023d4f981a7d7e58e31;hb=22571ea4e8729efee6940b704666566b46e42e76;hp=87f3ed2bf262b891f702cc9c3f7f6d705613b802;hpb=765bb0fd1420e36b04ecc03c18f01f5bda96c563;p=st.git diff --git a/st.c b/st.c index 87f3ed2..6138817 100644 --- a/st.c +++ b/st.c @@ -685,12 +685,12 @@ void selnormalize(void) { int i; - if(sel.ob.y == sel.oe.y || sel.type == SEL_RECTANGULAR) { - sel.nb.x = MIN(sel.ob.x, sel.oe.x); - sel.ne.x = MAX(sel.ob.x, sel.oe.x); - } else { + if(sel.type == SEL_REGULAR && sel.ob.y != sel.oe.y) { sel.nb.x = sel.ob.y < sel.oe.y ? sel.ob.x : sel.oe.x; sel.ne.x = sel.ob.y < sel.oe.y ? sel.oe.x : sel.ob.x; + } else { + sel.nb.x = MIN(sel.ob.x, sel.oe.x); + sel.ne.x = MAX(sel.ob.x, sel.oe.x); } sel.nb.y = MIN(sel.ob.y, sel.oe.y); sel.ne.y = MAX(sel.ob.y, sel.oe.y); @@ -772,15 +772,15 @@ selsnap(int *x, int *y, int direction) { * previous line will be selected. */ *x = (direction < 0) ? 0 : term.col - 1; - if(direction < 0 && *y > 0) { + if(direction < 0) { for(; *y > 0; *y += direction) { if(!(term.line[*y-1][term.col-1].mode & ATTR_WRAP)) { break; } } - } else if(direction > 0 && *y < term.row-1) { - for(; *y < term.row; *y += direction) { + } else if(direction > 0) { + for(; *y < term.row-1; *y += direction) { if(!(term.line[*y][term.col-1].mode & ATTR_WRAP)) { break;