Skip to content

Commit 5f761f8

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 9235d12 + f1f6f3f commit 5f761f8

11 files changed

Lines changed: 163 additions & 28 deletions

File tree

runtime/macros/matchit.vim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
" Load the matchit package.
22
" For those users who were loading the matchit plugin from here.
3-
packadd matchit
3+
if 1
4+
packadd matchit
5+
endif

runtime/mswin.vim

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Set options and add mapping such that Vim behaves a lot like MS-Windows
22
"
33
" Maintainer: Bram Moolenaar <[email protected]>
4-
" Last change: 2012 Jul 25
4+
" Last change: 2017 Feb 09
55

66
" bail out if this isn't wanted (mrsvim.vim uses this).
77
if exists("g:skip_loading_mswin") && g:skip_loading_mswin
@@ -23,29 +23,33 @@ set backspace=indent,eol,start whichwrap+=<,>,[,]
2323
" backspace in Visual mode deletes selection
2424
vnoremap <BS> d
2525
26-
" CTRL-X and SHIFT-Del are Cut
27-
vnoremap <C-X> "+x
28-
vnoremap <S-Del> "+x
26+
if has("clipboard")
27+
" CTRL-X and SHIFT-Del are Cut
28+
vnoremap <C-X> "+x
29+
vnoremap <S-Del> "+x
2930
30-
" CTRL-C and CTRL-Insert are Copy
31-
vnoremap <C-C> "+y
32-
vnoremap <C-Insert> "+y
31+
" CTRL-C and CTRL-Insert are Copy
32+
vnoremap <C-C> "+y
33+
vnoremap <C-Insert> "+y
3334
34-
" CTRL-V and SHIFT-Insert are Paste
35-
map <C-V> "+gP
36-
map <S-Insert> "+gP
35+
" CTRL-V and SHIFT-Insert are Paste
36+
map <C-V> "+gP
37+
map <S-Insert> "+gP
3738
38-
cmap <C-V> <C-R>+
39-
cmap <S-Insert> <C-R>+
39+
cmap <C-V> <C-R>+
40+
cmap <S-Insert> <C-R>+
41+
endif
4042

4143
" Pasting blockwise and linewise selections is not possible in Insert and
4244
" Visual mode without the +virtualedit feature. They are pasted as if they
4345
" were characterwise instead.
4446
" Uses the paste.vim autoload script.
4547
" Use CTRL-G u to have CTRL-Z only undo the paste.
4648

47-
exe 'inoremap <script> <C-V> <C-G>u' . paste#paste_cmd['i']
48-
exe 'vnoremap <script> <C-V> ' . paste#paste_cmd['v']
49+
if 1
50+
exe 'inoremap <script> <C-V> <C-G>u' . paste#paste_cmd['i']
51+
exe 'vnoremap <script> <C-V> ' . paste#paste_cmd['v']
52+
endif
4953

5054
imap <S-Insert> <C-V>
5155
vmap <S-Insert> <C-V>
@@ -99,6 +103,18 @@ inoremap <C-F4> <C-O><C-W>c
99103
cnoremap <C-F4> <C-C><C-W>c
100104
onoremap <C-F4> <C-C><C-W>c
101105
106+
if has("gui")
107+
" CTRL-F is the search dialog
108+
noremap <C-F> :promptfind<CR>
109+
inoremap <C-F> <C-\><C-O>:promptfind<CR>
110+
cnoremap <C-F> <C-\><C-C>:promptfind<CR>
111+
112+
" CTRL-H is the replace dialog
113+
noremap <C-H> :promptrepl<CR>
114+
inoremap <C-H> <C-\><C-O>:promptrepl<CR>
115+
cnoremap <C-H> <C-\><C-C>:promptrepl<CR>
116+
endif
117+
102118
" restore 'cpoptions'
103119
set cpo&
104120
if 1

src/edit.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3476,10 +3476,13 @@ ins_compl_bs(void)
34763476
mb_ptr_back(line, p);
34773477

34783478
/* Stop completion when the whole word was deleted. For Omni completion
3479-
* allow the word to be deleted, we won't match everything. */
3479+
* allow the word to be deleted, we won't match everything.
3480+
* Respect the 'backspace' option. */
34803481
if ((int)(p - line) - (int)compl_col < 0
34813482
|| ((int)(p - line) - (int)compl_col == 0
3482-
&& ctrl_x_mode != CTRL_X_OMNI) || ctrl_x_mode == CTRL_X_EVAL)
3483+
&& ctrl_x_mode != CTRL_X_OMNI) || ctrl_x_mode == CTRL_X_EVAL
3484+
|| (!can_bs(BS_START) && (int)(p - line) - (int)compl_col
3485+
- compl_length < 0))
34833486
return K_BS;
34843487

