Browse Source

selsnap: simplify SNAP_LINE case

Also make sure y never exceeds term.row-1 even if ATTR_WRAP is set for
some reason.
master
noname 9 years ago
committed by Roberto E. Vargas Caballero
parent
commit
8751809aff
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      st.c

+ 3
- 3
st.c View File

@ -772,15 +772,15 @@ selsnap(int *x, int *y, int direction) {
* previous line will be selected. * previous line will be selected.
*/ */
*x = (direction < 0) ? 0 : term.col - 1; *x = (direction < 0) ? 0 : term.col - 1;
if(direction < 0 && *y > 0) {
if(direction < 0) {
for(; *y > 0; *y += direction) { for(; *y > 0; *y += direction) {
if(!(term.line[*y-1][term.col-1].mode if(!(term.line[*y-1][term.col-1].mode
& ATTR_WRAP)) { & ATTR_WRAP)) {
break; 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 if(!(term.line[*y][term.col-1].mode
& ATTR_WRAP)) { & ATTR_WRAP)) {
break; break;


Loading…
Cancel
Save