Skip to content

Commit 486f4fd

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 273e46e + 7964873 commit 486f4fd

30 files changed

Lines changed: 721 additions & 158 deletions

runtime/doc/options.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5776,7 +5776,16 @@ A jump table for the options with a short description can be found at |Q_op|.
57765776
{not available when compiled without the |+windows| or
57775777
|+quickfix| features}
57785778
Default height for a preview window. Used for |:ptag| and associated
5779-
commands. Used for |CTRL-W_}| when no count is given.
5779+
commands. Used for |CTRL-W_}| when no count is given. Not used when
5780+
'previewpopup' is set.
5781+
5782+
*'previewpopup'* *'pvp'*
5783+
'previewpopup' 'pvp' string (default empty)
5784+
global
5785+
{not available when compiled without the |+windows|,
5786+
|+textprop| or |+quickfix| feature}
5787+
When not empty a popup window is used for commands that would open a
5788+
preview window. See |preview-popup|.
57805789

57815790
*'previewwindow'* *'nopreviewwindow'*
57825791
*'pvw'* *'nopvw'* *E590*

runtime/doc/popup.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ popup_getoptions({id}) *popup_getoptions()*
303303
zero. When all values are one then an empty list is included.
304304

305305
"borderhighlight" is not included when all values are empty.
306-
"scrollbarhighlight" and "thumbhighlight" are onlu included
306+
"scrollbarhighlight" and "thumbhighlight" are only included
307307
when set.
308308

309309
"tabpage" will be -1 for a global popup, zero for a popup on
@@ -345,7 +345,7 @@ popup_hide({id}) *popup_hide()*
345345

346346

347347
popup_locate({row}, {col}) *popup_locate()*
348-
Return the |window-ID| of the popup at screen positoin {row}
348+
Return the |window-ID| of the popup at screen position {row}
349349
and {col}. If there are multiple popups the one with the
350350
highest zindex is returned. If there are no popups at this
351351
position then zero is returned.
@@ -362,6 +362,7 @@ popup_menu({what}, {options}) *popup_menu()*
362362
\ drag: 1,
363363
\ wrap: 0,
364364
\ border: [],
365+
\ cursorline: 1,
365366
\ padding: [0,1,0,1],
366367
\ filter: 'popup_filter_menu',
367368
\ })
@@ -429,6 +430,7 @@ popup_setoptions({id}, {options}) *popup_setoptions()*
429430
callback
430431
close
431432
drag
433+
cursorline
432434
filter
433435
firstline
434436
flip
@@ -598,6 +600,11 @@ The second argument of |popup_create()| is a dictionary with options:
598600
{start} or after {end}
599601
The popup also closes if the cursor moves to another
600602
line or to another window.
603+
cursorline non-zero: Highlight the cursor line. Also scrolls the
604+
text to show this line (only works properly
605+
when 'wrap' is off).
606+
zero: Do not highlight the cursor line.
607+
Default is zero, except for |popup_menu()|.
601608
filter A callback that can filter typed characters, see
602609
|popup-filter|.
603610
callback A callback that is called when the popup closes, e.g.
@@ -695,8 +702,8 @@ If the text does not fit in the popup a scrollbar is displayed on the right of
695702
the window. This can be disabled by setting the "scrollbar" option to zero.
696703
When the scrollbar is displayed mouse scroll events, while the mouse pointer
697704
is on the popup, will cause the text to scroll up or down as you would expect.
698-
A click in the upper halve of the scrollbar will scroll the text one line
699-
down. A click in the lower halve wil scroll the text one line up. However,
705+
A click in the upper half of the scrollbar will scroll the text one line
706+
down. A click in the lower half wil scroll the text one line up. However,
700707
this is limited so that the popup does not get smaller.
701708

702709

@@ -709,7 +716,7 @@ list has four numbers:
709716
leftmost, negative for counting from the right, -1 for
710717
rightmost
711718
endcol last column, like "col"
712-
line start line, positive for conting from the top, 1 for top,
719+
line start line, positive for counting from the top, 1 for top,
713720
negative for counting from the bottom, -1 for bottom
714721
endline end line, like "line"
715722

runtime/doc/windows.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,15 @@ height of the preview window when it's opened. The 'previewwindow' option is
864864
set in the preview window to be able to recognize it. The 'winfixheight'
865865
option is set to have it keep the same height when opening/closing other
866866
windows.
867-
867+
*preview-popup*
868+
Alternatively, a popup window can be used by setting the 'previewpopup'
869+
option. When set, it overrules the 'previewwindow' and 'previewheight'
870+
settings. The option is a comma separated list of values:
871+
height maximum height of the popup
872+
width maximu width of the popup
873+
Example: >
874+
:set previewpopup=height:10,width:60
875+
<
868876
*:pta* *:ptag*
869877
:pta[g][!] [tagname]
870878
Does ":tag[!] [tagname]" and shows the found tag in a

src/beval.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include "vim.h"
1212

