Skip to content

Commit 59671a2

Browse files
committed
Fix documentation, add syntax highlight, add unit tests
1 parent 12fec21 commit 59671a2

File tree

6 files changed

+54
-9
lines changed

6 files changed

+54
-9
lines changed

runtime/doc/windows.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ window will appear.
286286
" current one
287287
:-curwin help " opens help in the window before the
288288
" current one
289-
:0curwin help " opens help in the top left window
289+
:1curwin help " opens help in the top left window
290290
:$curwin help " opens help in the bottom right window
291291
:+curwin copen " opens quickfix in the next window
292292
:3curwin! split " opens current buffer in the 3rd window

runtime/syntax/vim.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ syn keyword vimCommand contained abc[lear] argdo au bel[owright] bp[revious] bro
2525
syn keyword vimCommand contained abo[veleft] arge[dit] bN[ext] bf[irst] br[ewind] bufdo c[hange] cat[ch] cdo cg[etfile] checkt[ime] cmapc[lear] colo[rscheme] cope[n] cscope debugg[reedy] deletl dep diffpu[t] dl ds[earch] echoe[rr] en[dif] ex filetype fix[del] for gui helpg[rep] ia in ju[mps] keepp[atterns] laddb[uffer] lbo[ttom] ld[o] lfir[st] lh[elpgrep] lmapc[lear] loadkeymap lpf[ile] luafile mak[e] mk[exrc] mz[scheme] nbs[tart] noh[lsearch] o[pen] ownsyntax pe[rl] pp[op] profd[el] pta[g] ptp[revious] py3 python3 q[uit] red[o] res[ize] rightb[elow] rundo sIg sN[ext] sbN[ext] sbm[odified] scI scp se[t] sfir[st] sgi sh[ell] sign sir sme snoreme spe[llgood] spellw[rong] sre[wind] srp startr[eplace] sunme sy t tabc[lose] tabl[ast] tabp[revious] tcld[o] tj[ump] tn[ext] try una[bbreviate] unlo[ckvar] verb[ose] vimgrepa[dd] wN[ext] winc[md] wq x[it] xnoreme xwininfo
2626
syn keyword vimCommand contained al[l] argg[lobal] b[uffer] bl[ast] brea[k] buffers cabc[lear] cb[uffer] ce[nter] cgetb[uffer] chi[story] cn[ext] com cp[revious] cstag delc[ommand] deletp di[splay] diffs[plit] dli[st] dsp[lit] echom[sg] endf[unction] exi[t] filt[er] fo[ld] fu[nction] gvim helpt[ags] iabc[lear] intro k lN[ext] laddf[ile] lc[d] le[ft] lg[etfile] lhi[story] lne[xt] loc[kmarks] lr[ewind] lv[imgrep] marks mks[ession] mzf[ile] new nor ol[dfiles] p[rint] ped[it] pre[serve] promptf[ind] ptf[irst] ptr[ewind] py3do pythonx qa[ll] redi[r] ret[ab] ru[ntime] rv[iminfo] sIl sa[rgument] sb[uffer] sbn[ext] sce scr[iptnames] setf[iletype] sg sgl si sil[ent] sl[eep] smenu snoremenu spelld[ump] spr[evious] srg st[op] stj[ump] sunmenu syn tN[ext] tabd[o] tabm[ove] tabr[ewind] tclf[ile] tl[ast] tno[remap] ts[elect] undoj[oin] uns[ilent] vert[ical] viu[sage] w[rite] windo wqa[ll] xa[ll] xnoremenu y[ank]
2727
syn keyword vimCommand contained ar[gs] argl[ocal] ba[ll] bm[odified] breaka[dd] bun[load] cad[dbuffer] cbo[ttom] cex[pr] cgete[xpr] cl[ist] cnew[er] comc[lear] cpf[ile] cuna[bbrev] delel delf[unction] dif[fupdate] difft[his] do e[dit] echon endfo[r] exu[sage] fin[d] foldc[lose] g h[elp] hi if is[earch] kee[pmarks] lNf[ile] lan[guage] lch[dir] lefta[bove] lgetb[uffer] ll lnew[er] lockv[ar] ls lvimgrepa[dd] mat[ch] mksp[ell]
28-
syn keyword vimCommand contained ter[minal]
28+
syn keyword vimCommand contained ter[minal] cur[win]
2929

3030
syn match vimCommand contained "\<z[-+^.=]\=\>"
3131
syn keyword vimStdPlugin contained DiffOrig Man N[ext] P[rint] S TOhtml XMLent XMLns

