@@ -2007,13 +2007,17 @@ is_opt_word_char(char_type ch) {
2007
2007
}
2008
2008
2009
2009
bool
2010
- screen_selection_range_for_word (Screen * self , index_type x , index_type * y1 , index_type * y2 , index_type * s , index_type * e ) {
2010
+ screen_selection_range_for_word (Screen * self , index_type x , index_type * y1 , index_type * y2 , index_type * s , index_type * e , bool initial_selection ) {
2011
2011
if (* y1 >= self -> lines || x >= self -> columns ) return false;
2012
2012
index_type start , end ;
2013
2013
Line * line = visual_line_ (self , * y1 );
2014
2014
* y2 = * y1 ;
2015
2015
#define is_ok (x ) (is_word_char((line->cpu_cells[x].ch)) || is_opt_word_char(line->cpu_cells[x].ch))
2016
- if (!is_ok (x )) return false;
2016
+ if (!is_ok (x )) {
2017
+ if (initial_selection ) return false;
2018
+ * s = x ; * e = x ;
2019
+ return true;
2020
+ }
2017
2021
start = x ; end = x ;
2018
2022
while (true) {
2019
2023
while (start > 0 && is_ok (start - 1 )) start -- ;
@@ -2109,19 +2113,19 @@ screen_update_selection(Screen *self, index_type x, index_type y, bool ended) {
2109
2113
switch (self -> selection .extend_mode ) {
2110
2114
case EXTEND_WORD : {
2111
2115
index_type y1 = y , y2 ;
2112
- found = screen_selection_range_for_word (self , x , & y1 , & y2 , & start , & end );
2116
+ found = screen_selection_range_for_word (self , x , & y1 , & y2 , & start , & end , false );
2113
2117
if (found ) {
2114
2118
if (extending_leftwards ) {
2115
2119
self -> selection .end_x = start ; self -> selection .end_y = y1 ;
2116
2120
y1 = self -> selection .start_y ;
2117
- found = screen_selection_range_for_word (self , self -> selection .start_x , & y1 , & y2 , & start , & end );
2121
+ found = screen_selection_range_for_word (self , self -> selection .start_x , & y1 , & y2 , & start , & end , false );
2118
2122
if (found ) {
2119
2123
self -> selection .start_x = end ; self -> selection .start_y = y2 ;
2120
2124
}
2121
2125
} else {
2122
2126
self -> selection .end_x = end ; self -> selection .end_y = y2 ;
2123
2127
y1 = self -> selection .start_y ;
2124
- found = screen_selection_range_for_word (self , self -> selection .start_x , & y1 , & y2 , & start , & end );
2128
+ found = screen_selection_range_for_word (self , self -> selection .start_x , & y1 , & y2 , & start , & end , false );
2125
2129
if (found ) {
2126
2130
self -> selection .start_x = start ; self -> selection .start_y = y1 ;
2127
2131
}
0 commit comments