[hackers] [st] [PATCH] set sel.alt in selstart instead of selextend

From: Daniel Tameling <tamelingdaniel_AT_gmail.com>
Date: Wed, 28 Mar 2018 21:27:58 +0200

---
When selecting something via doubleclick after entering or leaving the
altscreen mode, the selection is not highlighted with st 0.8. But it
gets copied to the primary, so the problem is only the highlighting.
To reproduce this, enter less and select something with a
doubleclick. Afterwards you cannot see in the terminal what you
selected. But once you start scrolling, the selection appears.
The reason for this behavior is that selextend is only called when the
mouse button is released the second time. But during this call the
tsetdirt function isn't called, so the terminal isn't redrawn. What
gets selected has at that point already been decided during selstart,
but the subsequent tsetdirt doesn't have any effect as the function
selected returns early if sel.alt != IS_SET(MODE_ALTSCREEN).  Thus,
setting sel.alt is moved to selstart, which fixes the bug and didn't
show any side effects during my testing.
 st.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/st.c b/st.c
index 46c954b..2612c95 100644
--- a/st.c
+++ b/st.c
_AT_@ -446,6 +446,7 @@ selstart(int col, int row, int snap)
 	selclear();
 	sel.mode = SEL_EMPTY;
 	sel.type = SEL_REGULAR;
+	sel.alt = IS_SET(MODE_ALTSCREEN);
 	sel.snap = snap;
 	sel.oe.x = sel.ob.x = col;
 	sel.oe.y = sel.ob.y = row;
_AT_@ -474,7 +475,6 @@ selextend(int col, int row, int type, int done)
 	oldsey = sel.ne.y;
 	oldtype = sel.type;
 
-	sel.alt = IS_SET(MODE_ALTSCREEN);
 	sel.oe.x = col;
 	sel.oe.y = row;
 	selnormalize();
-- 
2.11.0
Received on Wed Mar 28 2018 - 21:27:58 CEST

This archive was generated by hypermail 2.3.0 : Wed Mar 28 2018 - 21:36:23 CEST