diff --git a/st.c b/st.c index 8d27c94..c5188d5 100644 --- a/st.c +++ b/st.c @@ -677,7 +677,30 @@ selsnap(int mode, int *x, int *y, int direction) { } break; case SNAP_LINE: - *x = (direction < 0) ? 0 : term.col - 1; + if (direction < 0) + { + *x = 0; + for(; *y > 0; *y-=1) + { + int i = term.col; + while (--i > 0 && term.line[*y-1][i].c[0] == ' ') + /* nothing */ ; + if (i <= 0 || !(term.line[*y-1][i].mode & ATTR_WRAP)) + break; + } + } + else + { + *x = term.col - 1; + for(; *y < term.row-1; *y+=1) + { + int i = term.col; + while (--i > 0 && term.line[*y][i].c[0] == ' ') + /* nothing */ ; + if (i <= 0 || !(term.line[*y][i].mode & ATTR_WRAP)) + break; + } + } break; default: break;