Skip to content

Commit 7ba343e

Browse files
committed
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Problem: Terminal: screen updates from 'balloonexpr' are not displayed. Solution: Update the screen if needed. Fix the word position for "mousemoved".
1 parent e089c3f commit 7ba343e

6 files changed

Lines changed: 48 additions & 38 deletions

File tree

src/beval.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ find_word_under_cursor(
2727
win_T **winp, // can be NULL
2828
linenr_T *lnump, // can be NULL
2929
char_u **textp,
30-
int *colp)
30+
int *colp, // column where mouse hovers, can be NULL
31+
int *startcolp) // column where text starts, can be NULL
3132
{
3233
int row = mouserow;
3334
int col = mousecol;
35+
int scol;
3436
win_T *wp;
3537
char_u *lbuf;
3638
linenr_T lnum;
@@ -98,8 +100,8 @@ find_word_under_cursor(
98100
{
99101
// Find the word under the cursor.
100102
++emsg_off;
101-
len = find_ident_at_pos(wp, lnum, (colnr_T)col, &lbuf,
102-
flags);
103+
len = find_ident_at_pos(wp, lnum, (colnr_T)col,
104+
&lbuf, &scol, flags);
103105
--emsg_off;
104106
if (len == 0)
105107
return FAIL;
@@ -112,7 +114,10 @@ find_word_under_cursor(
112114
if (lnump != NULL)
113115
*lnump = lnum;
114116
*textp = lbuf;
115-
*colp = col;
117+
if (colp != NULL)
118+
*colp = col;
119+
if (startcolp != NULL)
120+
*startcolp = scol;
116121
return OK;
117122
}
118123
}
@@ -150,7 +155,7 @@ get_beval_info(
150155
#endif
151156
if (find_word_under_cursor(row, col, getword,
152157
FIND_IDENT + FIND_STRING + FIND_EVAL,
153-
winp, lnump, textp, colp) == OK)
158+
winp, lnump, textp, colp, NULL) == OK)
154159
{
155160
#ifdef FEAT_VARTABS
156161
vim_free(beval->vts);
@@ -296,12 +301,10 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
296301
if (result != NULL && result[0] != NUL)
297302
post_balloon(beval, result, NULL);
298303

299-
# ifdef FEAT_GUI
300304
// The 'balloonexpr' evaluation may show something on the screen
301305
// that requires a screen update.
302-
if (gui.in_use && must_redraw)
306+
if (must_redraw)
303307
redraw_after_callback(FALSE);
304-
# endif
305308

306309
recursive = FALSE;
307310
return;

src/normal.c

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,6 +2325,7 @@ do_mouse(
23252325
ui_may_remove_balloon();
23262326
if (p_bevalterm)
23272327
{
2328+
ch_log(NULL, "setting balloon timer");
23282329
profile_setlimit(p_bdlay, &bevalexpr_due);
23292330
bevalexpr_due_set = TRUE;
23302331
}
@@ -3327,28 +3328,28 @@ find_is_eval_item(
33273328
* Find the identifier under or to the right of the cursor.
33283329
* "find_type" can have one of three values:
33293330
* FIND_IDENT: find an identifier (keyword)
3330-
* FIND_STRING: find any non-white string
3331-
* FIND_IDENT + FIND_STRING: find any non-white string, identifier preferred.
3331+
* FIND_STRING: find any non-white text
3332+
* FIND_IDENT + FIND_STRING: find any non-white text, identifier preferred.
33323333
* FIND_EVAL: find text useful for C program debugging
33333334
*
33343335
* There are three steps:
3335-
* 1. Search forward for the start of an identifier/string. Doesn't move if
3336+
* 1. Search forward for the start of an identifier/text. Doesn't move if
33363337
* already on one.
3337-
* 2. Search backward for the start of this identifier/string.
3338+
* 2. Search backward for the start of this identifier/text.
33383339
* This doesn't match the real Vi but I like it a little better and it
33393340
* shouldn't bother anyone.
3340-
* 3. Search forward to the end of this identifier/string.
3341+
* 3. Search forward to the end of this identifier/text.
33413342
* When FIND_IDENT isn't defined, we backup until a blank.
33423343
*
3343-
* Returns the length of the string, or zero if no string is found.
3344-
* If a string is found, a pointer to the string is put in "*string". This
3345-
* string is not always NUL terminated.
3344+
* Returns the length of the text, or zero if no text is found.
3345+
* If text is found, a pointer to the text is put in "*text". This
3346+
* points into the current buffer line and is not always NUL terminated.
33463347
*/
33473348
int
3348-
find_ident_under_cursor(char_u **string, int find_type)
3349+
find_ident_under_cursor(char_u **text, int find_type)
33493350
{
33503351
return find_ident_at_pos(curwin, curwin->w_cursor.lnum,
3351-
curwin->w_cursor.col, string, find_type);
3352+
curwin->w_cursor.col, text, NULL, find_type);
33523353
}
33533354

33543355
/*
@@ -3360,33 +3361,34 @@ find_ident_at_pos(
33603361
win_T *wp,
33613362
linenr_T lnum,
33623363
colnr_T startcol,
3363-
char_u **string,
3364+
char_u **text,
3365+
int *textcol, // column where "text" starts, can be NULL
33643366
int find_type)
33653367
{
33663368
char_u *ptr;
3367-
int col = 0; /* init to shut up GCC */
3369+
int col = 0; // init to shut up GCC
33683370
int i;
33693371
int this_class = 0;
33703372
int prev_class;
33713373
int prevcol;
3372-
int bn = 0; /* bracket nesting */
3374+
int bn = 0; // bracket nesting
33733375

33743376
/*
33753377
* if i == 0: try to find an identifier
3376-
* if i == 1: try to find any non-white string
3378+
* if i == 1: try to find any non-white text
33773379
*/
33783380
ptr = ml_get_buf(wp->w_buffer, lnum, FALSE);
33793381
for (i = (find_type & FIND_IDENT) ? 0 : 1; i < 2; ++i)
33803382
{
33813383
/*
3382-
* 1. skip to start of identifier/string
3384+
* 1. skip to start of identifier/text
33833385
*/
33843386
col = startcol;
33853387
if (has_mbyte)
33863388
{
33873389
while (ptr[col] != NUL)
33883390
{
3389-
/* Stop at a ']' to evaluate "a[x]". */
3391+
// Stop at a ']' to evaluate "a[x]".
33903392
if ((find_type & FIND_EVAL) && ptr[col] == ']')
33913393
break;
33923394
this_class = mb_get_class(ptr + col);
@@ -3402,11 +3404,11 @@ find_ident_at_pos(
34023404
)
34033405
++col;
34043406

3405-
/* When starting on a ']' count it, so that we include the '['. */
3407+
// When starting on a ']' count it, so that we include the '['.
34063408
bn = ptr[col] == ']';
34073409

34083410
/*
3409-
* 2. Back up to start of identifier/string.
3411+
* 2. Back up to start of identifier/text.
34103412
*/
34113413
if (has_mbyte)
34123414
{
@@ -3432,8 +3434,8 @@ find_ident_at_pos(
34323434
col = prevcol;
34333435
}
34343436

3435-
/* If we don't want just any old string, or we've found an
3436-
* identifier, stop searching. */
3437+
// If we don't want just any old text, or we've found an
3438+
// identifier, stop searching.
34373439
if (this_class > 2)
34383440
this_class = 2;
34393441
if (!(find_type & FIND_STRING) || this_class == 2)
@@ -3454,8 +3456,8 @@ find_ident_at_pos(
34543456
))
34553457
--col;
34563458

3457-
/* If we don't want just any old string, or we've found an
3458-
* identifier, stop searching. */
3459+
// If we don't want just any old text, or we've found an
3460+
// identifier, stop searching.
34593461
if (!(find_type & FIND_STRING) || vim_iswordc(ptr[col]))
34603462
break;
34613463
}
@@ -3464,7 +3466,7 @@ find_ident_at_pos(
34643466
if (ptr[col] == NUL || (i == 0
34653467
&& (has_mbyte ? this_class != 2 : !vim_iswordc(ptr[col]))))
34663468
{
3467-
// didn't find an identifier or string
3469+
// didn't find an identifier or text
34683470
if ((find_type & FIND_NOERROR) == 0)
34693471
{
34703472
if (find_type & FIND_STRING)
@@ -3475,17 +3477,19 @@ find_ident_at_pos(
34753477
return 0;
34763478
}
34773479
ptr += col;
3478-
*string = ptr;
3480+
*text = ptr;
3481+
if (textcol != NULL)
3482+
*textcol = col;
34793483

34803484
/*
3481-
* 3. Find the end if the identifier/string.
3485+
* 3. Find the end if the identifier/text.
34823486
*/
34833487
bn = 0;
34843488
startcol -= col;
34853489
col = 0;
34863490
if (has_mbyte)
34873491
{
3488-
/* Search for point of changing multibyte character class. */
3492+
// Search for point of changing multibyte character class.
34893493
this_class = mb_get_class(ptr);
34903494
while (ptr[col] != NUL
34913495
&& ((i == 0 ? mb_get_class(ptr + col) == this_class

src/popupwin.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ set_mousemoved_columns(win_T *wp, int flags)
188188
int col;
189189

190190
if (find_word_under_cursor(mouse_row, mouse_col, TRUE, flags,
191-
NULL, NULL, &text, &col) == OK)
191+
NULL, NULL, &text, NULL, &col) == OK)
192192
{
193193
wp->w_popup_mouse_mincol = col;
194194
wp->w_popup_mouse_maxcol = col + STRLEN(text) - 1;
@@ -1437,6 +1437,7 @@ check_mouse_moved(win_T *wp, win_T *mouse_wp)
14371437
{
14381438
typval_T res;
14391439

1440+
ch_log(NULL, "closing popup %d", wp->w_id);
14401441
res.v_type = VAR_NUMBER;
14411442
res.vval.v_number = -2;
14421443
// Careful: this makes "wp" invalid.

src/proto/beval.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* beval.c */
2-
int find_word_under_cursor(int mouserow, int mousecol, int getword, int flags, win_T **winp, linenr_T *lnump, char_u **textp, int *colp);
2+
int find_word_under_cursor(int mouserow, int mousecol, int getword, int flags, win_T **winp, linenr_T *lnump, char_u **textp, int *colp, int *startcolp);
33
int get_beval_info(BalloonEval *beval, int getword, win_T **winp, linenr_T *lnump, char_u **textp, int *colp);
44
void post_balloon(BalloonEval *beval, char_u *mesg, list_T *list);
55
int can_use_beval(void);

src/proto/normal.pro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ void check_visual_highlight(void);
77
void end_visual_mode(void);
88
void reset_VIsual_and_resel(void);
99
void reset_VIsual(void);
10-
int find_ident_under_cursor(char_u **string, int find_type);
11-
int find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char_u **string, int find_type);
10+
int find_ident_under_cursor(char_u **text, int find_type);
11+
int find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char_u **text, int *textcol, int find_type);
1212
void clear_showcmd(void);
1313
int add_to_showcmd(int c);
1414
void add_to_showcmd_c(int c);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,8 @@ static char *(features[]) =
777777

778778
static int included_patches[] =
779779
{ /* Add new patch number below this line */
780+
/**/
781+
1657,
780782
/**/
781783
1656,
782784
/**/

0 commit comments

Comments
 (0)