annotate src/testdir/test_man.vim @ 17470:d2a834aa7cc0 v8.1.1733

patch 8.1.1733: the man ftplugin leaves an empty buffer behind commit https://github.com/vim/vim/commit/e5e6950193ddf365c6c507ddefcd7f9db939e5ac Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jul 22 22:09:21 2019 +0200 patch 8.1.1733: the man ftplugin leaves an empty buffer behind Problem: The man ftplugin leaves an empty buffer behind. Solution: Don't make new window and edit, use split. (Jason Franklin)
author Bram Moolenaar <Bram@vim.org>
date Mon, 22 Jul 2019 22:15:04 +0200
parents ccbb8e393d80
children d9aa921b7198
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 runtime ftplugin/man.vim
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 function Test_g_ft_man_open_mode()
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 vnew
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 let l:h = winheight(1)
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 q
9636
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 9326
diff changeset
7 let l:w = winwidth(1)
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 " split horizontally
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 let wincnt = winnr('$')
9636
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 9326
diff changeset
11 Man vim
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 if wincnt == winnr('$')
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 " Vim manual page cannot be found.
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 return
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 endif
9636
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 9326
diff changeset
16
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 9326
diff changeset
17 call assert_inrange(l:w - 2, l:w + 2, winwidth(1))
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call assert_true(l:h > winheight(1))
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call assert_equal(1, tabpagenr('$'))
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call assert_equal(1, tabpagenr())
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 q
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 " split horizontally
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 let g:ft_man_open_mode = "horz"
9636
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 9326
diff changeset
25 Man vim
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 9326
diff changeset
26 call assert_inrange(l:w - 2, l:w + 2, winwidth(1))
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call assert_true(l:h > winheight(1))
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 call assert_equal(1, tabpagenr('$'))
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 call assert_equal(1, tabpagenr())
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 q
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 " split vertically
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 let g:ft_man_open_mode = "vert"
9636
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 9326
diff changeset
34 Man vim
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 call assert_true(l:w > winwidth(1))
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 call assert_equal(l:h, winheight(1))
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 call assert_equal(1, tabpagenr('$'))
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 call assert_equal(1, tabpagenr())
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 q
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 " separate tab
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 let g:ft_man_open_mode = "tab"
9636
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 9326
diff changeset
43 Man vim
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 9326
diff changeset
44 call assert_inrange(l:w - 2, l:w + 2, winwidth(1))
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 9326
diff changeset
45 call assert_inrange(l:h - 1, l:h + 1, winheight(1))
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 call assert_equal(2, tabpagenr('$'))
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 call assert_equal(2, tabpagenr())
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 q
17470
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
49
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
50 unlet g:ft_man_open_mode
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 endfunction
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 function Test_nomodifiable()
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 let wincnt = winnr('$')
9636
ccbb8e393d80 commit https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78
Christian Brabandt <cb@256bit.org>
parents: 9326
diff changeset
55 Man vim
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 if wincnt == winnr('$')
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 " Vim manual page cannot be found.
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 return
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 endif
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 call assert_false(&l:modifiable)
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 q
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 endfunction
17470
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
63
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
64 function Test_buffer_count_hidden()
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
65 %bw!
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
66 set hidden
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
67
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
68 call assert_equal(1, len(getbufinfo()))
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
69
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
70 let wincnt = winnr('$')
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
71 Man vim
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
72 if wincnt == winnr('$')
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
73 " Vim manual page cannot be found.
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
74 return
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
75 endif
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
76
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
77 call assert_equal(1, len(getbufinfo({'buflisted':1})))
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
78 call assert_equal(2, len(getbufinfo()))
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
79 q
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
80
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
81 Man vim
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
82
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
83 call assert_equal(1, len(getbufinfo({'buflisted':1})))
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
84 call assert_equal(2, len(getbufinfo()))
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
85 q
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
86
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
87 set hidden&
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 9636
diff changeset
88 endfunction