diff options
| -rw-r--r-- | st.c | 11 |
1 files changed, 9 insertions, 2 deletions
| @@ -709,7 +709,8 @@ selected(int x, int y) { | |||
| 709 | void | 709 | void |
| 710 | selsnap(int mode, int *x, int *y, int direction) { | 710 | selsnap(int mode, int *x, int *y, int direction) { |
| 711 | int newx, newy, xt, yt; | 711 | int newx, newy, xt, yt; |
| 712 | Glyph *gp; | 712 | bool delim, prevdelim; |
| 713 | Glyph *gp, *prevgp; | ||
| 713 | 714 | ||
| 714 | switch(mode) { | 715 | switch(mode) { |
| 715 | case SNAP_WORD: | 716 | case SNAP_WORD: |
| @@ -717,6 +718,8 @@ selsnap(int mode, int *x, int *y, int direction) { | |||
| 717 | * Snap around if the word wraps around at the end or | 718 | * Snap around if the word wraps around at the end or |
| 718 | * beginning of a line. | 719 | * beginning of a line. |
| 719 | */ | 720 | */ |
| 721 | prevgp = &term.line[*y][*x]; | ||
| 722 | prevdelim = strchr(worddelimiters, prevgp->c[0]) != NULL; | ||
| 720 | for(;;) { | 723 | for(;;) { |
| 721 | newx = *x + direction; | 724 | newx = *x + direction; |
| 722 | newy = *y; | 725 | newy = *y; |
| @@ -738,11 +741,15 @@ selsnap(int mode, int *x, int *y, int direction) { | |||
| 738 | break; | 741 | break; |
| 739 | 742 | ||
| 740 | gp = &term.line[newy][newx]; | 743 | gp = &term.line[newy][newx]; |
| 741 | if (!(gp->mode & ATTR_WDUMMY) && strchr(worddelimiters, gp->c[0])) | 744 | delim = strchr(worddelimiters, gp->c[0]) != NULL; |
| 745 | if(!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim | ||
| 746 | || (delim && gp->c[0] != prevgp->c[0]))) | ||
| 742 | break; | 747 | break; |
| 743 | 748 | ||
| 744 | *x = newx; | 749 | *x = newx; |
| 745 | *y = newy; | 750 | *y = newy; |
| 751 | prevgp = gp; | ||
| 752 | prevdelim = delim; | ||
| 746 | } | 753 | } |
| 747 | break; | 754 | break; |
| 748 | case SNAP_LINE: | 755 | case SNAP_LINE: |
