Skip to content

Commit 5b0c113

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 401db76 + 1bd3cb2 commit 5b0c113

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+749
-160
lines changed

runtime/doc/vim9.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ script and `:def` functions; details are below:
9696
def CallMe(count: number, message: string): bool
9797
- Call functions without `:call`: >
9898
writefile(['done'], 'file.txt')
99-
- You cannot use `:xit`, `:t`, `:append`, `:change`, `:insert` or curly-braces
100-
names.
99+
- You cannot use `:xit`, `:t`, `:k`, `:append`, `:change`, `:insert` or
100+
curly-braces names.
101101
- A range before a command must be prefixed with a colon: >
102102
:%s/this/that
103103
- Unless mentioned specifically, the highest |scriptversion| is used.
@@ -562,11 +562,12 @@ error. A number can be given with and without the []: >
562562
{'456': 'with', '123': 'without'}
563563
564564
565-
No :xit, :t, :append, :change or :insert ~
565+
No :xit, :t, :k, :append, :change or :insert ~
566566

567567
These commands are too easily confused with local variable names.
568568
Instead of `:x` or `:xit` you can use `:exit`.
569569
Instead of `:t` you can use `:copy`.
570+
Instead of `:k` you can use `:mark`.
570571

571572

572573
Comparators ~

src/Make_mvc.mak

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,16 @@ $(NEW_TESTS):
14891489
$(MAKE) /NOLOGO -f Make_dos.mak VIMPROG=..\$(VIMTESTTARGET) report
14901490
cd ..
14911491

1492+
# Run Vim9 tests.
1493+
# These do not depend on the executable, compile it when needed.
1494+
test_vim9:
1495+
cd testdir
1496+
-del test_vim9_*.res
1497+
$(MAKE) /NOLOGO -f Make_dos.mak VIMPROG=..\$(VIMTESTTARGET) nolog
1498+
$(MAKE) /NOLOGO -f Make_dos.mak VIMPROG=..\$(VIMTESTTARGET) $(TEST_VIM9_RES)
1499+
$(MAKE) /NOLOGO -f Make_dos.mak VIMPROG=..\$(VIMTESTTARGET) report
1500+
cd ..
1501+
14921502
###########################################################################
14931503

14941504
# Create a default rule for transforming .c files to .obj files in $(OUTDIR)

src/errors.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,7 @@ EXTERN char e_variable_nr_type_mismatch_expected_str_but_got_str[]
365365
INIT(= N_("E1163: Variable %d: type mismatch, expected %s but got %s"));
366366
EXTERN char e_vim9cmd_must_be_followed_by_command[]
367367
INIT(= N_("E1164: vim9cmd must be followed by a command"));
368+
EXTERN char e_cannot_use_range_with_assignment_str[]
369+
INIT(= N_("E1165: Cannot use a range with an assignment: %s"));
370+
EXTERN char e_cannot_use_range_with_dictionary[]
371+
INIT(= N_("E1166: Cannot use a range with a dictionary"));