34853488
/* Deleted more than what was used to find matches or didn't finish

src/ex_cmds.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6503,18 +6503,20 @@ find_help_tags(
65036503
static char *(mtable[]) = {"*", "g*", "[*", "]*", ":*",
65046504
"/*", "/\\*", "\"*", "**",
65056505
"cpo-*", "/\\(\\)", "/\\%(\\)",
6506-
"?", ":?", "?<CR>", "g?", "g?g?", "g??", "z?",
6506+
"?", ":?", "?<CR>", "g?", "g?g?", "g??",
65076507
"/\\?", "/\\z(\\)", "\\=", ":s\\=",
6508-
"[count]", "[quotex]", "[range]",
6508+
"[count]", "[quotex]",
6509+
"[range]", ":[range]",
65096510
"[pattern]", "\\|", "\\%$",
65106511
"s/\\~", "s/\\U", "s/\\L",
65116512
"s/\\1", "s/\\2", "s/\\3", "s/\\9"};
65126513
static char *(rtable[]) = {"star", "gstar", "[star", "]star", ":star",
65136514
"/star", "/\\\\star", "quotestar", "starstar",
65146515
"cpo-star", "/\\\\(\\\\)", "/\\\\%(\\\\)",
6515-
"?", ":?", "?<CR>", "g?", "g?g?", "g??", "z?",
6516+
"?", ":?", "?<CR>", "g?", "g?g?", "g??",
65166517
"/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=",
6517-
"\\[count]", "\\[quotex]", "\\[range]",
6518+
"\\[count]", "\\[quotex]",
6519+
"\\[range]", ":\\[range]",
65186520
"\\[pattern]", "\\\\bar", "/\\\\%\\$",
65196521
"s/\\\\\\~", "s/\\\\U", "s/\\\\L",
65206522
"s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9"};

src/ex_docmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,8 +2302,8 @@ do_one_cmd(
23022302
if (!ea.skip)
23032303
{
23042304
curwin->w_cursor.lnum = ea.line2;
2305-
/* don't leave the cursor on an illegal line */
2306-
check_cursor_lnum();
2305+
/* don't leave the cursor on an illegal line or column */
2306+
check_cursor();
23072307
}
23082308
}
23092309
else if (*ea.cmd != ',')

src/ex_getln.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ getcmdline(
212212
#endif
213213
expand_T xpc;
214214
long *b_im_ptr = NULL;
215-
#if defined(FEAT_WILDMENU) || defined(FEAT_EVAL) \
216-
|| defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CMDWIN)
215+
#if defined(FEAT_WILDMENU) || defined(FEAT_EVAL) || defined(FEAT_SEARCH_EXTRA)
217216
/* Everything that may work recursively should save and restore the
218217
* current command line in save_ccline. That includes update_screen(), a
219218
* custom status line may invoke ":normal". */