13-
#if defined(FEAT_BEVAL) || defined(FEAT_TEXT_PROP) || defined(PROT)
13+
#if defined(FEAT_BEVAL) || defined(FEAT_TEXT_PROP) || defined(PROTO)
1414
/*
1515
* Find text under the mouse position "row" / "col".
1616
* If "getword" is TRUE the returned text in "*textp" is not the whole line but
@@ -72,6 +72,7 @@ find_word_under_cursor(
7272
}
7373

7474
col = vcol2col(wp, lnum, col);
75+
scol = col;
7576

7677
if (VIsual_active
7778
&& wp->w_buffer == curwin->w_buffer
@@ -95,6 +96,7 @@ find_word_under_cursor(
9596
lbuf = vim_strnsave(lbuf + spos->col, len);
9697
lnum = spos->lnum;
9798
col = spos->col;
99+
scol = col;
98100
}
99101
else
100102
{

src/change.c

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,16 @@ changed_internal(void)
155155
static long next_listener_id = 0;
156156

157157
/*
158-
* Check if the change at "lnum" / "col" is above or overlaps with an existing
159-
* changed. If above then flush changes and invoke listeners.
160-
* If "merge" is TRUE do the merge.
158+
* Check if the change at "lnum" is above or overlaps with an existing
159+
* change. If above then flush changes and invoke listeners.
161160
* Returns TRUE if the change was merged.
162161
*/
163162
static int
164163
check_recorded_changes(
165164
buf_T *buf,
166165
linenr_T lnum,
167-
colnr_T col,
168166
linenr_T lnume,
169-
long xtra,
170-
int merge)
167+
long xtra)
171168
{
172169
if (buf->b_recorded_changes != NULL && xtra != 0)
173170
{
@@ -182,42 +179,12 @@ check_recorded_changes(
182179
li->li_tv.vval.v_dict, (char_u *)"lnum");
183180
prev_lnume = (linenr_T)dict_get_number(
184181
li->li_tv.vval.v_dict, (char_u *)"end");
185-
if (prev_lnum >= lnum || prev_lnum > lnume
186-
|| (prev_lnume >= lnum && xtra != 0))
182+
if (prev_lnum >= lnum || prev_lnum > lnume || prev_lnume >= lnum)
187183
{
188-
if (li->li_next == NULL && lnum == prev_lnum
189-
&& xtra == 0
190-
&& col + 1 == (colnr_T)dict_get_number(
191-
li->li_tv.vval.v_dict, (char_u *)"col"))
192-
{
193-
if (merge)
194-
{
195-
dictitem_T *di;
196-
197-
// Same start point and nothing is following, entries
198-
// can be merged.
199-
di = dict_find(li->li_tv.vval.v_dict,
200-
(char_u *)"end", -1);
201-
if (di != NULL)
202-
{
203-
prev_lnum = tv_get_number(&di->di_tv);
204-
if (lnume > prev_lnum)
205-
di->di_tv.vval.v_number = lnume;
206-
}
207-
di = dict_find(li->li_tv.vval.v_dict,
208-
(char_u *)"added", -1);
209-
if (di != NULL)
210-
di->di_tv.vval.v_number += xtra;
211-
return TRUE;
212-
}
213-
}
214-
else
215-
{
216-
// the current change is going to make the line number in
217-
// the older change invalid, flush now
218-
invoke_listeners(curbuf);
219-
break;
220-
}
184+
// the current change is going to make the line number in
185+
// the older change invalid, flush now
186+
invoke_listeners(curbuf);
187+
break;
221188
}
222189
}
223190
}
@@ -242,7 +209,7 @@ may_record_change(
242209

243210
// If the new change is going to change the line numbers in already listed
244211
// changes, then flush.
245-
if (check_recorded_changes(curbuf, lnum, col, lnume, xtra, TRUE))
212+
if (check_recorded_changes(curbuf, lnum, lnume, xtra))
246213
return;
247214

248215
if (curbuf->b_recorded_changes == NULL)
@@ -362,7 +329,7 @@ f_listener_remove(typval_T *argvars, typval_T *rettv)
362329
void
363330
may_invoke_listeners(buf_T *buf, linenr_T lnum, linenr_T lnume, int added)
364331
{
365-
check_recorded_changes(buf, lnum, 0, lnume, added, FALSE);
332+
check_recorded_changes(buf, lnum, lnume, added);
366333
}
367334

368335
/*

src/ex_cmds.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6270,28 +6270,42 @@ prepare_tagpreview(
62706270
*/
62716271
if (!curwin->w_p_pvw)
62726272
{
6273-
FOR_ALL_WINDOWS(wp)
6274-
if (wp->w_p_pvw)
6275-
break;
6273+
# ifdef FEAT_TEXT_PROP
6274+
if (*p_pvp != NUL)
6275+
{
6276+
wp = popup_find_preview_window();
6277+
if (wp != NULL)
6278+
popup_set_wantpos(wp);
6279+
}
6280+
else
6281+
# endif
6282+
{
6283+
FOR_ALL_WINDOWS(wp)
6284+
if (wp->w_p_pvw)
6285+
break;
6286+
}
62766287
if (wp != NULL)
62776288
win_enter(wp, undo_sync);
62786289
else
62796290
{
62806291
/*
62816292
* There is no preview window open yet. Create one.
62826293
*/
6283-
if (win_split(g_do_tagpreview > 0 ? g_do_tagpreview : 0, 0)
6284-
== FAIL)
6294+
# ifdef FEAT_TEXT_PROP
6295+
if (*p_pvp != NUL)
6296+
return popup_create_preview_window();
6297+
# endif
6298+
if (win_split(g_do_tagpreview > 0 ? g_do_tagpreview : 0, 0) == FAIL)
62856299
return FALSE;
62866300
curwin->w_p_pvw = TRUE;
62876301
curwin->w_p_wfh = TRUE;
6288-
RESET_BINDING(curwin); /* don't take over 'scrollbind'
6289-
and 'cursorbind' */
6302+
RESET_BINDING(curwin); // don't take over 'scrollbind'
6303+
// and 'cursorbind'
62906304
# ifdef FEAT_DIFF
6291-
curwin->w_p_diff = FALSE; /* no 'diff' */
6305+
curwin->w_p_diff = FALSE; // no 'diff'
62926306
# endif
62936307
# ifdef FEAT_FOLDING
6294-
curwin->w_p_fdc = 0; /* no 'foldcolumn' */
6308+
curwin->w_p_fdc = 0; // no 'foldcolumn'
62956309
# endif
62966310
return TRUE;
62976311
}

src/ex_docmd.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5908,12 +5908,17 @@ ex_pclose(exarg_T *eap)
59085908
{
59095909
win_T *win;
59105910

5911+
// First close any normal window.
59115912
FOR_ALL_WINDOWS(win)
59125913
if (win->w_p_pvw)
59135914
{
59145915
ex_win_close(eap->forceit, win, NULL);
5915-
break;
5916+
return;
59165917
}
5918+
# ifdef FEAT_TEXT_PROP
5919+
// Also when 'previewpopup' is empty, it might have been cleared.
5920+
popup_close_preview();
5921+
# endif
59175922
}
59185923
#endif
59195924

src/memline.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,6 +3566,15 @@ adjust_text_props_for_delete(
35663566
ml_delete(linenr_T lnum, int message)
35673567
{
35683568
ml_flush_line(curbuf);
3569+
if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count)
3570+
return FAIL;
3571+
3572+
#ifdef FEAT_EVAL
3573+
// When inserting above recorded changes: flush the changes before changing
3574+
// the text.
3575+
may_invoke_listeners(curbuf, lnum, lnum + 1, -1);
3576+
#endif
3577+
35693578
return ml_delete_int(curbuf, lnum, message);
35703579
}
35713580

@@ -3590,14 +3599,6 @@ ml_delete_int(buf_T *buf, linenr_T lnum, int message)
35903599
int textprop_save_len;
35913600
#endif
35923601

3593-
if (lnum < 1 || lnum > buf->b_ml.ml_line_count)
3594-
return FAIL;
3595-
3596-
#ifdef FEAT_EVAL
3597-
// When inserting above recorded changes: flush the changes before changing
3598-
// the text.
3599-
may_invoke_listeners(buf, lnum, lnum + 1, -1);
3600-
#endif
36013602
if (lowest_marked && lowest_marked > lnum)
36023603
lowest_marked--;
36033604

src/option.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,15 @@ static struct vimoption options[] =
21552155
(char_u *)NULL, PV_NONE,
21562156
#endif
21572157
{(char_u *)12L, (char_u *)0L} SCTX_INIT},
2158+
{"previewpopup", "pvp", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2159+
#ifdef FEAT_TEXT_PROP
2160+
(char_u *)&p_pvp, PV_NONE,
2161+
{(char_u *)"", (char_u *)0L}
2162+
#else
2163+
(char_u *)NULL, PV_NONE,
2164+
{(char_u *)NULL, (char_u *)0L}
2165+
#endif
2166+
SCTX_INIT},
21582167
{"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
21592168
#if defined(FEAT_QUICKFIX)
21602169
(char_u *)VAR_WIN, PV_PVW,
@@ -7954,6 +7963,15 @@ did_set_string_option(
79547963
}
79557964
#endif
79567965

7966+
#ifdef FEAT_TEXT_PROP
7967+
// 'previewpopup'
7968+
else if (varp == &p_pvp)
7969+
{
7970+
if (parse_previewpopup(NULL) == FAIL)
7971+
errmsg = e_invarg;
7972+
}
7973+
#endif
7974+
79577975
/* Options that are a list of flags. */
79587976
else
79597977
{

src/option.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,9 @@ EXTERN int fuoptions_bgcolor;
511511
argb color. */
512512
#endif
513513
EXTERN int p_gd; /* 'gdefault' */
514+
#ifdef FEAT_TEXT_PROP
515+
EXTERN char_u *p_pvp; // 'previewpopup'
516+
#endif
514517
#ifdef FEAT_PRINTER
515518
EXTERN char_u *p_pdev; /* 'printdevice' */
516519
# ifdef FEAT_POSTSCRIPT

0 commit comments

Comments
 (0)