src/eval.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,15 +1213,7 @@ get_lval(
12131213

12141214
lp->ll_dict = NULL;
12151215
lp->ll_list = lp->ll_tv->vval.v_list;
1216-
lp->ll_li = list_find(lp->ll_list, lp->ll_n1);
1217-
if (lp->ll_li == NULL)
1218-
{
1219-
if (lp->ll_n1 < 0)
1220-
{
1221-
lp->ll_n1 = 0;
1222-
lp->ll_li = list_find(lp->ll_list, lp->ll_n1);
1223-
}
1224-
}
1216+
lp->ll_li = list_find_index(lp->ll_list, &lp->ll_n1);
12251217
if (lp->ll_li == NULL)
12261218
{
12271219
clear_tv(&var2);

src/evalvars.c

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,27 +1658,9 @@ do_unlet_var(
16581658
return FAIL;
16591659
else if (lp->ll_range)
16601660
{
1661-
listitem_T *li;
1662-
listitem_T *ll_li = lp->ll_li;
1663-
int ll_n1 = lp->ll_n1;
1664-
1665-
while (ll_li != NULL && (lp->ll_empty2 || lp->ll_n2 >= ll_n1))
1666-
{
1667-
li = ll_li->li_next;
1668-
if (value_check_lock(ll_li->li_tv.v_lock, lp->ll_name, FALSE))
1669-
return FAIL;
1670-
ll_li = li;
1671-
++ll_n1;
1672-
}
1673-
1674-
// Delete a range of List items.
1675-
while (lp->ll_li != NULL && (lp->ll_empty2 || lp->ll_n2 >= lp->ll_n1))
1676-
{
1677-
li = lp->ll_li->li_next;
1678-
listitem_remove(lp->ll_list, lp->ll_li);
1679-
lp->ll_li = li;
1680-
++lp->ll_n1;
1681-
}
1661+
if (list_unlet_range(lp->ll_list, lp->ll_li, lp->ll_name, lp->ll_n1,
1662+
!lp->ll_empty2, lp->ll_n2) == FAIL)
1663+
return FAIL;
16821664
}
16831665
else
16841666
{
@@ -1693,6 +1675,43 @@ do_unlet_var(
16931675
return ret;
16941676
}
16951677

1678+
/*
1679+
* Unlet one item or a range of items from a list.
1680+
* Return OK or FAIL.
1681+
*/
1682+
int
1683+
list_unlet_range(
1684+
list_T *l,
1685+
listitem_T *li_first,
1686+
char_u *name,
1687+
long n1_arg,
1688+
int has_n2,
1689+
long n2)
1690+
{
1691+
listitem_T *li = li_first;
1692+
int n1 = n1_arg;
1693+
1694+
while (li != NULL && (!has_n2 || n2 >= n1))
1695+
{
1696+
if (value_check_lock(li->li_tv.v_lock, name, FALSE))
1697+
return FAIL;
1698+
li = li->li_next;
1699+
++n1;
1700+
}
1701+
1702+
// Delete a range of List items.
1703+
li = li_first;
1704+
n1 = n1_arg;
1705+
while (li != NULL && (!has_n2 || n2 >= n1))
1706+
{
1707+
listitem_T *next = li->li_next;
1708+
1709+
listitem_remove(l, li);
1710+
li = next;
1711+
++n1;
1712+
}
1713+
return OK;
1714+
}
16961715
/*
16971716
* "unlet" a variable. Return OK if it existed, FAIL if not.
16981717
* When "forceit" is TRUE don't complain if the variable doesn't exist.

src/ex_cmds.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ EXCMD(CMD_jumps, "jumps", ex_jumps,
741741
EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
742742
ADDR_NONE),
743743
EXCMD(CMD_k, "k", ex_mark,
744-
EX_RANGE|EX_WORD1|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
744+
EX_RANGE|EX_WORD1|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_NONWHITE_OK,
745745
ADDR_LINES),
746746
EXCMD(CMD_keepmarks, "keepmarks", ex_wrongmodifier,
747747
EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM,

src/ex_docmd.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3467,7 +3467,8 @@ find_ex_command(
34673467
/*
34683468
* Isolate the command and search for it in the command table.
34693469
* Exceptions:
3470-
* - the 'k' command can directly be followed by any character.
3470+
* - The 'k' command can directly be followed by any character.
3471+
* But it is not used in Vim9 script.
34713472
* - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r'
34723473
* but :sre[wind] is another command, as are :scr[iptnames],
34733474
* :scs[cope], :sim[alt], :sig[ns] and :sil[ent].
@@ -8072,6 +8073,10 @@ ex_mark(exarg_T *eap)
80728073
{
80738074
pos_T pos;
80748075

8076+
#ifdef FEAT_EVAL
8077+
if (not_in_vim9(eap) == FAIL)
8078+
return;
8079+
#endif
80758080
if (*eap->arg == NUL) // No argument?
80768081
emsg(_(e_argreq));
80778082
else if (eap->arg[1] != NUL) // more than one character?

src/if_py_both.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2815,6 +2815,7 @@ typedef struct
28152815
ListIterDestruct(listiterinfo_T *lii)
28162816
{
28172817
list_rem_watch(lii->list, &lii->lw);
2818+
list_unref(lii->list);
28182819
PyMem_Free(lii);
28192820
}
28202821

@@ -2850,6 +2851,7 @@ ListIter(ListObject *self)
28502851
list_add_watch(l, &lii->lw);
28512852
lii->lw.lw_item = l->lv_first;
28522853
lii->list = l;
2854+
++l->lv_refcount;
28532855

28542856
return IterNew(lii,
28552857
(destructorfun) ListIterDestruct, (nextfun) ListIterNext,

src/list.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,26 @@ list_find_str(list_T *l, long idx)
530530
return tv_get_string(&li->li_tv);
531531
}
532532

533+
/*
534+
* Like list_find() but when a negative index is used that is not found use
535+
* zero and set "idx" to zero. Used for first index of a range.
536+
*/
537+
listitem_T *
538+
list_find_index(list_T *l, long *idx)
539+
{
540+
listitem_T *li = list_find(l, *idx);
541+
542+
if (li == NULL)
543+
{
544+
if (*idx < 0)
545+
{
546+
*idx = 0;
547+
li = list_find(l, *idx);
548+
}
549+
}
550+
return li;
551+
}
552+
533553
/*
534554
* Locate "item" list "l" and return its index.
535555
* Returns -1 when "item" is not in the list.
@@ -2125,6 +2145,7 @@ filter_map(typval_T *argvars, typval_T *rettv, filtermap_T filtermap)
21252145
arg_errmsg, TRUE)))
21262146
break;
21272147
set_vim_var_string(VV_KEY, di->di_key, -1);
2148+
newtv.v_type = VAR_UNKNOWN;
21282149
r = filter_map_one(&di->di_tv, expr, filtermap,
21292150
&newtv, &rem);
21302151
clear_tv(get_vim_var_tv(VV_KEY));

src/match.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,15 @@ update_search_hl(
792792
// highlight empty match, try again after
793793
// it
794794
if (has_mbyte)
795-
shl->endcol += (*mb_ptr2len)(*line + shl->endcol);
795+
{
796+
char_u *p = *line + shl->endcol;
797+
798+
if (*p == NUL)
799+
// consistent with non-mbyte
800+
++shl->endcol;
801+
else
802+
shl->endcol += (*mb_ptr2len)(p);
803+
}
796804
else
797805
++shl->endcol;
798806
}
@@ -842,18 +850,31 @@ get_prevcol_hl_flag(win_T *wp, match_T *search_hl, long curcol)
842850
int prevcol_hl_flag = FALSE;
843851
matchitem_T *cur; // points to the match list
844852

853+
#if defined(FEAT_PROP_POPUP)
854+
// don't do this in a popup window
855+
if (popup_is_popup(wp))
856+
return FALSE;
857+
#endif
858+
845859
// we're not really at that column when skipping some text
846860
if ((long)(wp->w_p_wrap ? wp->w_skipcol : wp->w_leftcol) > prevcol)
847861
++prevcol;
848862

849-
if (!search_hl->is_addpos && prevcol == (long)search_hl->startcol)
863+
// Highlight a character after the end of the line if the match started
864+
// at the end of the line or when the match continues in the next line
865+
// (match includes the line break).
866+
if (!search_hl->is_addpos && (prevcol == (long)search_hl->startcol
867+
|| (prevcol > (long)search_hl->startcol
868+
&& search_hl->endcol == MAXCOL)))
850869
prevcol_hl_flag = TRUE;
851870
else
852871
{
853872
cur = wp->w_match_head;
854873
while (cur != NULL)
855874
{
856-
if (!cur->hl.is_addpos && prevcol == (long)cur->hl.startcol)
875+
if (!cur->hl.is_addpos && (prevcol == (long)cur->hl.startcol
876+
|| (prevcol > (long)cur->hl.startcol
877+
&& cur->hl.endcol == MAXCOL)))
857878
{
858879
prevcol_hl_flag = TRUE;
859880
break;

0 commit comments

Comments
 (0)