src/spellfile.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,9 @@ spell_read_tree(
15951595
len = get4c(fd);
15961596
if (len < 0)
15971597
return SP_TRUNCERROR;
1598+
if (len >= 0x3ffffff)
1599+
/* Invalid length, multiply with sizeof(int) would overflow. */
1600+
return SP_FORMERROR;
15981601
if (len > 0)
15991602
{
16001603
/* Allocate the byte array. */

src/testdir/test_cmdline.vim

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,24 @@ func Test_remove_char_in_cmdline()
289289
call assert_equal('"def', @:)
290290
endfunc
291291

292-
func Test_illegal_address()
292+
func Test_illegal_address1()
293293
new
294294
2;'(
295295
2;')
296296
quit
297297
endfunc
298298

299+
func Test_illegal_address2()
300+
call writefile(['c', 'x', ' x', '.', '1;y'], 'Xtest.vim')
301+
new
302+
source Xtest.vim
303+
" Trigger calling validate_cursor()
304+
diffsp Xtest.vim
305+
quit!
306+
bwipe!
307+
call delete('Xtest.vim')
308+
endfunc
309+
299310
func Test_cmdline_complete_wildoptions()
300311
help
301312
call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx')
@@ -353,7 +364,7 @@ func Test_getcmdtype()
353364
call feedkeys("?MyCmd a\<C-R>=Check_cmdline('?')\<CR>\<Esc>", "xt")
354365

355366
call feedkeys(":call input('Answer?')\<CR>", "t")
356-
call feedkeys("MyCmd a\<C-R>=Check_cmdline('@')\<CR>\<Esc>", "xt")
367+
call feedkeys("MyCmd a\<C-R>=Check_cmdline('@')\<CR>\<C-C>", "xt")
357368

358369
call feedkeys(":insert\<CR>MyCmd a\<C-R>=Check_cmdline('-')\<CR>\<Esc>", "xt")
359370

src/testdir/test_gui.vim

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func Test_getfontname_with_arg()
4141
call assert_equal('', getfontname('notexist'))
4242

4343
" Valid font name. This is usually the real name of 7x13 by default.
44-
let l:fname = '-Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO10646-1'
44+
let l:fname = '-misc-fixed-medium-r-normal--13-120-75-75-c-70-iso8859-1'
4545
call assert_equal(l:fname, getfontname(l:fname))
4646

4747
elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
@@ -72,6 +72,65 @@ func Test_getfontname_without_arg()
7272
endif
7373
endfunc
7474

75+
func Test_set_guifont()
76+
let l:guifont_saved = &guifont
77+
if has('xfontset')
78+
" Prevent 'guifontset' from canceling 'guifont'.
79+
let l:guifontset_saved = &guifontset
80+
set guifontset=
81+
endif
82+
83+
let skipped = 0
84+
if has('gui_athena') || has('gui_motif')
85+
" Non-empty font list with invalid font names.
86+
"
87+
" This test is twofold: (1) It checks if the command fails as expected
88+
" when there are no loadable fonts found in the list. (2) It checks if
89+
" 'guifont' remains the same after the command loads none of the fonts
90+
" listed.
91+
let l:flist = &guifont
92+
call assert_fails('set guifont=-notexist1-*,-notexist2-*')
93+
call assert_equal(l:flist, &guifont)
94+
95+
" Non-empty font list with a valid font name. Should pick up the first
96+
" valid font.
97+
set guifont=-notexist1-*,fixed,-notexist2-*
98+
call assert_equal('fixed', getfontname())
99+
100+
" Empty list. Should fallback to the built-in default.
101+
set guifont=
102+
call assert_equal('7x13', getfontname())
103+
104+
elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
105+
" For GTK, what we refer to as 'font names' in our manual are actually
106+
" 'initial font patterns'. A valid font which matches the 'canonical font
107+
" pattern' constructed from a given 'initial pattern' is to be looked up
108+
" and loaded. That explains why the GTK GUIs appear to accept 'invalid
109+
" font names'.
110+
"
111+
" Non-empty list. Should always pick up the first element, no matter how
112+
" strange it is, as explained above.
113+
set guifont=(´・ω・`)\ 12,Courier\ 12
114+
call assert_equal('(´・ω・`) 12', getfontname())
115+
116+
" Empty list. Should fallback to the built-in default.
117+
set guifont=
118+
call assert_equal('Monospace 10', getfontname())
119+
120+
else
121+
let skipped = 1
122+
endif
123+
124+
if has('xfontset')
125+
let &guifontset = l:guifontset_saved
126+
endif
127+
let &guifont = l:guifont_saved
128+
129+
if skipped
130+
throw "Skipped: Test not implemented yet for this GUI"
131+
endif
132+
endfunc
133+
75134
func Test_getwinpos()
76135
call assert_match('Window position: X \d\+, Y \d\+', execute('winpos'))
77136
call assert_true(getwinposx() >= 0)

src/testdir/test_popup.vim

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,4 +511,24 @@ func Test_completion_clear_candidate_list()
511511
bw!
512512
endfunc
513513

514+
func Test_completion_respect_bs_option()
515+
new
516+
let li = ["aaa", "aaa12345", "aaaabcdef", "aaaABC"]
517+
518+
set bs=indent,eol
519+
call setline(1, li)
520+
1
521+
call feedkeys("A\<C-X>\<C-N>\<C-P>\<BS>\<BS>\<BS>\<Esc>", "tx")
522+
call assert_equal('aaa', getline(1))
523+
524+
%d
525+
set bs=indent,eol,start
526+
call setline(1, li)
527+
1
528+
call feedkeys("A\<C-X>\<C-N>\<C-P>\<BS>\<BS>\<BS>\<Esc>", "tx")
529+
call assert_equal('', getline(1))
530+
531+
bw!
532+
endfunc
533+
514534
" vim: shiftwidth=2 sts=2 expandtab

0 commit comments

Comments
 (0)