mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-05-28 00:21:57 +02:00
Merge pull request #163 from chdiza/master
Merge remote-tracking branch 'vim/master'
This commit is contained in:
@@ -5803,6 +5803,10 @@ sort({list} [, {func} [, {dict}]]) *sort()* *E702*
|
||||
strtod() function to parse numbers, Strings, Lists, Dicts and
|
||||
Funcrefs will be considered as being 0).
|
||||
|
||||
When {func} is given and it is 'N' then all items will be
|
||||
sorted numerical. This is like 'n' but a string containing
|
||||
digits will be used as the number they represent.
|
||||
|
||||
When {func} is a |Funcref| or a function name, this function
|
||||
is called to compare items. The function is invoked with two
|
||||
items as argument and must return zero if they are equal, 1 or
|
||||
@@ -5817,6 +5821,11 @@ sort({list} [, {func} [, {dict}]]) *sort()* *E702*
|
||||
on numbers, text strings will sort next to each other, in the
|
||||
same order as they were originally.
|
||||
|
||||
The sort is stable, items which compare equal (as number or as
|
||||
string) will keep their relative position. E.g., when sorting
|
||||
on numbers, text strings will sort next to each other, in the
|
||||
same order as they were originally.
|
||||
|
||||
Also see |uniq()|.
|
||||
|
||||
Example: >
|
||||
|
||||
+19
@@ -900,6 +900,7 @@ eval_init()
|
||||
set_vim_var_nr(VV_SEARCHFORWARD, 1L);
|
||||
set_vim_var_nr(VV_HLSEARCH, 1L);
|
||||
set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc());
|
||||
set_vim_var_list(VV_ERRORS, list_alloc());
|
||||
set_reg_var(0); /* default for v:register is not 0 but '"' */
|
||||
|
||||
#ifdef EBCDIC
|
||||
@@ -8749,7 +8750,9 @@ call_func(funcname, len, rettv, argcount, argvars, firstline, lastline,
|
||||
* redo buffer.
|
||||
*/
|
||||
save_search_patterns();
|
||||
#ifdef FEAT_INS_EXPAND
|
||||
if (!ins_compl_active())
|
||||
#endif
|
||||
{
|
||||
saveRedobuff();
|
||||
did_save_redo = TRUE;
|
||||
@@ -17953,6 +17956,7 @@ typedef struct
|
||||
|
||||
static int item_compare_ic;
|
||||
static int item_compare_numeric;
|
||||
static int item_compare_numbers;
|
||||
static char_u *item_compare_func;
|
||||
static dict_T *item_compare_selfdict;
|
||||
static int item_compare_func_err;
|
||||
@@ -17983,6 +17987,15 @@ item_compare(s1, s2)
|
||||
si2 = (sortItem_T *)s2;
|
||||
tv1 = &si1->item->li_tv;
|
||||
tv2 = &si2->item->li_tv;
|
||||
|
||||
if (item_compare_numbers)
|
||||
{
|
||||
long v1 = get_tv_number(tv1);
|
||||
long v2 = get_tv_number(tv2);
|
||||
|
||||
return v1 == v2 ? 0 : v1 > v2 ? 1 : -1;
|
||||
}
|
||||
|
||||
/* tv2string() puts quotes around a string and allocates memory. Don't do
|
||||
* that for string variables. Use a single quote when comparing with a
|
||||
* non-string to do what the docs promise. */
|
||||
@@ -18116,6 +18129,7 @@ do_sort_uniq(argvars, rettv, sort)
|
||||
|
||||
item_compare_ic = FALSE;
|
||||
item_compare_numeric = FALSE;
|
||||
item_compare_numbers = FALSE;
|
||||
item_compare_func = NULL;
|
||||
item_compare_selfdict = NULL;
|
||||
if (argvars[1].v_type != VAR_UNKNOWN)
|
||||
@@ -18141,6 +18155,11 @@ do_sort_uniq(argvars, rettv, sort)
|
||||
item_compare_func = NULL;
|
||||
item_compare_numeric = TRUE;
|
||||
}
|
||||
else if (STRCMP(item_compare_func, "N") == 0)
|
||||
{
|
||||
item_compare_func = NULL;
|
||||
item_compare_numbers = TRUE;
|
||||
}
|
||||
else if (STRCMP(item_compare_func, "i") == 0)
|
||||
{
|
||||
item_compare_func = NULL;
|
||||
|
||||
@@ -9488,7 +9488,9 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
|
||||
if (!autocmd_busy)
|
||||
{
|
||||
save_search_patterns();
|
||||
#ifdef FEAT_INS_EXPAND
|
||||
if (!ins_compl_active())
|
||||
#endif
|
||||
{
|
||||
saveRedobuff();
|
||||
did_save_redobuff = TRUE;
|
||||
|
||||
+6
-1
@@ -5427,7 +5427,12 @@ win_line(wp, lnum, startrow, endrow, nochange)
|
||||
else
|
||||
/* DBCS: Put second byte in the second screen char. */
|
||||
ScreenLines[off] = mb_c & 0xff;
|
||||
++vcol;
|
||||
if (draw_state > WL_NR
|
||||
#ifdef FEAT_DIFF
|
||||
&& filler_todo <= 0
|
||||
#endif
|
||||
)
|
||||
++vcol;
|
||||
/* When "tocol" is halfway a character, set it to the end of
|
||||
* the character, otherwise highlighting won't stop. */
|
||||
if (tocol == vcol)
|
||||
|
||||
@@ -34,7 +34,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
|
||||
test81.out test82.out test83.out test84.out test88.out \
|
||||
test89.out test90.out test91.out test92.out test93.out \
|
||||
test94.out test95.out test96.out test97.out test98.out \
|
||||
test99.out test100.out test101.out test102.out test103.out \
|
||||
test99.out test101.out test102.out test103.out \
|
||||
test104.out test105.out test106.out test107.out \
|
||||
test_argument_0count.out \
|
||||
test_argument_count.out \
|
||||
@@ -185,7 +185,6 @@ test96.out: test96.in
|
||||
test97.out: test97.in
|
||||
test98.out: test98.in
|
||||
test99.out: test99.in
|
||||
test100.out: test100.in
|
||||
test101.out: test101.in
|
||||
test102.out: test102.in
|
||||
test103.out: test103.in
|
||||
|
||||
@@ -33,7 +33,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
|
||||
test84.out test85.out test86.out test87.out test88.out \
|
||||
test89.out test90.out test91.out test92.out test93.out \
|
||||
test94.out test95.out test96.out test98.out test99.out \
|
||||
test100.out test101.out test102.out test103.out test104.out \
|
||||
test101.out test102.out test103.out test104.out \
|
||||
test105.out test106.out test107.out\
|
||||
test_argument_0count.out \
|
||||
test_argument_count.out \
|
||||
|
||||
@@ -55,7 +55,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
|
||||
test84.out test85.out test86.out test87.out test88.out \
|
||||
test89.out test90.out test91.out test92.out test93.out \
|
||||
test94.out test95.out test96.out test98.out test99.out \
|
||||
test100.out test101.out test102.out test103.out test104.out \
|
||||
test101.out test102.out test103.out test104.out \
|
||||
test105.out test106.out test107.out \
|
||||
test_argument_0count.out \
|
||||
test_argument_count.out \
|
||||
|
||||
@@ -35,7 +35,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
|
||||
test81.out test82.out test83.out test84.out test88.out \
|
||||
test89.out test90.out test91.out test92.out test93.out \
|
||||
test94.out test95.out test96.out test98.out test99.out \
|
||||
test100.out test101.out test102.out test103.out test104.out \
|
||||
test101.out test102.out test103.out test104.out \
|
||||
test105.out test106.out test107.out \
|
||||
test_argument_0count.out \
|
||||
test_argument_count.out \
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# Authors: Zoltan Arpadffy, <arpadffy@polarhome.com>
|
||||
# Sandor Kopanyi, <sandor.kopanyi@mailbox.hu>
|
||||
#
|
||||
# Last change: 2015 Sep 08
|
||||
# Last change: 2015 Dec 03
|
||||
#
|
||||
# This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
|
||||
# Edit the lines in the Configuration section below to select.
|
||||
@@ -94,7 +94,7 @@ SCRIPT = test1.out test2.out test3.out test4.out test5.out \
|
||||
test82.out test84.out test88.out test89.out \
|
||||
test90.out test91.out test92.out test93.out test94.out \
|
||||
test95.out test96.out test98.out test99.out \
|
||||
test100.out test101.out test103.out test104.out \
|
||||
test101.out test103.out test104.out \
|
||||
test105.out test106.out test107.out \
|
||||
test_argument_0count.out \
|
||||
test_argument_count.out \
|
||||
|
||||
@@ -31,7 +31,7 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
|
||||
test84.out test85.out test86.out test87.out test88.out \
|
||||
test89.out test90.out test91.out test92.out test93.out \
|
||||
test94.out test95.out test96.out test97.out test98.out \
|
||||
test99.out test100.out test101.out test102.out test103.out \
|
||||
test99.out test101.out test102.out test103.out \
|
||||
test104.out test105.out test106.out test107.out \
|
||||
test_argument_0count.out \
|
||||
test_argument_count.out \
|
||||
@@ -69,7 +69,7 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
|
||||
test_writefile.out
|
||||
|
||||
NEW_TESTS = test_assert.res \
|
||||
test_undolevels.res
|
||||
test_alot.res
|
||||
|
||||
SCRIPTS_GUI = test16.out
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ endfor
|
||||
|
||||
if fail == 0
|
||||
" Success, create the .res file so that make knows it's done.
|
||||
split %:r.res
|
||||
exe 'split ' . fnamemodify(testname, ':r') . '.res'
|
||||
write
|
||||
endif
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
Tests for 'lispwords' settings being global-local
|
||||
|
||||
STARTTEST
|
||||
:so small.vim
|
||||
:set nocompatible viminfo+=nviminfo
|
||||
:"
|
||||
:" Testing 'lispwords'
|
||||
:"
|
||||
:setglobal lispwords=foo,bar,baz
|
||||
:setlocal lispwords-=foo | setlocal lispwords+=quux
|
||||
:redir >> test.out | echon "\nTesting 'lispwords' local value" | setglobal lispwords? | setlocal lispwords? | echo &lispwords . "\n" | redir end
|
||||
:setlocal lispwords<
|
||||
:redir >> test.out | echon "\nTesting 'lispwords' value reset" | setglobal lispwords? | setlocal lispwords? | echo &lispwords . "\n" | redir end
|
||||
:qa!
|
||||
ENDTEST
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
Testing 'lispwords' local value
|
||||
lispwords=foo,bar,baz
|
||||
lispwords=bar,baz,quux
|
||||
bar,baz,quux
|
||||
|
||||
Testing 'lispwords' value reset
|
||||
lispwords=foo,bar,baz
|
||||
lispwords=foo,bar,baz
|
||||
foo,bar,baz
|
||||
@@ -0,0 +1,6 @@
|
||||
" A series of tests that can run in one Vim invocation.
|
||||
" This makes testing go faster, since Vim doesn't need to restart.
|
||||
|
||||
source test_lispwords.vim
|
||||
source test_sort.vim
|
||||
source test_undolevels.vim
|
||||
@@ -0,0 +1,16 @@
|
||||
" Tests for 'lispwords' settings being global-local
|
||||
|
||||
set nocompatible viminfo+=nviminfo
|
||||
|
||||
func Test_global_local_lispwords()
|
||||
setglobal lispwords=foo,bar,baz
|
||||
setlocal lispwords-=foo | setlocal lispwords+=quux
|
||||
call assert_equal('foo,bar,baz', &g:lispwords)
|
||||
call assert_equal('bar,baz,quux', &l:lispwords)
|
||||
call assert_equal('bar,baz,quux', &lispwords)
|
||||
|
||||
setlocal lispwords<
|
||||
call assert_equal('foo,bar,baz', &g:lispwords)
|
||||
call assert_equal('foo,bar,baz', &l:lispwords)
|
||||
call assert_equal('foo,bar,baz', &lispwords)
|
||||
endfunc
|
||||
@@ -2,7 +2,7 @@ Test for linebreak and list option in utf-8 mode
|
||||
|
||||
STARTTEST
|
||||
:so small.vim
|
||||
:if !exists("+linebreak") || !has("conceal") | e! test.ok | w! test.out | qa! | endif
|
||||
:if !exists("+linebreak") || !has("conceal") || !has("signs") | e! test.ok | w! test.out | qa! | endif
|
||||
:so mbyte.vim
|
||||
:if &enc !=? 'utf-8'|:e! test.ok|:w! test.out|qa!|endif
|
||||
:10new|:vsp|:vert resize 20
|
||||
@@ -25,6 +25,7 @@ STARTTEST
|
||||
: $put =g:line
|
||||
: wincmd p
|
||||
:endfu
|
||||
:"
|
||||
:let g:test ="Test 1: set linebreak + set list + fancy listchars"
|
||||
:exe "set linebreak list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6"
|
||||
:redraw!
|
||||
@@ -45,6 +46,7 @@ STARTTEST
|
||||
:redraw!
|
||||
:let line=ScreenChar(winwidth(0),4)
|
||||
:call DoRecordScreen()
|
||||
:"
|
||||
:let g:test ="Test 4: set linebreak list listchars and concealing"
|
||||
:let c_defines=['#define ABCDE 1','#define ABCDEF 1','#define ABCDEFG 1','#define ABCDEFGH 1', '#define MSG_MODE_FILE 1','#define MSG_MODE_CONSOLE 2','#define MSG_MODE_FILE_AND_CONSOLE 3','#define MSG_MODE_FILE_THEN_CONSOLE 4']
|
||||
:call append('$', c_defines)
|
||||
@@ -56,6 +58,7 @@ STARTTEST
|
||||
:redraw!
|
||||
:let line=ScreenChar(winwidth(0),7)
|
||||
:call DoRecordScreen()
|
||||
:"
|
||||
:let g:test ="Test 5: set linebreak list listchars and concealing part2"
|
||||
:let c_defines=['bbeeeeee ; some text']
|
||||
:call append('$', c_defines)
|
||||
@@ -74,6 +77,7 @@ STARTTEST
|
||||
:redraw!
|
||||
:let line=ScreenChar(winwidth(0),1)
|
||||
:call DoRecordScreen()
|
||||
:"
|
||||
:let g:test ="Test 6: Screenattributes for comment"
|
||||
:$put =g:test
|
||||
:call append('$', ' /* and some more */')
|
||||
@@ -92,10 +96,39 @@ GGlGGlGGlGGlGGlGGlGGlGGlGGlGGl
|
||||
: call append('$', "Not all attributes are different")
|
||||
:endif
|
||||
:set cpo&vim linebreak selection=exclusive
|
||||
:"
|
||||
:let g:test ="Test 8: set linebreak with visual block mode and v_b_A and selection=exclusive and multibyte char"
|
||||
:$put =g:test
|
||||
Golong line: 40afoobar aTARGETÃ' at end
|
||||
:exe "norm! $3B\<C-v>eAx\<Esc>"
|
||||
:"
|
||||
:let g:test ="Test 9: a multibyte sign and colorcolumn"
|
||||
:let attr=[]
|
||||
:let attr2=[]
|
||||
:$put =''
|
||||
:$put ='a b c'
|
||||
:$put ='a b c'
|
||||
:set list nolinebreak cc=3
|
||||
:sign define foo text=ï¼
|
||||
:sign place 1 name=foo line=50 buffer=2
|
||||
:norm! 2kztj
|
||||
:let line1=line('.')
|
||||
0GGlGGlGGlGGl
|
||||
:let line2=line('.')
|
||||
:let attr2=attr
|
||||
:let attr=[]
|
||||
0GGlGGlGGlGGl
|
||||
:redraw!
|
||||
:let line=ScreenChar(winwidth(0),3)
|
||||
:call DoRecordScreen()
|
||||
:call append('$', ['ScreenAttributes for test9:'])
|
||||
:call append('$', ["Line: ".line1. " ". string(g:attr),"Line: ".line2. " ". string(g:attr2)])
|
||||
:" expected: attr[2] is different because of colorcolumn
|
||||
:if attr[0] != attr2[0] || attr[1] != attr2[1] || attr[2] != attr2[2]
|
||||
: call append('$', "Screen attributes are different!")
|
||||
:else
|
||||
: call append('$', "Screen attributes are the same!")
|
||||
:endif
|
||||
:%w! test.out
|
||||
:qa!
|
||||
ENDTEST
|
||||
|
||||
@@ -46,3 +46,15 @@ ScreenAttributes for test6:
|
||||
Attribut 0 and 1 and 3 and 5 are different!
|
||||
Test 8: set linebreak with visual block mode and v_b_A and selection=exclusive and multibyte char
|
||||
long line: foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar TARGETÃx' at end
|
||||
|
||||
a b c
|
||||
a b c
|
||||
|
||||
Test 9: a multibyte sign and colorcolumn
|
||||
¶
|
||||
ï¼a b c¶
|
||||
a b c¶
|
||||
ScreenAttributes for test9:
|
||||
Line: 50 ['0', '0', '72', '0']
|
||||
Line: 51 ['0', '0', '72', '0']
|
||||
Screen attributes are the same!
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
" Test sort()
|
||||
|
||||
func Test_sort_strings()
|
||||
" numbers compared as strings
|
||||
call assert_equal([1, 2, 3], sort([3, 2, 1]))
|
||||
call assert_equal([13, 28, 3], sort([3, 28, 13]))
|
||||
endfunc
|
||||
|
||||
func Test_sort_numeric()
|
||||
call assert_equal([1, 2, 3], sort([3, 2, 1], 'n'))
|
||||
call assert_equal([3, 13, 28], sort([13, 28, 3], 'n'))
|
||||
" strings are not sorted
|
||||
call assert_equal(['13', '28', '3'], sort(['13', '28', '3'], 'n'))
|
||||
endfunc
|
||||
|
||||
func Test_sort_numbers()
|
||||
call assert_equal([3, 13, 28], sort([13, 28, 3], 'N'))
|
||||
call assert_equal(['3', '13', '28'], sort(['13', '28', '3'], 'N'))
|
||||
endfunc
|
||||
@@ -756,6 +756,18 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
953,
|
||||
/**/
|
||||
952,
|
||||
/**/
|
||||
951,
|
||||
/**/
|
||||
950,
|
||||
/**/
|
||||
949,
|
||||
/**/
|
||||
948,
|
||||
/**/
|
||||
947,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user