src/ex_docmd.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6733,6 +6733,7 @@ uc_check_code(
67336733
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
67346734
{&cmdmod.confirm, "confirm"},
67356735
#endif
6736+
{&cmdmod.curwin, "curwin"},
67366737
{&cmdmod.hide, "hide"},
67376738
{&cmdmod.keepalt, "keepalt"},
67386739
{&cmdmod.keepjumps, "keepjumps"},
@@ -6761,9 +6762,6 @@ uc_check_code(
67616762
/* :botright */
67626763
if (cmdmod.split & WSP_BOT)
67636764
result += add_cmd_modifier(buf, "botright", &multi_mods);
6764-
/* :curwin */
6765-
if (cmdmod.curwin > 0)
6766-
result += add_cmd_modifier(buf, "curwin", &multi_mods);
67676765

67686766
/* the modifiers that are simple flags */
67696767
for (i = 0; mod_entries[i].varp != NULL; ++i)

src/testdir/test_terminal.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,14 @@ func Test_terminal_curwin()
357357
call assert_equal(2, winnr('$'))
358358
bwipe!
359359

360+
split dummy
361+
split dummy2
362+
exe '2curwin terminal ' . cmd
363+
call assert_equal(2, winnr())
364+
call assert_equal(3, winnr('$'))
365+
bwipe!
366+
bwipe!
367+
360368
split dummy
361369
call term_start(cmd, {'curwin': 1})
362370
call assert_equal(2, winnr('$'))

src/testdir/test_usercommands.vim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function Test_cmdmods()
1717
bro MyCmd
1818
confirm MyCmd
1919
conf MyCmd
20+
curwin MyCmd
2021
hide MyCmd
2122
hid MyCmd
2223
keepalt MyCmd
@@ -48,17 +49,17 @@ function Test_cmdmods()
4849
vertical MyCmd
4950
vert MyCmd
5051

51-
aboveleft belowright botright browse confirm hide keepalt keepjumps
52+
aboveleft belowright botright browse confirm curwin hide keepalt keepjumps
5253
\ keepmarks keeppatterns lockmarks noswapfile silent tab
5354
\ topleft verbose vertical MyCmd
5455

5556
call assert_equal(' aboveleft aboveleft belowright belowright botright ' .
56-
\ 'botright browse browse confirm confirm hide hide ' .
57+
\ 'botright browse browse confirm confirm curwin hide hide ' .
5758
\ 'keepalt keepalt keepjumps keepjumps keepmarks keepmarks ' .
5859
\ 'keeppatterns keeppatterns aboveleft aboveleft lockmarks lockmarks noswapfile ' .
5960
\ 'noswapfile belowright belowright silent silent tab topleft topleft verbose verbose ' .
6061
\ 'vertical vertical ' .
61-
\ 'aboveleft belowright botright browse confirm hide keepalt keepjumps ' .
62+
\ 'aboveleft belowright botright browse confirm curwin hide keepalt keepjumps ' .
6263
\ 'keepmarks keeppatterns lockmarks noswapfile silent tab topleft ' .
6364
\ 'verbose vertical ', g:mods)
6465

src/testdir/test_window_cmd.vim

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,44 @@ func Test_window_vertical_split()
103103
bw
104104
endfunc
105105

106+
func Test_window_curwin()
107+
call assert_equal(1, winnr('$'))
108+
split
109+
split
110+
split
111+
call assert_equal(4, winnr('$'))
112+
113+
2wincmd w
114+
curwin help
115+
call assert_equal(2, winnr())
116+
3curwin sp
117+
call assert_equal(3, winnr())
118+
+curwin sp
119+
call assert_equal(4, winnr())
120+
1curwin sp
121+
call assert_equal(1, winnr())
122+
call assert_equal(4, winnr('$'))
123+
124+
bw
125+
126+
" Now test whether :curwin! works in discarding changes
127+
new
128+
new
129+
put ='text'
130+
let l:bufnr = bufnr('%')
131+
132+
2wincmd w
133+
call assert_fails('1curwin sp', 'E37:')
134+
call assert_true(bufloaded(l:bufnr))
135+
1curwin! sp
136+
call assert_false(bufloaded(l:bufnr))
137+
call assert_equal(1, winnr())
138+
call assert_equal(3, winnr('$'))
139+
140+
bw!
141+
call assert_equal(1, winnr('$'))
142+
endfunc
143+
106144
func Test_window_split_edit_alternate()
107145
e Xa
108146
e Xb
@@ -322,7 +360,7 @@ func Test_equalalways_on_close()
322360
set equalalways
323361
vsplit
324362
windo split
325-
split
363+
split
326364
wincmd J
327365
" now we have a frame top-left with two windows, a frame top-right with two
328366
" windows and a frame at the bottom, full-width.

0 commit comments

Comments
 (0)