Skip to content

Commit 48288d2

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 86c5ff6 + af8af8b commit 48288d2

File tree

6 files changed

+69
-28
lines changed

6 files changed

+69
-28
lines changed

src/eval.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3737,24 +3737,27 @@ do_unlet(name, forceit)
37373737
ht = find_var_ht(name, &varname);
37383738
if (ht != NULL && *varname != NUL)
37393739
{
3740-
if (ht == &globvarht)
3741-
d = &globvardict;
3742-
else if (current_funccal != NULL
3743-
&& ht == &current_funccal->l_vars.dv_hashtab)
3744-
d = &current_funccal->l_vars;
3745-
else
3746-
{
3747-
di = find_var_in_ht(ht, *name, (char_u *)"", FALSE);
3748-
d = di->di_tv.vval.v_dict;
3749-
}
37503740
hi = hash_find(ht, varname);
37513741
if (!HASHITEM_EMPTY(hi))
37523742
{
37533743
di = HI2DI(hi);
37543744
if (var_check_fixed(di->di_flags, name, FALSE)
3755-
|| var_check_ro(di->di_flags, name, FALSE)
3756-
|| tv_check_lock(d->dv_lock, name, FALSE))
3745+
|| var_check_ro(di->di_flags, name, FALSE))
37573746
return FAIL;
3747+
3748+
if (ht == &globvarht)
3749+
d = &globvardict;
3750+
else if (current_funccal != NULL
3751+
&& ht == &current_funccal->l_vars.dv_hashtab)
3752+
d = &current_funccal->l_vars;
3753+
else
3754+
{
3755+
di = find_var_in_ht(ht, *name, (char_u *)"", FALSE);
3756+
d = di->di_tv.vval.v_dict;
3757+
}
3758+
if (d == NULL || tv_check_lock(d->dv_lock, name, FALSE))
3759+
return FAIL;
3760+
37583761
delete_var(ht, hi);
37593762
return OK;
37603763
}

src/ops.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6974,7 +6974,9 @@ cursor_pos_info(dict)
69746974
char_u buf2[40];
69756975
linenr_T lnum;
69766976
long byte_count = 0;
6977+
#ifdef FEAT_MBYTE
69776978
long bom_count = 0;
6979+
#endif
69786980
long byte_count_cursor = 0;
69796981
long char_count = 0;
69806982
long char_count_cursor = 0;
@@ -7190,15 +7192,15 @@ cursor_pos_info(dict)
71907192
}
71917193
}
71927194

7193-
/* Don't shorten this message, the user asked for it. */
71947195
#ifdef FEAT_MBYTE
71957196
bom_count = bomb_size();
71967197
if (bom_count > 0)
7197-
sprintf((char *)IObuff + STRLEN(IObuff), _("(+%ld for BOM)"),
7198-
bom_count);
7198+
vim_snprintf((char *)IObuff + STRLEN(IObuff), IOSIZE,
7199+
_("(+%ld for BOM)"), bom_count);
71997200
#endif
72007201
if (dict == NULL)
72017202
{
7203+
/* Don't shorten this message, the user asked for it. */
72027204
p = p_shm;
72037205
p_shm = (char_u *)"";
72047206
msg(IObuff);
@@ -7210,19 +7212,17 @@ cursor_pos_info(dict)
72107212
{
72117213
dict_add_nr_str(dict, "words", (long)word_count, NULL);
72127214
dict_add_nr_str(dict, "chars", (long)char_count, NULL);
7213-
dict_add_nr_str(dict, "bytes", (long)byte_count + bom_count, NULL);
7214-
if (VIsual_active)
7215-
{
7216-
dict_add_nr_str(dict, "visual_bytes", (long)byte_count_cursor, NULL);
7217-
dict_add_nr_str(dict, "visual_chars", (long)char_count_cursor, NULL);
7218-
dict_add_nr_str(dict, "visual_words", (long)word_count_cursor, NULL);
7219-
}
7220-
else
7221-
{
7222-
dict_add_nr_str(dict, "cursor_bytes", (long)byte_count_cursor, NULL);
7223-
dict_add_nr_str(dict, "cursor_chars", (long)char_count_cursor, NULL);
7224-
dict_add_nr_str(dict, "cursor_words", (long)word_count_cursor, NULL);
7225-
}
7215+
dict_add_nr_str(dict, "bytes", (long)byte_count
7216+
# ifdef FEAT_MBYTE
7217+
+ bom_count
7218+
# endif
7219+
, NULL);
7220+
dict_add_nr_str(dict, VIsual_active ? "visual_bytes" : "cursor_bytes",
7221+
(long)byte_count_cursor, NULL);
7222+
dict_add_nr_str(dict, VIsual_active ? "visual_chars" : "cursor_chars",
7223+
(long)char_count_cursor, NULL);
7224+
dict_add_nr_str(dict, VIsual_active ? "visual_words" : "cursor_words",
7225+
(long)word_count_cursor, NULL);
72267226
}
72277227
#endif
72287228
}

src/testdir/test_alot.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ source test_searchpos.vim
88
source test_set.vim
99
source test_sort.vim
1010
source test_undolevels.vim
11+
source test_unlet.vim

src/testdir/test_unlet.vim

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
" Tests for :unlet
2+
3+
func Test_read_only()
4+
try
5+
" this caused a crash
6+
unlet count
7+
catch
8+
call assert_true(v:exception =~ ':E795:')
9+
endtry
10+
endfunc
11+
12+
func Test_existing()
13+
let does_exist = 1
14+
call assert_true(exists('does_exist'))
15+
unlet does_exist
16+
call assert_false(exists('does_exist'))
17+
endfunc
18+
19+
func Test_not_existing()
20+
unlet! does_not_exist
21+
try
22+
unlet does_not_exist
23+
catch
24+
call assert_true(v:exception =~ ':E108:')
25+
endtry
26+
endfunc

src/testdir/test_wordcount.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ STARTTEST
44
:so small.vim
55
:so mbyte.vim
66
:set enc=utf8
7+
:set selection=inclusive fileformat=unix fileformats=unix
78
:new
89
:fu DoRecordWin(...)
910
: wincmd k

src/version.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,16 @@ static char *(features[]) =
756756

757757
static int included_patches[] =
758758
{ /* Add new patch number below this line */
759+
/**/
760+
1051,
761+
/**/
762+
1050,
763+
/**/
764+
1049,
765+
/**/
766+
1048,
767+
/**/
768+
1047,
759769
/**/
760770
1046,
761771
/**/

0 commit comments

Comments
 (0)