Skip to content

Commit 54e5082

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 88f75a7 + 03ff9bc commit 54e5082

18 files changed

+236
-43
lines changed

runtime/doc/term.txt

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*term.txt* For Vim version 8.0. Last change: 2017 Jan 27
1+
*term.txt* For Vim version 8.0. Last change: 2017 Feb 02
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -95,7 +95,12 @@ terminal when entering "raw" mode and 't_BD' when leaving "raw" mode. The
9595
terminal is then expected to put 't_PS' before pasted text and 't_PE' after
9696
pasted text. This way Vim can separate text that is pasted from characters
9797
that are typed. The pasted text is handled like when the middle mouse button
98-
is used.
98+
is used, it is inserted literally and not interpreted as commands.
99+
100+
When the cursor is in the first column, the pasted text will be inserted
101+
before it. Otherwise the pasted text is appended after the cursor position.
102+
This means one cannot paste after the first column. Unfortunately Vim does
103+
not have a way to tell where the mouse pointer was.
99104

100105
Note that in some situations Vim will not recognize the bracketed paste and
101106
you will get the raw text. In other situations Vim will only get the first

src/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -2144,8 +2144,9 @@ test_arglist \
21442144
test_fnameescape \
21452145
test_fnamemodify \
21462146
test_fold \
2147-
test_glob2regpat \
2147+
test_ga \
21482148
test_gf \
2149+
test_glob2regpat \
21492150
test_gn \
21502151
test_goto \
21512152
test_gui \

