Compare commits

...

20 Commits

Author SHA1 Message Date
Bram Moolenaar
4bc2f2e9fd patch 8.0.0249: CI failure when a submit is close to previous one
Problem:    When two submits happen quick after each other, the tests for the
            first one may error out.
Solution:   Use a git depth of 10 instead of 1. (Christian Brabandt)
2017-01-27 22:20:13 +01:00
Bram Moolenaar
45600ce8f2 patch 8.0.0248: vim_strcat() cannot handle overlapping arguments
Problem:    vim_strcat() cannot handle overlapping arguments.
Solution:   Use mch_memmove() instead of strcpy(). (Justin M Keyes,
            closes #1415)
2017-01-27 21:54:07 +01:00
Bram Moolenaar
aed6d0b81a patch 8.0.0247: need to type Ctrl-N twice to select a completion
Problem:    Under some circumstances, one needs to type Ctrl-N or Ctrl-P twice
            to have a menu entry selected. (Lifepillar)
Solution:   call ins_compl_free(). (Christian Brabandt, closes #1411)
2017-01-27 21:48:54 +01:00
Bram Moolenaar
3a118be150 patch 8.0.0246: compiler warnings for int to pointer conversion
Problem:    Compiler warnings for int to pointer conversion.
Solution:   Fix macro for mch_memmove(). (John Marriott)
2017-01-27 21:22:19 +01:00
Bram Moolenaar
16038d50c4 patch 8.0.0245: zh_CN.cp936.po has a conversion error
Problem:    The generated zh_CN.cp936.po message file is not encoded properly.
Solution:   Instead of using zh_CN.po as input, use zh_CN.UTF-8.po.
2017-01-27 20:37:49 +01:00
Bram Moolenaar
d9c60648e5 patch 8.0.0244: making t_BE empty only has an effect before startup
Problem:    When the user sets t_BE empty after startup to disable bracketed
            paste, this has no direct effect.
Solution:   When t_BE is made empty write t_BD.  When t_BE is made non-empty
            write the new value.
2017-01-27 20:03:18 +01:00
Bram Moolenaar
cc5b22b3bf patch 8.0.0243: tolower() does not work if the byte count changes
Problem:    When making a character lower case with tolower() changes the byte
            cound, it is not made lower case.
Solution:   Add strlow_save(). (Dominique Pelle, closes #1406)
2017-01-26 22:51:56 +01:00
Bram Moolenaar
65c836e600 patch 8.0.0242: no tests for user command completion
Problem:    Completion of user defined functions is not covered by tests.
Solution:   Add tests.  Also test various errors of user-defined commands.
            (Dominique Pelle, closes #1413)
2017-01-26 22:07:33 +01:00
Bram Moolenaar
52c0de1de1 patch 8.0.0241: fallback implementation of mch_memmove is unused
Problem:    Vim defines a mch_memmove() function but it doesn't work, thus is
            always unused.
Solution:   Remove the mch_memmove implementation. (suggested by Dominique
            Pelle)
2017-01-26 21:36:34 +01:00
Bram Moolenaar
4f7090b93d patch 8.0.0240: failure with one build on CI
Problem:    The clang build on CI fails with one configuration.
Solution:   Redo a previous patch that was accidentally reverted.
2017-01-26 21:24:02 +01:00
Bram Moolenaar
1e07633a5d patch 8.0.0239: no CI with an address sanitizer
Problem:    The address sanitizer sometimes finds errors, but it needs to be
            run manually.
Solution:   Add an environment to Travis with clang and the address sanitizer.
            (Christian Brabandt)  Also include changes only on github.
2017-01-26 20:11:12 +01:00
Bram Moolenaar
9e817c8a31 patch 8.0.0238: bracketed paste does not disable autoindent
Problem:    When using bracketed paste autoindent causes indent to be
            increased.
Solution:   Disable 'ai' and set 'paste' temporarily. (Ken Takata)
2017-01-25 21:36:17 +01:00
Bram Moolenaar
ba47b51ff8 patch 8.0.0237: when 'wildoptions' is "tagfile" completion may not work
Problem:    When setting wildoptions=tagfile the completion context is not set
            correctly. (desjardins)
Solution:   Check for EXPAND_TAGS_LISTFILES. (Christian Brabandt, closes #1399)
2017-01-24 21:18:19 +01:00
Bram Moolenaar
6a717f17ec patch 8.0.0236: gcc complains about uninitialized variable
Problem:    Gcc complains that a variable may be used uninitialized. Confusion
            between variable and label name. (John Marriott)
Solution:   Initialize it.  Rename end to end_lnum.
2017-01-24 20:47:50 +01:00
Bram Moolenaar
b031c4ea04 patch 8.0.0235: memory leak in diff mode
Problem:    Memory leak detected when running tests for diff mode.
Solution:   Free p_extra_free.
2017-01-24 20:14:48 +01:00
Bram Moolenaar
941c12da3c patch 8.0.0234: crash when using put in Visual mode
Problem:    When several lines are visually selected and one of them is short,
            using put may cause a crash. (Axel Bender)
Solution:   Check for a short line. (Christian Brabandt)
2017-01-24 19:55:43 +01:00
Bram Moolenaar
bff6ad1331 patch 8.0.0233: paste test fails in the GUI
Problem:    The paste test fails if the GUI is being used.
Solution:   Skip the test in the GUI.
2017-01-24 19:18:13 +01:00
Bram Moolenaar
48c9f3b123 patch 8.0.0232: paste does not work when 'esckeys' is off
Problem:    Pasting in Insert mode does not work when bracketed paste is used
            and 'esckeys' is off.
Solution:   When 'esckeys' is off disable bracketed paste in Insert mode.
2017-01-24 19:08:15 +01:00
Bram Moolenaar
076e502199 patch 8.0.0231: bracketed paste mode is not tested
Problem:    There are no tests for bracketed paste mode.
Solution:   Add a test.  Fix repeating with "normal .".
2017-01-24 18:58:30 +01:00
Bram Moolenaar
915350edec patch 8.0.0230: bracketed paste does not support line breaks
Problem:    When using bracketed paste line breaks are not respected.
Solution:   Turn CR characters into a line break if the text is being
            inserted. (closes #1404)
2017-01-24 17:50:52 +01:00
21 changed files with 555 additions and 100 deletions

View File

@@ -18,13 +18,16 @@ env:
# Mac OSX build
- BUILD=yes TEST=test COVERAGE=no FEATURES=huge SHADOWOPT= SRCDIR=./src CHECK_AUTOCONF=no
"CONFOPT='--enable-perlinterp --enable-pythoninterp --enable-rubyinterp --enable-luainterp'"
# ASAN build
- BUILD=yes TEST=test SANITIZER_CFLAGS="-g -O1 -fsanitize=address -fno-omit-frame-pointer" FEATURES=huge SRCDIR=./src CHECK_AUTOCONF=no
"CONFOPT='--enable-perlinterp --enable-pythoninterp --enable-rubyinterp --enable-luainterp'"
sudo: false
git:
depth: 1
depth: 10
# instead of a 6*2*2 matrix (2*os + 2*compiler + 6*env),
# instead of a 2*2*8 matrix (2*os + 2*compiler + 8*env),
# exclude some builds on mac os x and linux
# linux: 2*compiler + 5*env + mac: 2*compiler + 2*env
matrix:
@@ -38,6 +41,13 @@ matrix:
- os: osx
env: BUILD=yes TEST=scripttests COVERAGE=yes CFLAGS=--coverage LDFLAGS=--coverage FEATURES=huge SHADOWOPT= SRCDIR=./src CHECK_AUTOCONF=no
"CONFOPT='--enable-perlinterp --enable-pythoninterp --enable-python3interp --enable-rubyinterp --enable-luainterp'"
- os: osx
env: BUILD=yes TEST=test SANITIZER_CFLAGS="-g -O1 -fsanitize=address -fno-omit-frame-pointer" FEATURES=huge SRCDIR=./src CHECK_AUTOCONF=no
"CONFOPT='--enable-perlinterp --enable-pythoninterp --enable-rubyinterp --enable-luainterp'"
- os: linux
compiler: gcc
env: BUILD=yes TEST=test SANITIZER_CFLAGS="-g -O1 -fsanitize=address -fno-omit-frame-pointer" FEATURES=huge SRCDIR=./src CHECK_AUTOCONF=no
"CONFOPT='--enable-perlinterp --enable-pythoninterp --enable-rubyinterp --enable-luainterp'"
- os: linux
compiler: clang
env: BUILD=no TEST=unittests COVERAGE=yes CFLAGS=--coverage LDFLAGS=--coverage FEATURES=huge SHADOWOPT= SRCDIR=./src CHECK_AUTOCONF=yes

View File

@@ -2147,6 +2147,7 @@ test_arglist \
test_options \
test_packadd \
test_partial \
test_paste \
test_perl \
test_popup \
test_profile \
@@ -2161,9 +2162,9 @@ test_arglist \
test_searchpos \
test_set \
test_signs \
test_smartindent \
test_sort \
test_source_utf8 \
test_smartindent \
test_startup \
test_startup_utf8 \
test_stat \

View File

@@ -463,7 +463,10 @@ edit(
else
#endif
{
AppendCharToRedobuff(cmdchar);
if (cmdchar == K_PS)
AppendCharToRedobuff('a');
else
AppendCharToRedobuff(cmdchar);
if (cmdchar == 'g') /* "gI" command */
AppendCharToRedobuff('I');
else if (cmdchar == 'r') /* "r<CR>" command */
@@ -531,6 +534,10 @@ edit(
revins_legal = 0;
revins_scol = -1;
#endif
if (!p_ek)
/* Disable bracketed paste mode, we won't recognize the escape
* sequences. */
out_str(T_BD);
/*
* Handle restarting Insert mode.
@@ -2814,6 +2821,7 @@ set_completion(colnr_T startcol, list_T *list)
if (ctrl_x_mode != 0)
ins_compl_prep(' ');
ins_compl_clear();
ins_compl_free();
compl_direction = FORWARD;
if (startcol > curwin->w_cursor.col)
@@ -8620,6 +8628,9 @@ ins_esc(
#ifdef CURSOR_SHAPE
ui_cursor_shape(); /* may show different cursor shape */
#endif
if (!p_ek)
/* Re-enable bracketed paste mode. */
out_str(T_BE);
/*
* When recording or for CTRL-O, need to display the new mode.
@@ -9453,12 +9464,17 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
char_u *end = find_termcode((char_u *)"PE");
int ret_char = -1;
int save_allow_keys = allow_keys;
int save_paste = p_paste;
int save_ai = curbuf->b_p_ai;
/* If the end code is too long we can't detect it, read everything. */
if (STRLEN(end) >= NUMBUFLEN)
end = NULL;
++no_mapping;
allow_keys = 0;
p_paste = TRUE;
curbuf->b_p_ai = FALSE;
for (;;)
{
/* When the end is not defined read everything. */
@@ -9498,8 +9514,14 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
case PASTE_INSERT:
if (stop_arrow() == OK)
{
ins_char_bytes(buf, idx);
AppendToRedobuffLit(buf, idx);
c = buf[0];
if (idx == 1 && (c == CAR || c == K_KENTER || c == NL))
ins_eol(c);
else
{
ins_char_bytes(buf, idx);
AppendToRedobuffLit(buf, idx);
}
}
break;
@@ -9518,8 +9540,11 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
}
idx = 0;
}
--no_mapping;
allow_keys = save_allow_keys;
p_paste = save_paste;
curbuf->b_p_ai = save_ai;
return ret_char;
}

View File

@@ -12503,39 +12503,8 @@ f_timer_stopall(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
static void
f_tolower(typval_T *argvars, typval_T *rettv)
{
char_u *p;
p = vim_strsave(get_tv_string(&argvars[0]));
rettv->v_type = VAR_STRING;
rettv->vval.v_string = p;
if (p != NULL)
while (*p != NUL)
{
#ifdef FEAT_MBYTE
int l;
if (enc_utf8)
{
int c, lc;
c = utf_ptr2char(p);
lc = utf_tolower(c);
l = utf_ptr2len(p);
/* TODO: reallocate string when byte count changes. */
if (utf_char2len(lc) == l)
utf_char2bytes(lc, p);
p += l;
}
else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
p += l; /* skip multi-byte character */
else
#endif
{
*p = TOLOWER_LOC(*p); /* note that tolower() can be a macro */
++p;
}
}
rettv->vval.v_string = strlow_save(get_tv_string(&argvars[0]));
}
/*

View File

@@ -4366,7 +4366,9 @@ addstar(
|| context == EXPAND_OWNSYNTAX
|| context == EXPAND_FILETYPE
|| context == EXPAND_PACKADD
|| (context == EXPAND_TAGS && fname[0] == '/'))
|| ((context == EXPAND_TAGS_LISTFILES
|| context == EXPAND_TAGS)
&& fname[0] == '/'))
retval = vim_strnsave(fname, len);
else
{

View File

@@ -1602,7 +1602,10 @@ strup_save(char_u *orig)
{
s = alloc((unsigned)STRLEN(res) + 1 + newl - l);
if (s == NULL)
break;
{
vim_free(res);
return NULL;
}
mch_memmove(s, res, p - res);
STRCPY(s + (p - res) + newl, p + l);
p = s + (p - res);
@@ -1625,6 +1628,69 @@ strup_save(char_u *orig)
return res;
}
/*
* Make string "s" all lower-case and return it in allocated memory.
* Handles multi-byte characters as well as possible.
* Returns NULL when out of memory.
*/
char_u *
strlow_save(char_u *orig)
{
char_u *p;
char_u *res;
res = p = vim_strsave(orig);
if (res != NULL)
while (*p != NUL)
{
# ifdef FEAT_MBYTE
int l;
if (enc_utf8)
{
int c, lc;
int newl;
char_u *s;
c = utf_ptr2char(p);
lc = utf_tolower(c);
/* Reallocate string when byte count changes. This is rare,
* thus it's OK to do another malloc()/free(). */
l = utf_ptr2len(p);
newl = utf_char2len(lc);
if (newl != l)
{
s = alloc((unsigned)STRLEN(res) + 1 + newl - l);
if (s == NULL)
{
vim_free(res);
return NULL;
}
mch_memmove(s, res, p - res);
STRCPY(s + (p - res) + newl, p + l);
p = s + (p - res);
vim_free(res);
res = s;
}
utf_char2bytes(lc, p);
p += newl;
}
else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
p += l; /* skip multi-byte character */
else
# endif
{
*p = TOLOWER_LOC(*p); /* note that tolower() can be a macro */
p++;
}
}
return res;
}
#endif
/*
@@ -1653,7 +1719,7 @@ vim_strncpy(char_u *to, char_u *from, size_t len)
/*
* Like strcat(), but make sure the result fits in "tosize" bytes and is
* always NUL terminated.
* always NUL terminated. "from" and "to" may overlap.
*/
void
vim_strcat(char_u *to, char_u *from, size_t tosize)
@@ -1667,7 +1733,7 @@ vim_strcat(char_u *to, char_u *from, size_t tosize)
to[tosize - 1] = NUL;
}
else
STRCPY(to + tolen, from);
mch_memmove(to + tolen, from, fromlen + 1);
}
/*
@@ -1740,34 +1806,6 @@ vim_memset(void *ptr, int c, size_t size)
}
#endif
/* skipped when generating prototypes, the prototype is in vim.h */
#ifdef VIM_MEMMOVE
/*
* Version of memmove() that handles overlapping source and destination.
* For systems that don't have a function that is guaranteed to do that (SYSV).
*/
void
mch_memmove(void *src_arg, void *dst_arg, size_t len)
{
/*
* A void doesn't have a size, we use char pointers.
*/
char *dst = dst_arg, *src = src_arg;
/* overlap, copy backwards */
if (dst > src && dst < src + len)
{
src += len;
dst += len;
while (len-- > 0)
*--dst = *--src;
}
else /* copy forwards */
while (len-- > 0)
*dst++ = *src++;
}
#endif
#if (!defined(HAVE_STRCASECMP) && !defined(HAVE_STRICMP)) || defined(PROTO)
/*
* Compare two strings, ignoring case, using current locale.

View File

@@ -3774,16 +3774,25 @@ do_put(
*/
if (y_type == MCHAR && y_size == 1)
{
linenr_T end = curbuf->b_visual.vi_end.lnum;
linenr_T end_lnum = 0; /* init for gcc */
if (curbuf->b_visual.vi_end.lnum < curbuf->b_visual.vi_start.lnum)
end = curbuf->b_visual.vi_start.lnum;
if (VIsual_active)
{
end_lnum = curbuf->b_visual.vi_end.lnum;
if (end_lnum < curbuf->b_visual.vi_start.lnum)
end_lnum = curbuf->b_visual.vi_start.lnum;
}
do {
totlen = count * yanklen;
if (totlen > 0)
{
oldp = ml_get(lnum);
if (VIsual_active && col > (int)STRLEN(oldp))
{
lnum++;
continue;
}
newp = alloc_check((unsigned)(STRLEN(oldp) + totlen + 1));
if (newp == NULL)
goto end; /* alloc() gave an error message */
@@ -3806,7 +3815,7 @@ do_put(
}
if (VIsual_active)
lnum++;
} while (VIsual_active && lnum <= end);
} while (VIsual_active && lnum <= end_lnum);
if (VIsual_active) /* reset lnum to the last visual line */
lnum--;

View File

@@ -6619,6 +6619,15 @@ did_set_string_option(
mch_set_normal_colors();
#endif
}
if (varp == &T_BE && termcap_active)
{
if (*T_BE == NUL)
/* When clearing t_BE we assume the user no longer wants
* bracketed paste, thus disable it by writing t_BD. */
out_str(T_BD);
else
out_str(T_BE);
}
}
#ifdef FEAT_LINEBREAK

View File

@@ -423,21 +423,17 @@ typedef struct dsc$descriptor DESC;
# endif
#endif
/* memmove is not present on all systems, use memmove, bcopy, memcpy or our
* own version */
/* Some systems have (void *) arguments, some (char *). If we use (char *) it
/* memmove() is not present on all systems, use memmove, bcopy or memcpy.
* Some systems have (void *) arguments, some (char *). If we use (char *) it
* works for all */
#ifdef USEMEMMOVE
#if defined(USEMEMMOVE) || (!defined(USEBCOPY) && !defined(USEMEMCPY))
# define mch_memmove(to, from, len) memmove((char *)(to), (char *)(from), len)
#else
# ifdef USEBCOPY
# define mch_memmove(to, from, len) bcopy((char *)(from), (char *)(to), len)
# else
# ifdef USEMEMCPY
/* ifdef USEMEMCPY */
# define mch_memmove(to, from, len) memcpy((char *)(to), (char *)(from), len)
# else
# define VIM_MEMMOVE /* found in misc2.c */
# endif
# endif
#endif

View File

@@ -232,12 +232,13 @@ sk.cp1250.po: sk.po
iconv -f iso-8859-2 -t cp1250 sk.po | \
sed -e 's/charset=ISO-8859-2/charset=cp1250/' -e 's/# Original translations/# Generated from sk.po, DO NOT EDIT/' > sk.cp1250.po
# Convert zh_CN.po to create zh_CN.cp936.po.
# set 'charset' to gbk to avoid that msfmt generates a warning
zh_CN.cp936.po: zh_CN.po
# Convert zh_CN.UTF-8.po to create zh_CN.cp936.po.
# Set 'charset' to gbk to avoid that msfmt generates a warning.
# This used to convert from zh_CN.po, but that results in a conversion error.
zh_CN.cp936.po: zh_CN.UTF-8.po
rm -f zh_CN.cp936.po
iconv -f gb2312 -t cp936 zh_CN.po | \
sed -e 's/charset=gb2312/charset=gbk/' -e 's/# Original translations/# Generated from zh_CN.po, DO NOT EDIT/' > zh_CN.cp936.po
iconv -f UTF-8 -t cp936 zh_CN.UTF-8.po | \
sed -e 's/charset=utf-8/charset=gbk/' -e 's/# Original translations/# Generated from zh_CN.po, DO NOT EDIT/' > zh_CN.cp936.po
# Convert ko.UTF-8.po to create ko.po.
ko.po: ko.UTF-8.po

View File

@@ -40,6 +40,7 @@ char_u *vim_strsave_up(char_u *string);
char_u *vim_strnsave_up(char_u *string, int len);
void vim_strup(char_u *p);
char_u *strup_save(char_u *orig);
char_u *strlow_save(char_u *orig);
void del_trailing_spaces(char_u *ptr);
void vim_strncpy(char_u *to, char_u *from, size_t len);
void vim_strcat(char_u *to, char_u *from, size_t tosize);

View File

@@ -3651,6 +3651,7 @@ win_line(
{
/* Draw the 'foldcolumn'. Allocate a buffer, "extra" may
* already be in use. */
vim_free(p_extra_free);
p_extra_free = alloc(12 + 1);
if (p_extra_free != NULL)
@@ -4695,6 +4696,7 @@ win_line(
p = alloc((unsigned)(len + 1));
vim_memset(p, ' ', len);
p[len] = NUL;
vim_free(p_extra_free);
p_extra_free = p;
for (i = 0; i < tab_len; i++)
{
@@ -4857,6 +4859,7 @@ win_line(
vim_memset(p, ' ', n_extra);
STRNCPY(p, p_extra + 1, STRLEN(p_extra) - 1);
p[n_extra] = NUL;
vim_free(p_extra_free);
p_extra_free = p_extra = p;
}
else
@@ -5784,6 +5787,7 @@ win_line(
}
#endif
vim_free(p_extra_free);
return row;
}

View File

@@ -173,6 +173,7 @@ NEW_TESTS = test_arglist.res \
test_nested_function.res \
test_netbeans.res \
test_normal.res \
test_paste.res \
test_packadd.res \
test_perl.res \
test_profile.res \

View File

@@ -295,3 +295,14 @@ func Test_illegal_address()
2;')
quit
endfunc
func Test_cmdline_complete_wildoptions()
help
call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx')
let a = join(sort(split(@:)),' ')
set wildoptions=tagfile
call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx')
let b = join(sort(split(@:)),' ')
call assert_equal(a, b)
bw!
endfunc

View File

@@ -16,3 +16,148 @@ func Test_str2nr()
call assert_equal(123456789, str2nr('123456789'))
call assert_equal(-123456789, str2nr('-123456789'))
endfunc
func Test_tolower()
call assert_equal("", tolower(""))
" Test with all printable ASCII characters.
call assert_equal(' !"#$%&''()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\]^_`abcdefghijklmnopqrstuvwxyz{|}~',
\ tolower(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'))
if !has('multi_byte')
return
endif
" Test with a few uppercase diacritics.
call assert_equal("aàáâãäåāăąǎǟǡả", tolower("AÀÁÂÃÄÅĀĂĄǍǞǠẢ"))
call assert_equal("bḃḇ", tolower("BḂḆ"))
call assert_equal("cçćĉċč", tolower("CÇĆĈĊČ"))
call assert_equal("dďđḋḏḑ", tolower("DĎĐḊḎḐ"))
call assert_equal("eèéêëēĕėęěẻẽ", tolower("EÈÉÊËĒĔĖĘĚẺẼ"))
call assert_equal("fḟ ", tolower("FḞ "))
call assert_equal("gĝğġģǥǧǵḡ", tolower("GĜĞĠĢǤǦǴḠ"))
call assert_equal("hĥħḣḧḩ", tolower("HĤĦḢḦḨ"))
call assert_equal("iìíîïĩīĭįiǐỉ", tolower("IÌÍÎÏĨĪĬĮİǏỈ"))
call assert_equal("jĵ", tolower("JĴ"))
call assert_equal("kķǩḱḵ", tolower("KĶǨḰḴ"))
call assert_equal("lĺļľŀłḻ", tolower("LĹĻĽĿŁḺ"))
call assert_equal("mḿṁ", tolower("MḾṀ"))
call assert_equal("nñńņňṅṉ", tolower("NÑŃŅŇṄṈ"))
call assert_equal("oòóôõöøōŏőơǒǫǭỏ", tolower("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ"))
call assert_equal("pṕṗ", tolower("PṔṖ"))
call assert_equal("q", tolower("Q"))
call assert_equal("rŕŗřṙṟ", tolower("RŔŖŘṘṞ"))
call assert_equal("sśŝşšṡ", tolower("SŚŜŞŠṠ"))
call assert_equal("tţťŧṫṯ", tolower("TŢŤŦṪṮ"))
call assert_equal("uùúûüũūŭůűųưǔủ", tolower("UÙÚÛÜŨŪŬŮŰŲƯǓỦ"))
call assert_equal("vṽ", tolower("VṼ"))
call assert_equal("wŵẁẃẅẇ", tolower("WŴẀẂẄẆ"))
call assert_equal("xẋẍ", tolower("XẊẌ"))
call assert_equal("yýŷÿẏỳỷỹ", tolower("YÝŶŸẎỲỶỸ"))
call assert_equal("zźżžƶẑẕ", tolower("ZŹŻŽƵẐẔ"))
" Test with a few lowercase diacritics, which should remain unchanged.
call assert_equal("aàáâãäåāăąǎǟǡả", tolower("aàáâãäåāăąǎǟǡả"))
call assert_equal("bḃḇ", tolower("bḃḇ"))
call assert_equal("cçćĉċč", tolower("cçćĉċč"))
call assert_equal("dďđḋḏḑ", tolower("dďđḋḏḑ"))
call assert_equal("eèéêëēĕėęěẻẽ", tolower("eèéêëēĕėęěẻẽ"))
call assert_equal("fḟ", tolower("fḟ"))
call assert_equal("gĝğġģǥǧǵḡ", tolower("gĝğġģǥǧǵḡ"))
call assert_equal("hĥħḣḧḩẖ", tolower("hĥħḣḧḩẖ"))
call assert_equal("iìíîïĩīĭįǐỉ", tolower("iìíîïĩīĭįǐỉ"))
call assert_equal("jĵǰ", tolower("jĵǰ"))
call assert_equal("kķǩḱḵ", tolower("kķǩḱḵ"))
call assert_equal("lĺļľŀłḻ", tolower("lĺļľŀłḻ"))
call assert_equal("mḿṁ ", tolower("mḿṁ "))
call assert_equal("nñńņňʼnṅṉ", tolower("nñńņňʼnṅṉ"))
call assert_equal("oòóôõöøōŏőơǒǫǭỏ", tolower("oòóôõöøōŏőơǒǫǭỏ"))
call assert_equal("pṕṗ", tolower("pṕṗ"))
call assert_equal("q", tolower("q"))
call assert_equal("rŕŗřṙṟ", tolower("rŕŗřṙṟ"))
call assert_equal("sśŝşšṡ", tolower("sśŝşšṡ"))
call assert_equal("tţťŧṫṯẗ", tolower("tţťŧṫṯẗ"))
call assert_equal("uùúûüũūŭůűųưǔủ", tolower("uùúûüũūŭůűųưǔủ"))
call assert_equal("vṽ", tolower("vṽ"))
call assert_equal("wŵẁẃẅẇẘ", tolower("wŵẁẃẅẇẘ"))
call assert_equal("ẋẍ", tolower("ẋẍ"))
call assert_equal("yýÿŷẏẙỳỷỹ", tolower("yýÿŷẏẙỳỷỹ"))
call assert_equal("zźżžƶẑẕ", tolower("zźżžƶẑẕ"))
" According to https://twitter.com/jifa/status/625776454479970304
" Ⱥ (U+023A) and Ⱦ (U+023E) are the *only* code points to increase
" in length (2 to 3 bytes) when lowercased. So let's test them.
call assert_equal("ⱥ ⱦ", tolower("Ⱥ Ⱦ"))
endfunc
func Test_toupper()
call assert_equal("", toupper(""))
" Test with all printable ASCII characters.
call assert_equal(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~',
\ toupper(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'))
if !has('multi_byte')
return
endif
" Test with a few lowercase diacritics.
call assert_equal("AÀÁÂÃÄÅĀĂĄǍǞǠẢ", toupper("aàáâãäåāăąǎǟǡả"))
call assert_equal("BḂḆ", toupper("bḃḇ"))
call assert_equal("CÇĆĈĊČ", toupper("cçćĉċč"))
call assert_equal("DĎĐḊḎḐ", toupper("dďđḋḏḑ"))
call assert_equal("EÈÉÊËĒĔĖĘĚẺẼ", toupper("eèéêëēĕėęěẻẽ"))
call assert_equal("FḞ", toupper("fḟ"))
call assert_equal("GĜĞĠĢǤǦǴḠ", toupper("gĝğġģǥǧǵḡ"))
call assert_equal("HĤĦḢḦḨẖ", toupper("hĥħḣḧḩẖ"))
call assert_equal("IÌÍÎÏĨĪĬĮǏỈ", toupper("iìíîïĩīĭįǐỉ"))
call assert_equal("JĴǰ", toupper("jĵǰ"))
call assert_equal("KĶǨḰḴ", toupper("kķǩḱḵ"))
call assert_equal("LĹĻĽĿŁḺ", toupper("lĺļľŀłḻ"))
call assert_equal("MḾṀ ", toupper("mḿṁ "))
call assert_equal("NÑŃŅŇʼnṄṈ", toupper("nñńņňʼnṅṉ"))
call assert_equal("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ", toupper("oòóôõöøōŏőơǒǫǭỏ"))
call assert_equal("PṔṖ", toupper("pṕṗ"))
call assert_equal("Q", toupper("q"))
call assert_equal("RŔŖŘṘṞ", toupper("rŕŗřṙṟ"))
call assert_equal("SŚŜŞŠṠ", toupper("sśŝşšṡ"))
call assert_equal("TŢŤŦṪṮẗ", toupper("tţťŧṫṯẗ"))
call assert_equal("UÙÚÛÜŨŪŬŮŰŲƯǓỦ", toupper("uùúûüũūŭůűųưǔủ"))
call assert_equal("VṼ", toupper("vṽ"))
call assert_equal("WŴẀẂẄẆẘ", toupper("wŵẁẃẅẇẘ"))
call assert_equal("ẊẌ", toupper("ẋẍ"))
call assert_equal("YÝŸŶẎẙỲỶỸ", toupper("yýÿŷẏẙỳỷỹ"))
call assert_equal("ZŹŻŽƵẐẔ", toupper("zźżžƶẑẕ"))
" Test that uppercase diacritics, which should remain unchanged.
call assert_equal("AÀÁÂÃÄÅĀĂĄǍǞǠẢ", toupper("AÀÁÂÃÄÅĀĂĄǍǞǠẢ"))
call assert_equal("BḂḆ", toupper("BḂḆ"))
call assert_equal("CÇĆĈĊČ", toupper("CÇĆĈĊČ"))
call assert_equal("DĎĐḊḎḐ", toupper("DĎĐḊḎḐ"))
call assert_equal("EÈÉÊËĒĔĖĘĚẺẼ", toupper("EÈÉÊËĒĔĖĘĚẺẼ"))
call assert_equal("FḞ ", toupper("FḞ "))
call assert_equal("GĜĞĠĢǤǦǴḠ", toupper("GĜĞĠĢǤǦǴḠ"))
call assert_equal("HĤĦḢḦḨ", toupper("HĤĦḢḦḨ"))
call assert_equal("IÌÍÎÏĨĪĬĮİǏỈ", toupper("IÌÍÎÏĨĪĬĮİǏỈ"))
call assert_equal("JĴ", toupper("JĴ"))
call assert_equal("KĶǨḰḴ", toupper("KĶǨḰḴ"))
call assert_equal("LĹĻĽĿŁḺ", toupper("LĹĻĽĿŁḺ"))
call assert_equal("MḾṀ", toupper("MḾṀ"))
call assert_equal("NÑŃŅŇṄṈ", toupper("NÑŃŅŇṄṈ"))
call assert_equal("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ", toupper("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ"))
call assert_equal("PṔṖ", toupper("PṔṖ"))
call assert_equal("Q", toupper("Q"))
call assert_equal("RŔŖŘṘṞ", toupper("RŔŖŘṘṞ"))
call assert_equal("SŚŜŞŠṠ", toupper("SŚŜŞŠṠ"))
call assert_equal("TŢŤŦṪṮ", toupper("TŢŤŦṪṮ"))
call assert_equal("UÙÚÛÜŨŪŬŮŰŲƯǓỦ", toupper("UÙÚÛÜŨŪŬŮŰŲƯǓỦ"))
call assert_equal("VṼ", toupper("VṼ"))
call assert_equal("WŴẀẂẄẆ", toupper("WŴẀẂẄẆ"))
call assert_equal("XẊẌ", toupper("XẊẌ"))
call assert_equal("YÝŶŸẎỲỶỸ", toupper("YÝŶŸẎỲỶỸ"))
call assert_equal("ZŹŻŽƵẐẔ", toupper("ZŹŻŽƵẐẔ"))
call assert_equal("ⱥ ⱦ", tolower("Ⱥ Ⱦ"))
endfunc

View File

@@ -0,0 +1,54 @@
" Tests for bracketed paste.
" Bracketed paste only works with "xterm". Not in GUI.
if has('gui_running')
finish
endif
set term=xterm
func Test_paste_normal_mode()
new
call setline(1, ['a', 'b', 'c'])
2
call feedkeys("\<Esc>[200~foo\<CR>bar\<Esc>[201~", 'xt')
call assert_equal('bfoo', getline(2))
call assert_equal('bar', getline(3))
call assert_equal('c', getline(4))
normal .
call assert_equal('barfoo', getline(3))
call assert_equal('bar', getline(4))
call assert_equal('c', getline(5))
bwipe!
endfunc
func Test_paste_insert_mode()
new
call setline(1, ['a', 'b', 'c'])
2
call feedkeys("i\<Esc>[200~foo\<CR>bar\<Esc>[201~ done\<Esc>", 'xt')
call assert_equal('foo', getline(2))
call assert_equal('bar doneb', getline(3))
call assert_equal('c', getline(4))
normal .
call assert_equal('bar donfoo', getline(3))
call assert_equal('bar doneeb', getline(4))
call assert_equal('c', getline(5))
set ai et tw=10
call setline(1, ['a', ' b', 'c'])
2
call feedkeys("A\<Esc>[200~foo\<CR> bar bar bar\<Esc>[201~\<Esc>", 'xt')
call assert_equal(' bfoo', getline(2))
call assert_equal(' bar bar bar', getline(3))
call assert_equal('c', getline(4))
set ai& et& tw=0
bwipe!
endfunc
func Test_paste_cmdline()
call feedkeys(":a\<Esc>[200~foo\<CR>bar\<Esc>[201~b\<Home>\"\<CR>", 'xt')
call assert_equal("\"afoo\<CR>barb", getreg(':'))
endfunc

View File

@@ -7,10 +7,10 @@ func! ListMonths()
if g:setting != ''
exe ":set" g:setting
endif
let mth=copy(g:months)
let mth = copy(g:months)
let entered = strcharpart(getline('.'),0,col('.'))
if !empty(entered)
let mth=filter(mth, 'v:val=~"^".entered')
let mth = filter(mth, 'v:val=~"^".entered')
endif
call complete(1, mth)
return ''
@@ -468,7 +468,7 @@ endfunc
" auto-wrap text.
func Test_completion_ctrl_e_without_autowrap()
new
let tw_save=&tw
let tw_save = &tw
set tw=78
let li = [
\ '" zzz',
@@ -478,8 +478,37 @@ func Test_completion_ctrl_e_without_autowrap()
call feedkeys("A\<C-X>\<C-N>\<C-E>\<Esc>", "tx")
call assert_equal(li, getline(1, '$'))
let &tw=tw_save
let &tw = tw_save
q!
endfunc
function! DummyCompleteSix()
call complete(1, ['Hello', 'World'])
return ''
endfunction
" complete() correctly clears the list of autocomplete candidates
" See #1411
func Test_completion_clear_candidate_list()
new
%d
" select first entry from the completion popup
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>", "tx")
call assert_equal('Hello', getline(1))
%d
" select second entry from the completion popup
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>", "tx")
call assert_equal('World', getline(1))
%d
" select original text
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>\<C-N>", "tx")
call assert_equal(' xxx', getline(1))
%d
" back at first entry from completion list
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>\<C-N>\<C-N>", "tx")
call assert_equal('Hello', getline(1))
bw!
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -21,3 +21,16 @@ func Test_put_char_block()
call assert_equal(['Xfile_put 1', 'Xfile_put 2'], getline(1,2))
bw!
endfunc
func Test_put_char_block2()
new
let a = [ getreg('a'), getregtype('a') ]
call setreg('a', ' one ', 'v')
call setline(1, ['Line 1', '', 'Line 3', ''])
" visually select the first 3 lines and put register a over it
exe "norm! ggl\<c-v>2j2l\"ap"
call assert_equal(['L one 1', '', 'L one 3', ''], getline(1,4))
" clean up
bw!
call setreg('a', a[0], a[1])
endfunc

View File

@@ -102,3 +102,107 @@ func Test_CmdUndefined()
call assert_fails('Dothat', 'E492:')
call assert_equal('yes', g:didnot)
endfunc
func Test_CmdErrors()
call assert_fails('com! docmd :', 'E183:')
call assert_fails('com! \<Tab> :', 'E182:')
call assert_fails('com! _ :', 'E182:')
call assert_fails('com! X :', 'E841:')
call assert_fails('com! - DoCmd :', 'E175:')
call assert_fails('com! -xxx DoCmd :', 'E181:')
call assert_fails('com! -addr DoCmd :', 'E179:')
call assert_fails('com! -complete DoCmd :', 'E179:')
call assert_fails('com! -complete=xxx DoCmd :', 'E180:')
call assert_fails('com! -complete=custom DoCmd :', 'E467:')
call assert_fails('com! -complete=customlist DoCmd :', 'E467:')
call assert_fails('com! -complete=behave,CustomComplete DoCmd :', 'E468:')
call assert_fails('com! -nargs=x DoCmd :', 'E176:')
call assert_fails('com! -count=1 -count=2 DoCmd :', 'E177:')
call assert_fails('com! -count=x DoCmd :', 'E178:')
call assert_fails('com! -range=x DoCmd :', 'E178:')
com! -nargs=0 DoCmd :
call assert_fails('DoCmd x', 'E488:')
com! -nargs=1 DoCmd :
call assert_fails('DoCmd', 'E471:')
com! -nargs=+ DoCmd :
call assert_fails('DoCmd', 'E471:')
call assert_fails('com DoCmd :', 'E174:')
comclear
call assert_fails('delcom DoCmd', 'E184:')
endfunc
func CustomComplete(A, L, P)
return "January\nFebruary\nMars\n"
endfunc
func CustomCompleteList(A, L, P)
return [ "Monday", "Tuesday", "Wednesday" ]
endfunc
func Test_CmdCompletion()
call feedkeys(":com -\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com -addr bang bar buffer complete count nargs range register', @:)
call feedkeys(":com -nargs=0 -\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com -nargs=0 -addr bang bar buffer complete count nargs range register', @:)
call feedkeys(":com -nargs=\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com -nargs=* + 0 1 ?', @:)
call feedkeys(":com -addr=\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com -addr=arguments buffers lines loaded_buffers quickfix tabs windows', @:)
call feedkeys(":com -complete=co\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com -complete=color command compiler', @:)
command! DoCmd1 :
command! DoCmd2 :
call feedkeys(":com \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com DoCmd1 DoCmd2', @:)
call feedkeys(":DoC\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"DoCmd1 DoCmd2', @:)
call feedkeys(":delcom DoC\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"delcom DoCmd1 DoCmd2', @:)
delcom DoCmd1
call feedkeys(":delcom DoC\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"delcom DoCmd2', @:)
call feedkeys(":com DoC\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com DoCmd2', @:)
delcom DoCmd2
call feedkeys(":delcom DoC\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"delcom DoC', @:)
call feedkeys(":com DoC\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com DoC', @:)
com! -complete=behave DoCmd :
call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"DoCmd mswin xterm', @:)
" This does not work. Why?
"call feedkeys(":DoCmd x\<C-A>\<C-B>\"\<CR>", 'tx')
"call assert_equal('"DoCmd xterm', @:)
com! -complete=custom,CustomComplete DoCmd :
call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"DoCmd January February Mars', @:)
com! -complete=customlist,CustomCompleteList DoCmd :
call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"DoCmd Monday Tuesday Wednesday', @:)
com! -complete=custom,CustomCompleteList DoCmd :
call assert_fails("call feedkeys(':DoCmd \<C-D>', 'tx')", 'E730:')
com! -complete=customlist,CustomComp DoCmd :
call assert_fails("call feedkeys(':DoCmd \<C-D>', 'tx')", 'E117:')
endfunc

View File

@@ -764,6 +764,46 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
249,
/**/
248,
/**/
247,
/**/
246,
/**/
245,
/**/
244,
/**/
243,
/**/
242,
/**/
241,
/**/
240,
/**/
239,
/**/
238,
/**/
237,
/**/
236,
/**/
235,
/**/
234,
/**/
233,
/**/
232,
/**/
231,
/**/
230,
/**/
229,
/**/

View File

@@ -1714,15 +1714,8 @@ typedef unsigned short disptick_T; /* display tick type */
typedef void *vim_acl_T; /* dummy to pass an ACL to a function */
/*
* Include a prototype for mch_memmove(), it may not be in alloc.pro.
*/
#ifdef VIM_MEMMOVE
void mch_memmove(void *, void *, size_t);
#else
# ifndef mch_memmove
# define mch_memmove(to, from, len) memmove(to, from, len)
# endif
#ifndef mch_memmove
# define mch_memmove(to, from, len) memmove((char*)(to), (char*)(from), (size_t)(len))
#endif
/*