Fix empty selection highlighting bug.

When user clicks LMB, one character is selected, but will not be copied
to selection until the user moves cursor a bit. Therefore, the character
should not be highlighted as selected yet.

Before the patch, the trick was not to mark line as dirty to avoid
highlighting it. However, if user has already selected something and
clicks in line that contains selection, selclear sets the line as dirty
and one character is highlighted when it should not.

This patch replaces dirty trick with explicit check for sel.mode inside
selected().
dev
noname 2015-05-03 19:28:10 +00:00 committed by Roberto E. Vargas Caballero
parent 3cb7f27afe
commit c990abfedf
1 changed files with 5 additions and 7 deletions

12
st.c
View File

@ -716,6 +716,9 @@ selnormalize(void) {
bool bool
selected(int x, int y) { selected(int x, int y) {
if(sel.mode == SEL_EMPTY)
return false;
if(sel.type == SEL_RECTANGULAR) if(sel.type == SEL_RECTANGULAR)
return BETWEEN(y, sel.nb.y, sel.ne.y) return BETWEEN(y, sel.nb.y, sel.ne.y)
&& BETWEEN(x, sel.nb.x, sel.ne.x); && BETWEEN(x, sel.nb.x, sel.ne.x);
@ -921,14 +924,9 @@ bpress(XEvent *e) {
} }
selnormalize(); selnormalize();
/* if(sel.snap != 0)
* Draw selection, unless it's regular and we don't want to
* make clicks visible
*/
if(sel.snap != 0) {
sel.mode = SEL_READY; sel.mode = SEL_READY;
tsetdirt(sel.nb.y, sel.ne.y); tsetdirt(sel.nb.y, sel.ne.y);
}
sel.tclick2 = sel.tclick1; sel.tclick2 = sel.tclick1;
sel.tclick1 = now; sel.tclick1 = now;
} }