src/ex_docmd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -11825,7 +11825,7 @@ ses_arglist(
1182511825
s = buf;
1182611826
}
1182711827
}
11828-
if (fputs("argadd ", fd) < 0
11828+
if (fputs("$argadd ", fd) < 0
1182911829
|| ses_put_fname(fd, s, flagp) == FAIL
1183011830
|| put_eol(fd) == FAIL)
1183111831
{

src/misc1.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -3264,7 +3264,11 @@ change_warning(
32643264
#endif
32653265
msg_clr_eos();
32663266
(void)msg_end();
3267-
if (msg_silent == 0 && !silent_mode)
3267+
if (msg_silent == 0 && !silent_mode
3268+
#ifdef FEAT_EVAL
3269+
&& time_for_testing != 1
3270+
#endif
3271+
)
32683272
{
32693273
out_flush();
32703274
ui_delay(1000L, TRUE); /* give the user time to think about it */

src/normal.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -9113,8 +9113,13 @@ nv_edit(cmdarg_T *cap)
91139113
beginline(BL_WHITE|BL_FIX);
91149114
break;
91159115

9116+
case K_PS: /* Bracketed paste works like "a"ppend, unless the
9117+
cursor is in the first column, then it inserts. */
9118+
if (curwin->w_cursor.col == 0)
9119+
break;
9120+
/*FALLTHROUGH*/
9121+
91169122
case 'a': /* "a"ppend is like "i"nsert on the next character. */
9117-
case K_PS: /* bracketed paste works like "a"ppend */
91189123
#ifdef FEAT_VIRTUALEDIT
91199124
/* increment coladd when in virtual space, increment the
91209125
* column otherwise, also to append after an unprintable char */

src/ops.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -2571,8 +2571,7 @@ op_insert(oparg_T *oap, long count1)
25712571
}
25722572

25732573
t1 = oap->start;
2574-
if (edit(NUL, FALSE, (linenr_T)count1))
2575-
return;
2574+
(void)edit(NUL, FALSE, (linenr_T)count1);
25762575

25772576
/* When a tab was inserted, and the characters in front of the tab
25782577
* have been converted to a tab as well, the column of the cursor

src/screen.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -2903,7 +2903,7 @@ win_line(
29032903
int endrow,
29042904
int nochange UNUSED) /* not updating for changed text */
29052905
{
2906-
int col; /* visual column on screen */
2906+
int col = 0; /* visual column on screen */
29072907
unsigned off; /* offset in ScreenLines/ScreenAttrs */
29082908
int c = 0; /* init for GCC */
29092909
long vcol = 0; /* virtual column (for tabs) */
@@ -3429,7 +3429,11 @@ win_line(
34293429
#else
34303430
--ptr;
34313431
#endif
3432-
n_skip = v - vcol;
3432+
#ifdef FEAT_MBYTE
3433+
/* character fits on the screen, don't need to skip it */
3434+
if ((*mb_ptr2cells)(ptr) >= c && col == 0)
3435+
#endif
3436+
n_skip = v - vcol;
34333437
}
34343438

34353439
/*

src/structs.h

+1
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,7 @@ typedef struct
13371337
int uf_varargs; /* variable nr of arguments */
13381338
int uf_flags;
13391339
int uf_calls; /* nr of active calls */
1340+
int uf_cleared; /* func_clear() was already called */
13401341
garray_T uf_args; /* arguments */
13411342
garray_T uf_lines; /* function lines */
13421343
#ifdef FEAT_PROFILE

src/testdir/runtest.vim

+9-2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ endfunc
8888

8989
function RunTheTest(test)
9090
echo 'Executing ' . a:test
91+
92+
" Avoid stopping at the "hit enter" prompt
93+
set nomore
94+
95+
" Avoid a three second wait when a message is about to be overwritten by the
96+
" mode message.
97+
set noshowmode
98+
9199
if exists("*SetUp")
92100
try
93101
call SetUp()
@@ -158,12 +166,11 @@ let s:flaky = [
158166
\ 'Test_communicate()',
159167
\ 'Test_nb_basic()',
160168
\ 'Test_pipe_through_sort_all()',
161-
\ 'Test_pipe_through_sort_some()'
169+
\ 'Test_pipe_through_sort_some()',
162170
\ 'Test_reltime()',
163171
\ ]
164172

165173
" Locate Test_ functions and execute them.
166-
set nomore
167174
redir @q
168175
silent function /^Test_
169176
redir END

src/testdir/test_alot.vim

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ source test_float_func.vim
1919
source test_fnamemodify.vim
2020
source test_functions.vim
2121
source test_glob2regpat.vim
22+
source test_ga.vim
2223
source test_goto.vim
2324
source test_help_tagjump.vim
2425
source test_join.vim

src/testdir/test_ga.vim

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
" Test ga normal command, and :ascii Ex command.
2+
func Do_ga(c)
3+
call setline(1, a:c)
4+
let l:a = execute("norm 1goga")
5+
let l:b = execute("ascii")
6+
call assert_equal(l:a, l:b)
7+
return l:a
8+
endfunc
9+
10+
func Test_ga_command()
11+
new
12+
set display=uhex
13+
call assert_equal("\nNUL", Do_ga(''))
14+
call assert_equal("\n<<01>> 1, Hex 01, Octal 001", Do_ga("\x01"))
15+
call assert_equal("\n<<09>> 9, Hex 09, Octal 011", Do_ga("\t"))
16+
17+
set display=
18+
call assert_equal("\nNUL", Do_ga(''))
19+
call assert_equal("\n<^A> 1, Hex 01, Octal 001", Do_ga("\x01"))
20+
call assert_equal("\n<^I> 9, Hex 09, Octal 011", Do_ga("\t"))
21+
22+
call assert_equal("\n<e> 101, Hex 65, Octal 145", Do_ga('e'))
23+
24+
if !has('multi_byte')
25+
return
26+
endif
27+
28+
" Test a few multi-bytes characters.
29+
call assert_equal("\n<é> 233, Hex 00e9, Octal 351", Do_ga('é'))
30+
call assert_equal("\n<ẻ> 7867, Hex 1ebb, Octal 17273", Do_ga(''))
31+
32+
" Test with combining characters.
33+
call assert_equal("\n<e> 101, Hex 65, Octal 145 < ́> 769, Hex 0301, Octal 1401", Do_ga("e\u0301"))
34+
call assert_equal("\n<e> 101, Hex 65, Octal 145 < ́> 769, Hex 0301, Octal 1401 < ̱> 817, Hex 0331, Octal 1461", Do_ga("e\u0301\u0331"))
35+
call assert_equal("\n<e> 101, Hex 65, Octal 145 < ́> 769, Hex 0301, Octal 1401 < ̱> 817, Hex 0331, Octal 1461 < ̸> 824, Hex 0338, Octal 1470", Do_ga("e\u0301\u0331\u0338"))
36+
bwipe!
37+
endfunc

src/testdir/test_mksession.vim

+12
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,16 @@ func Test_mksession_winheight()
110110
call delete('Xtest_mks.out')
111111
endfunc
112112

113+
func Test_mksession_arglist()
114+
argdel *
115+
next file1 file2 file3 file4
116+
mksession! Xtest_mks.out
117+
source Xtest_mks.out
118+
call assert_equal(['file1', 'file2', 'file3', 'file4'], argv())
119+
120+
call delete('Xtest_mks.out')
121+
argdel *
122+
endfunc
123+
124+
113125
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_normal.vim

+3
Original file line numberDiff line numberDiff line change
@@ -2193,6 +2193,8 @@ func! Test_normal51_FileChangedRO()
21932193
if !has("autocmd")
21942194
return
21952195
endif
2196+
" Don't sleep after the warning message.
2197+
call test_settime(1)
21962198
call writefile(['foo'], 'Xreadonly.log')
21972199
new Xreadonly.log
21982200
setl ro
@@ -2202,6 +2204,7 @@ func! Test_normal51_FileChangedRO()
22022204
call assert_equal('Xreadonly.log', bufname(''))
22032205

22042206
" cleanup
2207+
call test_settime(0)
22052208
bw!
22062209
call delete("Xreadonly.log")
22072210
endfunc

src/testdir/test_paste.vim

+22-4
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,36 @@ set term=xterm
88

99
func Test_paste_normal_mode()
1010
new
11+
" In first column text is inserted
1112
call setline(1, ['a', 'b', 'c'])
12-
2
13+
call cursor(2, 1)
1314
call feedkeys("\<Esc>[200~foo\<CR>bar\<Esc>[201~", 'xt')
14-
call assert_equal('bfoo', getline(2))
15-
call assert_equal('bar', getline(3))
15+
call assert_equal('foo', getline(2))
16+
call assert_equal('barb', getline(3))
1617
call assert_equal('c', getline(4))
1718

19+
" When repeating text is appended
1820
normal .
1921
call assert_equal('barfoo', getline(3))
20-
call assert_equal('bar', getline(4))
22+
call assert_equal('barb', getline(4))
2123
call assert_equal('c', getline(5))
2224
bwipe!
25+
26+
" In second column text is appended
27+
call setline(1, ['a', 'bbb', 'c'])
28+
call cursor(2, 2)
29+
call feedkeys("\<Esc>[200~foo\<CR>bar\<Esc>[201~", 'xt')
30+
call assert_equal('bbfoo', getline(2))
31+
call assert_equal('barb', getline(3))
32+
call assert_equal('c', getline(4))
33+
34+
" In last column text is appended
35+
call setline(1, ['a', 'bbb', 'c'])
36+
call cursor(2, 3)
37+
call feedkeys("\<Esc>[200~foo\<CR>bar\<Esc>[201~", 'xt')
38+
call assert_equal('bbbfoo', getline(2))
39+
call assert_equal('bar', getline(3))
40+
call assert_equal('c', getline(4))
2341
endfunc
2442

2543
func Test_paste_insert_mode()

src/testdir/test_stat.vim

+21-14
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,54 @@
11
" Tests for stat functions and checktime
22

33
func Test_existent_file()
4-
let fname='Xtest.tmp'
4+
let fname = 'Xtest.tmp'
55

6-
let ts=localtime()
7-
sleep 1
8-
let fl=['Hello World!']
6+
let ts = localtime()
7+
let fl = ['Hello World!']
98
call writefile(fl, fname)
10-
let tf=getftime(fname)
11-
sleep 1
12-
let te=localtime()
9+
let tf = getftime(fname)
10+
let te = localtime()
1311

1412
call assert_true(ts <= tf && tf <= te)
1513
call assert_equal(strlen(fl[0] . "\n"), getfsize(fname))
1614
call assert_equal('file', getftype(fname))
1715
call assert_equal('rw-', getfperm(fname)[0:2])
16+
17+
call delete(fname)
1818
endfunc
1919

2020
func Test_existent_directory()
21-
let dname='.'
21+
let dname = '.'
2222

2323
call assert_equal(0, getfsize(dname))
2424
call assert_equal('dir', getftype(dname))
2525
call assert_equal('rwx', getfperm(dname)[0:2])
2626
endfunc
2727

2828
func Test_checktime()
29-
let fname='Xtest.tmp'
29+
let fname = 'Xtest.tmp'
3030

31-
let fl=['Hello World!']
31+
let fl = ['Hello World!']
3232
call writefile(fl, fname)
3333
set autoread
3434
exec 'e' fname
35-
sleep 2
36-
let fl=readfile(fname)
35+
" FAT has a granularity of 2 seconds, otherwise it's usually 1 second
36+
if has('win32')
37+
sleep 2
38+
else
39+
sleep 1
40+
endif
41+
let fl = readfile(fname)
3742
let fl[0] .= ' - checktime'
3843
call writefile(fl, fname)
3944
checktime
4045
call assert_equal(fl[0], getline(1))
46+
47+
call delete(fname)
4148
endfunc
4249

4350
func Test_nonexistent_file()
44-
let fname='Xtest.tmp'
51+
let fname = 'Xtest.tmp'
4552

4653
call delete(fname)
4754
call assert_equal(-1, getftime(fname))
@@ -55,7 +62,7 @@ func Test_win32_symlink_dir()
5562
" So we use an existing symlink for this test.
5663
if has('win32')
5764
" Check if 'C:\Users\All Users' is a symlink to a directory.
58-
let res=system('dir C:\Users /a')
65+
let res = system('dir C:\Users /a')
5966
if match(res, '\C<SYMLINKD> *All Users') >= 0
6067
" Get the filetype of the symlink.
6168
call assert_equal('dir', getftype('C:\Users\All Users'))

src/testdir/test_visual.vim

+13
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,16 @@ func Test_dotregister_paste()
2323
call assert_equal('hello world world', getline(1))
2424
q!
2525
endfunc
26+
27+
func Test_Visual_ctrl_o()
28+
new
29+
call setline(1, ['one', 'two', 'three'])
30+
call cursor(1,2)
31+
set noshowmode
32+
set tw=0
33+
call feedkeys("\<c-v>jjlIa\<c-\>\<c-o>:set tw=88\<cr>\<esc>", 'tx')
34+
call assert_equal(['oane', 'tawo', 'tahree'], getline(1, 3))
35+
call assert_equal(88, &tw)
36+
set tw&
37+
bw!
38+
endfu

0 commit comments

Comments
 (0)