annotate src/testdir/test_winfixbuf.vim @ 34656:3b29a2cdbf74 v9.1.0212

patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf Commit: https://github.com/vim/vim/commit/79b2867ce3f4ed99d8c4e06c2c3b8f105f67c53a Author: Christian Brabandt <cb@256bit.org> Date: Wed Mar 27 10:44:14 2024 +0100 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf Problem: CI: MS-Windows fails in test_winfixbuf (after v9.1.208) Solution: Skip Ms-Windows for now, fix style related: #14286 Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Wed, 27 Mar 2024 11:00:06 +0100
parents 6b2efa2b2386
children 224d4a792264
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test 'winfixbuf'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 source check.vim
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 " Find the number of open windows in the current tab
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 func s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 return tabpagewinnr(tabpagenr(), '$')
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 " Create some unnamed buffers.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 func s:make_buffers_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 file first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 let l:first = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 file middle
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 let l:middle = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 file last
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 let l:last = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 return [l:first, l:last]
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 " Create some unnamed buffers and add them to an args list
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 func s:make_args_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 let [l:first, l:last] = s:make_buffers_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 args! first middle last
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 return [l:first, l:last]
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 " Create two buffers and then set the window to 'winfixbuf'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 func s:make_buffer_pairs(...)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 let l:reversed = get(a:, 1, 0)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 if l:reversed == 1
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 file original
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 enew!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 file other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 let l:other = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 return l:other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 endif
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 file other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 let l:other = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 file current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 return l:other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 " Create 3 quick buffers and set the window to 'winfixbuf'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 func s:make_buffer_trio()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 edit first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 let l:first = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 edit second
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 let l:second = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 edit! third
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 let l:third = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 execute ":buffer! " . l:second
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 return [l:first, l:second, l:third]
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 " Create a location list with at least 2 entries + a 'winfixbuf' window.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 func s:make_simple_location_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 file middle
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 let l:middle = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 call append(0, ["winfix search-term", "another line"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 enew!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 file first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 let l:first = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 call append(0, "first search-term")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 enew!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 file last
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 let l:last = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 call append(0, "last search-term")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 call setloclist(
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 \ 0,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 \ [
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 \ {
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 \ "filename": "first",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 \ "bufnr": l:first,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 \ "lnum": 1,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 \ },
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 \ {
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 \ "filename": "middle",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 \ "bufnr": l:middle,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 \ "lnum": 1,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 \ },
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 \ {
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 \ "filename": "middle",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 \ "bufnr": l:middle,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 \ "lnum": 2,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118 \ },
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 \ {
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 \ "filename": "last",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 \ "bufnr": l:last,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 \ "lnum": 1,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 \ },
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 \ ]
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 \)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129 return [l:first, l:middle, l:last]
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 " Create a quickfix with at least 2 entries that are in the current 'winfixbuf' window.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 func s:make_simple_quickfix()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 file current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 call append(0, ["winfix search-term", "another line"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 enew!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 file first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 let l:first = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 call append(0, "first search-term")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144 enew!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145 file last
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146 let l:last = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 call append(0, "last search-term")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 call setqflist(
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 \ [
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 \ {
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 \ "filename": "first",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 \ "bufnr": l:first,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 \ "lnum": 1,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 \ },
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 \ {
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 \ "filename": "current",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 \ "bufnr": l:current,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 \ "lnum": 1,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 \ },
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 \ {
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 \ "filename": "current",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 \ "bufnr": l:current,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 \ "lnum": 2,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 \ },
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 \ {
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 \ "filename": "last",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 \ "bufnr": l:last,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 \ "lnum": 1,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 \ },
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 \ ]
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172 \)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 return [l:current, l:last]
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 " Create a quickfix with at least 2 entries that are in the current 'winfixbuf' window.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 func s:make_quickfix_windows()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 let [l:current, _] = s:make_simple_quickfix()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 execute "buffer! " . l:current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 split
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 let l:first_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 let l:winfix_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
188
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
189 " Open the quickfix in a separate split and go to it
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190 copen
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
191 let l:quickfix_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
192
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193 return [l:first_window, l:winfix_window, l:quickfix_window]
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
196 " Revert all changes that occurred in any past test
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
197 func s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
198 %bwipeout!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
199 set nowinfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
200
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
201 call setqflist([])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
202
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
203 for l:window_info in getwininfo()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
204 call setloclist(l:window_info["winid"], [])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
205 endfor
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
206
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207 delmarks A-Z0-9
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210 " Find and set the first quickfix entry that points to `buffer`
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 func s:set_quickfix_by_buffer(buffer)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
212 let l:index = 1 " quickfix indices start at 1
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213 for l:entry in getqflist()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
214 if l:entry["bufnr"] == a:buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 execute l:index . "cc"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
216
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 return
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
218 endif
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
219
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
220 let l:index += 1
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
221 endfor
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223 echoerr 'No quickfix entry matching "' . a:buffer . '" could be found.'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
224 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
225
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226 " Fail to call :Next on a 'winfixbuf' window unless :Next! is used.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
227 func Test_Next()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
228 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
229
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
230 let [l:first, _] = s:make_args_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231 next!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
232
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
233 call assert_fails("Next", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
234 call assert_notequal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
235
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
236 Next!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
237 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
238 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
240 " Call :argdo and choose the next available 'nowinfixbuf' window.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
241 func Test_argdo_choose_available_window()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
242 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
243
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
244 let [_, l:last] = s:make_args_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
245
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
246 " Make a split window that is 'nowinfixbuf' but make it the second-to-last
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
247 " window so that :argdo will first try the 'winfixbuf' window, pass over it,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
248 " and prefer the other 'nowinfixbuf' window, instead.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
249 "
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
250 " +-------------------+
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
251 " | 'nowinfixbuf' |
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
252 " +-------------------+
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
253 " | 'winfixbuf' | <-- Cursor is here
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
254 " +-------------------+
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
255 split
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
256 let l:nowinfixbuf_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
257 " Move to the 'winfixbuf' window now
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
258 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
259 let l:winfixbuf_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
260 let l:expected_windows = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
261
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
262 argdo echo ''
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
263 call assert_equal(l:nowinfixbuf_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
264 call assert_equal(l:last, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
265 call assert_equal(l:expected_windows, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
266 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
267
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
268 " Call :argdo and create a new split window if all available windows are 'winfixbuf'.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
269 func Test_argdo_make_new_window()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
270 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
271
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
272 let [l:first, l:last] = s:make_args_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
273 let l:current = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
274 let l:current_windows = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
275
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
276 argdo echo ''
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
277 call assert_notequal(l:current, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
278 call assert_equal(l:last, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
279 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
280 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
281 call assert_equal(l:current_windows + 1, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
282 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
283
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
284 " Fail :argedit but :argedit! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
285 func Test_argedit()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
286 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
287
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
288 args! first middle last
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
289 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
290 file first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
291 let l:first = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
292
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
293 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
294 file middle
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
295 let l:middle = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
296
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
297 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
298 file last
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
299 let l:last = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
300
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
301 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
302
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
303 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
304 call assert_fails("argedit first middle last", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
305 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
306
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
307 argedit! first middle last
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
308 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
309 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
310
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
311 " Fail :arglocal but :arglocal! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
312 func Test_arglocal()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
314
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
315 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
316 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
317 argglobal! other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
318 execute "buffer! " . l:current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
319
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
320 call assert_fails("arglocal other", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
321 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
322
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
323 arglocal! other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
324 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
325 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
326
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
327 " Fail :argglobal but :argglobal! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
328 func Test_argglobal()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
329 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
330
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
331 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
332 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
333
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
334 call assert_fails("argglobal other", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
335 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
336
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
337 argglobal! other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
338 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
339 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
340
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
341 " Fail :args but :args! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
342 func Test_args()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
343 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
344
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
345 let [l:first, _] = s:make_buffers_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
346 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
347
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
348 call assert_fails("args first middle last", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
349 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
350
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
351 args! first middle last
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
352 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
353 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
354
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
355 " Fail :bNext but :bNext! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
356 func Test_bNext()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
357 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
358
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
359 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
360 call assert_fails("bNext", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
361 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
362
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
363 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
364
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
365 bNext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
366 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
367 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
368
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
369 " Allow :badd because it doesn't actually change the current window's buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
370 func Test_badd()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
371 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
372
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
373 call s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
374 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
375
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
376 badd other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
377 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
378 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
379
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
380 " Allow :balt because it doesn't actually change the current window's buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
381 func Test_balt()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
382 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
383
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
384 call s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
385 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
386
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
387 balt other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
388 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
389 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
390
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
391 " Fail :bfirst but :bfirst! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
392 func Test_bfirst()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
393 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
394
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
395 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
396 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
397
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
398 call assert_fails("bfirst", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
399 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
400
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
401 bfirst!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
402 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
403 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
404
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
405 " Fail :blast but :blast! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
406 func Test_blast()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
407 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
408
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
409 let l:other = s:make_buffer_pairs(1)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
410 bfirst!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
411 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
412
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
413 call assert_fails("blast", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
414 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
415
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
416 blast!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
417 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
418 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
419
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
420 " Fail :bmodified but :bmodified! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
421 func Test_bmodified()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
422 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
423
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
424 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
425 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
426
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
427 execute "buffer! " . l:other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
428 set modified
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
429 execute "buffer! " . l:current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
430
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
431 call assert_fails("bmodified", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
432 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
433
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
434 bmodified!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
435 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
436 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
437
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
438 " Fail :bnext but :bnext! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
439 func Test_bnext()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
440 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
441
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
442 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
443 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
444
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
445 call assert_fails("bnext", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
446 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
447
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
448 bnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
449 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
450 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
451
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
452 " Fail :bprevious but :bprevious! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
453 func Test_bprevious()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
454 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
455
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
456 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
457 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
458
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
459 call assert_fails("bprevious", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
460 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
461
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
462 bprevious!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
463 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
464 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
465
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
466 " Fail :brewind but :brewind! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
467 func Test_brewind()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
468 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
469
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
470 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
471 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
472
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
473 call assert_fails("brewind", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
474 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
475
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
476 brewind!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
477 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
478 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
479
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
480 " Fail :browse edit but :browse edit! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
481 func Test_browse_edit_fail()
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
482 " A GUI dialog may stall the test.
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
483 CheckNotGui
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
484
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
485 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
486
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
487 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
488 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
489
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
490 call assert_fails("browse edit other", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
491 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
492
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
493 try
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
494 browse edit! other
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
495 call assert_equal(l:other, bufnr())
34554
495218030237 patch 9.1.0178: E1513 might be confusing
Christian Brabandt <cb@256bit.org>
parents: 34500
diff changeset
496 catch /^Vim\%((\a\+)\)\=:E338:/
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
497 " Ignore E338, which occurs if console Vim is built with +browse.
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
498 " Console Vim without +browse will treat this as a regular :edit.
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
499 endtry
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
500 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
501
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
502 " Allow :browse w because it doesn't change the buffer in the current file
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
503 func Test_browse_edit_pass()
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
504 " A GUI dialog may stall the test.
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
505 CheckNotGui
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
506
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
507 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
508
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
509 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
510 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
511
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
512 try
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
513 browse write other
34554
495218030237 patch 9.1.0178: E1513 might be confusing
Christian Brabandt <cb@256bit.org>
parents: 34500
diff changeset
514 catch /^Vim\%((\a\+)\)\=:E338:/
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
515 " Ignore E338, which occurs if console Vim is built with +browse.
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
516 " Console Vim without +browse will treat this as a regular :write.
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
517 endtry
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
518
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
519 call delete("other")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
520 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
521
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
522 " Call :bufdo and choose the next available 'nowinfixbuf' window.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
523 func Test_bufdo_choose_available_window()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
524 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
525
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
526 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
527
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
528 " Make a split window that is 'nowinfixbuf' but make it the second-to-last
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
529 " window so that :bufdo will first try the 'winfixbuf' window, pass over it,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
530 " and prefer the other 'nowinfixbuf' window, instead.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
531 "
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
532 " +-------------------+
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
533 " | 'nowinfixbuf' |
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
534 " +-------------------+
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
535 " | 'winfixbuf' | <-- Cursor is here
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
536 " +-------------------+
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
537 split
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
538 let l:nowinfixbuf_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
539 " Move to the 'winfixbuf' window now
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
540 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
541 let l:winfixbuf_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
542
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
543 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
544 let l:expected_windows = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
545
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
546 call assert_notequal(l:current, l:other)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
547
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
548 bufdo echo ''
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
549 call assert_equal(l:nowinfixbuf_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
550 call assert_notequal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
551 call assert_equal(l:expected_windows, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
552 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
553
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
554 " Call :bufdo and create a new split window if all available windows are 'winfixbuf'.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
555 func Test_bufdo_make_new_window()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
556 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
557
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
558 let [l:first, l:last] = s:make_buffers_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
559 execute "buffer! " . l:first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
560 let l:current = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
561 let l:current_windows = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
562
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
563 bufdo echo ''
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
564 call assert_notequal(l:current, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
565 call assert_equal(l:last, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
566 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
567 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
568 call assert_equal(l:current_windows + 1, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
569 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
570
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
571 " Fail :buffer but :buffer! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
572 func Test_buffer()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
573 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
574
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
575 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
576 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
577
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
578 call assert_fails("buffer " . l:other, "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
579 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
580
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
581 execute "buffer! " . l:other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
582 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
583 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
584
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
585 " Allow :buffer on a 'winfixbuf' window if there is no change in buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
586 func Test_buffer_same_buffer()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
587 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
588
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
589 call s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
590 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
591
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
592 execute "buffer " . l:current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
593 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
594
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
595 execute "buffer! " . l:current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
596 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
597 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
598
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
599 " Allow :cNext but the 'nowinfixbuf' window is selected, instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
600 func Test_cNext()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
601 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
602 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
603
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
604 let [l:first_window, l:winfix_window, l:quickfix_window] = s:make_quickfix_windows()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
605
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
606 " The call to `:cNext` succeeds but it selects the window with 'nowinfixbuf' instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
607 call s:set_quickfix_by_buffer(winbufnr(l:winfix_window))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
608
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
609 " Make sure the previous window has 'winfixbuf' so we can test that our
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
610 " "skip 'winfixbuf' window" logic works.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
611 call win_gotoid(l:winfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
612 call win_gotoid(l:quickfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
613
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
614 cNext
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
615 call assert_equal(l:first_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
616 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
617
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
618 " Allow :cNfile but the 'nowinfixbuf' window is selected, instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
619 func Test_cNfile()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
620 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
621 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
622
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
623 let [l:first_window, l:winfix_window, l:quickfix_window] = s:make_quickfix_windows()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
624
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
625 " The call to `:cNfile` succeeds but it selects the window with 'nowinfixbuf' instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
626 call s:set_quickfix_by_buffer(winbufnr(l:winfix_window))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
627 cnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
628
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
629 " Make sure the previous window has 'winfixbuf' so we can test that our
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
630 " "skip 'winfixbuf' window" logic works.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
631 call win_gotoid(l:winfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
632 call win_gotoid(l:quickfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
633
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
634 cNfile
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
635 call assert_equal(l:first_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
636 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
637
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
638 " Allow :caddexpr because it doesn't change the current buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
639 func Test_caddexpr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
640 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
641 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
642
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
643 let l:file_path = tempname()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
644 call writefile(["Error - bad-thing-found"], l:file_path)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
645 execute "edit " . l:file_path
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
646 let l:file_buffer = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
647 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
648
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
649 edit first.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
650 call append(0, ["some-search-term bad-thing-found"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
651
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
652 edit! other.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
653
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
654 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
655
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
656 execute "buffer! " . l:file_buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
657
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
658 execute 'caddexpr expand("%") .. ":" .. line(".") .. ":" .. getline(".")'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
659 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
660
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
661 call delete(l:file_path)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
662 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
663
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
664 " Fail :cbuffer but :cbuffer! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
665 func Test_cbuffer()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
666 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
667 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
668
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
669 let l:file_path = tempname()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
670 call writefile(["first.unittest:1:Error - bad-thing-found"], l:file_path)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
671 execute "edit " . l:file_path
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
672 let l:file_buffer = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
673 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
674
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
675 edit first.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
676 call append(0, ["some-search-term bad-thing-found"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
677
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
678 edit! other.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
679
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
680 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
681
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
682 execute "buffer! " . l:file_buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
683
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
684 call assert_fails("cbuffer " . l:file_buffer)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
685 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
686
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
687 execute "cbuffer! " . l:file_buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
688 call assert_equal("first.unittest", expand("%:t"))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
689
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
690 call delete(l:file_path)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
691 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
692
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
693 " Allow :cc but the 'nowinfixbuf' window is selected, instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
694 func Test_cc()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
695 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
696 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
697
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
698 let [l:first_window, l:winfix_window, l:quickfix_window] = s:make_quickfix_windows()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
699
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
700 " The call to `:cnext` succeeds but it selects the window with 'nowinfixbuf' instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
701 call s:set_quickfix_by_buffer(winbufnr(l:winfix_window))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
702
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
703 " Make sure the previous window has 'winfixbuf' so we can test that our
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
704 " "skip 'winfixbuf' window" logic works.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
705 call win_gotoid(l:winfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
706 call win_gotoid(l:quickfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
707 " Go up one line in the quickfix window to an quickfix entry that doesn't
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
708 " point to a winfixbuf buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
709 normal k
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
710 " Attempt to make the previous window, winfixbuf buffer, to go to the
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
711 " non-winfixbuf quickfix entry
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
712 .cc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
713
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
714 " Confirm that :.cc did not change the winfixbuf-enabled window
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
715 call assert_equal(l:first_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
716 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
717
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
718 " Call :cdo and choose the next available 'nowinfixbuf' window.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
719 func Test_cdo_choose_available_window()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
720 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
721 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
722
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
723 let [l:current, l:last] = s:make_simple_quickfix()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
724 execute "buffer! " . l:current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
725
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
726 " Make a split window that is 'nowinfixbuf' but make it the second-to-last
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
727 " window so that :cdo will first try the 'winfixbuf' window, pass over it,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
728 " and prefer the other 'nowinfixbuf' window, instead.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
729 "
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
730 " +-------------------+
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
731 " | 'nowinfixbuf' |
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
732 " +-------------------+
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
733 " | 'winfixbuf' | <-- Cursor is here
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
734 " +-------------------+
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
735 split
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
736 let l:nowinfixbuf_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
737 " Move to the 'winfixbuf' window now
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
738 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
739 let l:winfixbuf_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
740 let l:expected_windows = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
741
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
742 cdo echo ''
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
743
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
744 call assert_equal(l:nowinfixbuf_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
745 call assert_equal(l:last, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
746 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
747 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
748 call assert_equal(l:expected_windows, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
749 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
750
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
751 " Call :cdo and create a new split window if all available windows are 'winfixbuf'.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
752 func Test_cdo_make_new_window()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
753 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
754 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
755
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
756 let [l:current_buffer, l:last] = s:make_simple_quickfix()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
757 execute "buffer! " . l:current_buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
758
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
759 let l:current_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
760 let l:current_windows = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
761
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
762 cdo echo ''
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
763 call assert_notequal(l:current_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
764 call assert_equal(l:last, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
765 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
766 call assert_equal(l:current_buffer, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
767 call assert_equal(l:current_windows + 1, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
768 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
769
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
770 " Fail :cexpr but :cexpr! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
771 func Test_cexpr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
772 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
773 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
774
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
775 let l:file = tempname()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
776 let l:entry = '["' . l:file . ':1:bar"]'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
777 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
778
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
779 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
780
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
781 call assert_fails("cexpr " . l:entry)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
782 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
783
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
784 execute "cexpr! " . l:entry
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
785 call assert_equal(fnamemodify(l:file, ":t"), expand("%:t"))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
786 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
787
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
788 " Call :cfdo and choose the next available 'nowinfixbuf' window.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
789 func Test_cfdo_choose_available_window()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
790 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
791 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
792
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
793 let [l:current, l:last] = s:make_simple_quickfix()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
794 execute "buffer! " . l:current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
795
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
796 " Make a split window that is 'nowinfixbuf' but make it the second-to-last
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
797 " window so that :cfdo will first try the 'winfixbuf' window, pass over it,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
798 " and prefer the other 'nowinfixbuf' window, instead.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
799 "
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
800 " +-------------------+
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
801 " | 'nowinfixbuf' |
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
802 " +-------------------+
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
803 " | 'winfixbuf' | <-- Cursor is here
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
804 " +-------------------+
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
805 split
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
806 let l:nowinfixbuf_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
807 " Move to the 'winfixbuf' window now
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
808 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
809 let l:winfixbuf_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
810 let l:expected_windows = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
811
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
812 cfdo echo ''
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
813
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
814 call assert_equal(l:nowinfixbuf_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
815 call assert_equal(l:last, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
816 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
817 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
818 call assert_equal(l:expected_windows, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
819 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
820
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
821 " Call :cfdo and create a new split window if all available windows are 'winfixbuf'.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
822 func Test_cfdo_make_new_window()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
823 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
824 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
825
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
826 let [l:current_buffer, l:last] = s:make_simple_quickfix()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
827 execute "buffer! " . l:current_buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
828
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
829 let l:current_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
830 let l:current_windows = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
831
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
832 cfdo echo ''
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
833 call assert_notequal(l:current_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
834 call assert_equal(l:last, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
835 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
836 call assert_equal(l:current_buffer, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
837 call assert_equal(l:current_windows + 1, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
838 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
839
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
840 " Fail :cfile but :cfile! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
841 func Test_cfile()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
842 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
843 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
844
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
845 edit first.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
846 call append(0, ["some-search-term bad-thing-found"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
847 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
848 let l:first = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
849
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
850 edit! second.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
851 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
852 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
853
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
854 let l:file = tempname()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
855 call writefile(["first.unittest:1:Error - bad-thing-found was detected"], l:file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
856
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
857 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
858
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
859 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
860
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
861 call assert_fails(":cfile " . l:file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
862 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
863
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
864 execute ":cfile! " . l:file
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
865 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
866
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
867 call delete(l:file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
868 call delete("first.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
869 call delete("second.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
870 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
871
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
872 " Allow :cfirst but the 'nowinfixbuf' window is selected, instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
873 func Test_cfirst()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
874 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
875 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
876
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
877 let [l:first_window, l:winfix_window, l:quickfix_window] = s:make_quickfix_windows()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
878
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
879 " The call to `:cfirst` succeeds but it selects the window with 'nowinfixbuf' instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
880 call s:set_quickfix_by_buffer(winbufnr(l:winfix_window))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
881
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
882 " Make sure the previous window has 'winfixbuf' so we can test that our
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
883 " "skip 'winfixbuf' window" logic works.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
884 call win_gotoid(l:winfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
885 call win_gotoid(l:quickfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
886
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
887 cfirst
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
888 call assert_equal(l:first_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
889 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
890
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
891 " Allow :clast but the 'nowinfixbuf' window is selected, instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
892 func Test_clast()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
893 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
894 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
895
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
896 let [l:first_window, l:winfix_window, l:quickfix_window] = s:make_quickfix_windows()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
897
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
898 " The call to `:clast` succeeds but it selects the window with 'nowinfixbuf' instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
899 call s:set_quickfix_by_buffer(winbufnr(l:winfix_window))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
900
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
901 " Make sure the previous window has 'winfixbuf' so we can test that our
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
902 " "skip 'winfixbuf' window" logic works.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
903 call win_gotoid(l:winfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
904 call win_gotoid(l:quickfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
905
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
906 clast
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
907 call assert_equal(l:first_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
908 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
909
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
910 " Allow :cnext but the 'nowinfixbuf' window is selected, instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
911 " Make sure no new windows are created and previous windows are reused
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
912 func Test_cnext()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
913 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
914 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
915
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
916 let [l:first_window, l:winfix_window, l:quickfix_window] = s:make_quickfix_windows()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
917 let l:expected = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
918
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
919 " The call to `:cnext` succeeds but it selects the window with 'nowinfixbuf' instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
920 call s:set_quickfix_by_buffer(winbufnr(l:winfix_window))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
921
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
922 cnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
923 call assert_equal(l:expected, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
924
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
925 " Make sure the previous window has 'winfixbuf' so we can test that our
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
926 " "skip 'winfixbuf' window" logic works.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
927 call win_gotoid(l:winfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
928 call win_gotoid(l:quickfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
929
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
930 cnext
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
931 call assert_equal(l:first_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
932 call assert_equal(l:expected, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
933 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
934
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
935 " Make sure :cnext creates a split window if no previous window exists
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
936 func Test_cnext_no_previous_window()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
937 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
938 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
939
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
940 let [l:current, _] = s:make_simple_quickfix()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
941 execute "buffer! " . l:current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
942
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
943 let l:expected = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
944
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
945 " Open the quickfix in a separate split and go to it
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
946 copen
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
947
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
948 call assert_equal(l:expected + 1, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
949 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
950
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
951 " Allow :cnext and create a 'nowinfixbuf' window if none exists
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
952 func Test_cnext_make_new_window()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
953 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
954 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
955
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
956 let [l:current, _] = s:make_simple_quickfix()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
957 let l:current = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
958
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
959 cfirst!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
960
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
961 let l:windows = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
962 let l:expected = l:windows + 1 " We're about to create a new split window
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
963
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
964 cnext
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
965 call assert_equal(l:expected, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
966
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
967 cnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
968 call assert_equal(l:expected, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
969 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
970
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
971 " Allow :cprevious but the 'nowinfixbuf' window is selected, instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
972 func Test_cprevious()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
973 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
974 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
975
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
976 let [l:first_window, l:winfix_window, l:quickfix_window] = s:make_quickfix_windows()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
977
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
978 " The call to `:cprevious` succeeds but it selects the window with 'nowinfixbuf' instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
979 call s:set_quickfix_by_buffer(winbufnr(l:winfix_window))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
980
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
981 " Make sure the previous window has 'winfixbuf' so we can test that our
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
982 " "skip 'winfixbuf' window" logic works.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
983 call win_gotoid(l:winfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
984 call win_gotoid(l:quickfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
985
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
986 cprevious
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
987 call assert_equal(l:first_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
988 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
989
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
990 " Allow :cnfile but the 'nowinfixbuf' window is selected, instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
991 func Test_cnfile()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
992 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
993 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
994
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
995 let [l:first_window, l:winfix_window, l:quickfix_window] = s:make_quickfix_windows()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
996
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
997 " The call to `:cnfile` succeeds but it selects the window with 'nowinfixbuf' instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
998 call s:set_quickfix_by_buffer(winbufnr(l:winfix_window))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
999 cnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1000
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1001 " Make sure the previous window has 'winfixbuf' so we can test that our
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1002 " "skip 'winfixbuf' window" logic works.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1003 call win_gotoid(l:winfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1004 call win_gotoid(l:quickfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1005
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1006 cnfile
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1007 call assert_equal(l:first_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1008 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1009
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1010 " Allow :cpfile but the 'nowinfixbuf' window is selected, instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1011 func Test_cpfile()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1012 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1013 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1014
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1015 let [l:first_window, l:winfix_window, l:quickfix_window] = s:make_quickfix_windows()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1016
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1017 " The call to `:cpfile` succeeds but it selects the window with 'nowinfixbuf' instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1018 call s:set_quickfix_by_buffer(winbufnr(l:winfix_window))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1019 cnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1020
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1021 " Make sure the previous window has 'winfixbuf' so we can test that our
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1022 " "skip 'winfixbuf' window" logic works.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1023 call win_gotoid(l:winfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1024 call win_gotoid(l:quickfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1025
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1026 cpfile
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1027 call assert_equal(l:first_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1028 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1029
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1030 " Allow :crewind but the 'nowinfixbuf' window is selected, instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1031 func Test_crewind()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1032 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1033 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1034
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1035 let [l:first_window, l:winfix_window, l:quickfix_window] = s:make_quickfix_windows()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1036
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1037 " The call to `:crewind` succeeds but it selects the window with 'nowinfixbuf' instead
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1038 call s:set_quickfix_by_buffer(winbufnr(l:winfix_window))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1039 cnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1040
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1041 " Make sure the previous window has 'winfixbuf' so we can test that our
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1042 " "skip 'winfixbuf' window" logic works.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1043 call win_gotoid(l:winfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1044 call win_gotoid(l:quickfix_window)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1045
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1046 crewind
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1047 call assert_equal(l:first_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1048 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1049
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1050 " Allow <C-w>f because it opens in a new split
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1051 func Test_ctrl_w_f()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1052 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1053
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1054 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1055 let l:file_name = tempname()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1056 call writefile([], l:file_name)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1057 let l:file_buffer = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1058
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1059 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1060 file other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1061 let l:other_buffer = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1062
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1063 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1064
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1065 call setline(1, l:file_name)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1066 let l:current_windows = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1067 execute "normal \<C-w>f"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1068
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1069 call assert_equal(l:current_windows + 1, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1070
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1071 call delete(l:file_name)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1072 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1073
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1074 " Fail :djump but :djump! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1075 func Test_djump()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1076 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1077
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1078 let l:include_file = tempname() . ".h"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1079 call writefile(["min(1, 12);",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1080 \ '#include "' . l:include_file . '"'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1081 \ ],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1082 \ "main.c")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1083 call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1084 edit main.c
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1085
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1086 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1087
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1088 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1089
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1090 call assert_fails("djump 1 /min/", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1091 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1092
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1093 djump! 1 /min/
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1094 call assert_notequal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1095
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1096 call delete("main.c")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1097 call delete(l:include_file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1098 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1099
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1100 " Fail :drop but :drop! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1101 func Test_drop()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1102 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1103
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1104 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1105 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1106
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1107 call assert_fails("drop other", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1108 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1109
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1110 drop! other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1111 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1112 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1113
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1114 " Fail :edit but :edit! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1115 func Test_edit()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1116 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1117
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1118 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1119 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1120
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1121 call assert_fails("edit other", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1122 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1123
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1124 edit! other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1125 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1126 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1127
34647
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1128 " Fail :e when selecting a buffer from a relative path if in a different folder
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1129 "
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1130 " In this tests there's 2 buffers
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1131 "
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1132 " foo - lives on disk, in some folder. e.g. /tmp/foo
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1133 " foo - an in-memory buffer that has not been saved to disk. If saved, it
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1134 " would live in a different folder, /other/foo.
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1135 "
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1136 " The 'winfixbuf' is looking at the in-memory buffer and trying to switch to
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1137 " the buffer on-disk (and fails, because it's a different buffer)
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1138 func Test_edit_different_buffer_on_disk_and_relative_path_to_disk()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1139 call s:reset_all_buffers()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1140
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1141 let l:file_on_disk = tempname()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1142 let l:directory_on_disk1 = fnamemodify(l:file_on_disk, ":p:h")
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1143 let l:name = fnamemodify(l:file_on_disk, ":t")
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1144 execute "edit " . l:file_on_disk
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1145 write!
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1146
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1147 let l:directory_on_disk2 = l:directory_on_disk1 . "_something_else"
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1148
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1149 if !isdirectory(l:directory_on_disk2)
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1150 call mkdir(l:directory_on_disk2)
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1151 endif
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1152
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1153 execute "cd " . l:directory_on_disk2
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1154 execute "edit " l:name
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1155
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1156 let l:current = bufnr()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1157
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1158 call assert_equal(l:current, bufnr())
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1159 set winfixbuf
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1160 call assert_fails("edit " . l:file_on_disk, "E1513:")
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1161 call assert_equal(l:current, bufnr())
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1162
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1163 call delete(l:directory_on_disk1)
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1164 call delete(l:directory_on_disk2)
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1165 endfunc
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1166
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1167 " Fail :e when selecting a buffer from a relative path if in a different folder
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1168 "
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1169 " In this tests there's 2 buffers
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1170 "
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1171 " foo - lives on disk, in some folder. e.g. /tmp/foo
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1172 " foo - an in-memory buffer that has not been saved to disk. If saved, it
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1173 " would live in a different folder, /other/foo.
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1174 "
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1175 " The 'winfixbuf' is looking at the on-disk buffer and trying to switch to
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1176 " the in-memory buffer (and fails, because it's a different buffer)
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1177 func Test_edit_different_buffer_on_disk_and_relative_path_to_memory()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1178 call s:reset_all_buffers()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1179
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1180 let l:file_on_disk = tempname()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1181 let l:directory_on_disk1 = fnamemodify(l:file_on_disk, ":p:h")
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1182 let l:name = fnamemodify(l:file_on_disk, ":t")
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1183 execute "edit " . l:file_on_disk
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1184 write!
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1185
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1186 let l:directory_on_disk2 = l:directory_on_disk1 . "_something_else"
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1187
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1188 if !isdirectory(l:directory_on_disk2)
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1189 call mkdir(l:directory_on_disk2)
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1190 endif
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1191
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1192 execute "cd " . l:directory_on_disk2
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1193 execute "edit " l:name
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1194 execute "cd " . l:directory_on_disk1
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1195 execute "edit " l:file_on_disk
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1196 execute "cd " . l:directory_on_disk2
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1197
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1198 let l:current = bufnr()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1199
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1200 call assert_equal(l:current, bufnr())
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1201 set winfixbuf
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1202 call assert_fails("edit " . l:name, "E1513:")
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1203 call assert_equal(l:current, bufnr())
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1204
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1205 call delete(l:directory_on_disk1)
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1206 call delete(l:directory_on_disk2)
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1207 endfunc
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1208
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1209 " Fail to call `:e first` if called from a starting, in-memory buffer
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1210 func Test_edit_first_buffer()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1211 call s:reset_all_buffers()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1212
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1213 set winfixbuf
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1214 let l:current = bufnr()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1215
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1216 call assert_fails("edit first", "E1513:")
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1217 call assert_equal(l:current, bufnr())
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1218
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1219 edit! first
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1220 call assert_equal(l:current, bufnr())
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1221 edit! somewhere_else
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1222 call assert_notequal(l:current, bufnr())
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1223 endfunc
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1224
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1225 " Allow reloading a buffer using :e
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1226 func Test_edit_no_arguments()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1227 call s:reset_all_buffers()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1228
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1229 let l:current = bufnr()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1230 file some_buffer
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1231
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1232 call assert_equal(l:current, bufnr())
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1233 set winfixbuf
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1234 edit
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1235 call assert_equal(l:current, bufnr())
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1236 endfunc
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1237
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1238 " Allow :e selecting the current buffer
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1239 func Test_edit_same_buffer_in_memory()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1240 call s:reset_all_buffers()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1241
34656
3b29a2cdbf74 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf
Christian Brabandt <cb@256bit.org>
parents: 34647
diff changeset
1242 let current = bufnr()
34647
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1243 file same_buffer
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1244
34656
3b29a2cdbf74 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf
Christian Brabandt <cb@256bit.org>
parents: 34647
diff changeset
1245 call assert_equal(current, bufnr())
34647
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1246 set winfixbuf
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1247 edit same_buffer
34656
3b29a2cdbf74 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf
Christian Brabandt <cb@256bit.org>
parents: 34647
diff changeset
1248 call assert_equal(current, bufnr())
3b29a2cdbf74 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf
Christian Brabandt <cb@256bit.org>
parents: 34647
diff changeset
1249 set nowinfixbuf
34647
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1250 endfunc
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1251
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1252 " Allow :e selecting the current buffer as a full path
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1253 func Test_edit_same_buffer_on_disk_absolute_path()
34656
3b29a2cdbf74 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf
Christian Brabandt <cb@256bit.org>
parents: 34647
diff changeset
1254 " This fails on CI (Windows builds), why?
3b29a2cdbf74 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf
Christian Brabandt <cb@256bit.org>
parents: 34647
diff changeset
1255 CheckNotMSWindows
34647
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1256 call s:reset_all_buffers()
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1257
34656
3b29a2cdbf74 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf
Christian Brabandt <cb@256bit.org>
parents: 34647
diff changeset
1258 let file = tempname()
3b29a2cdbf74 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf
Christian Brabandt <cb@256bit.org>
parents: 34647
diff changeset
1259 let current = bufnr()
3b29a2cdbf74 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf
Christian Brabandt <cb@256bit.org>
parents: 34647
diff changeset
1260 execute "edit " . file
34647
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1261 write!
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1262
34656
3b29a2cdbf74 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf
Christian Brabandt <cb@256bit.org>
parents: 34647
diff changeset
1263 call assert_equal(current, bufnr())
34647
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1264 set winfixbuf
34656
3b29a2cdbf74 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf
Christian Brabandt <cb@256bit.org>
parents: 34647
diff changeset
1265 execute "edit " file
3b29a2cdbf74 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf
Christian Brabandt <cb@256bit.org>
parents: 34647
diff changeset
1266 call assert_equal(current, bufnr())
3b29a2cdbf74 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf
Christian Brabandt <cb@256bit.org>
parents: 34647
diff changeset
1267
3b29a2cdbf74 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf
Christian Brabandt <cb@256bit.org>
parents: 34647
diff changeset
1268 call delete(file)
3b29a2cdbf74 patch 9.1.0212: CI: MS-Windows fails in test_winfixbuf
Christian Brabandt <cb@256bit.org>
parents: 34647
diff changeset
1269 set nowinfixbuf
34647
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1270 endfunc
6b2efa2b2386 patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Christian Brabandt <cb@256bit.org>
parents: 34554
diff changeset
1271
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1272 " Fail :enew but :enew! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1273 func Test_enew()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1274 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1275
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1276 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1277 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1278
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1279 call assert_fails("enew", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1280 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1281
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1282 enew!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1283 call assert_notequal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1284 call assert_notequal(3, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1285 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1286
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1287 " Fail :ex but :ex! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1288 func Test_ex()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1289 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1290
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1291 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1292 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1293
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1294 call assert_fails("ex other", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1295 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1296
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1297 ex! other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1298 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1299 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1300
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1301 " Fail :find but :find! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1302 func Test_find()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1303 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1304
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1305 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1306 let l:file = tempname()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1307 call writefile([], l:file)
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
1308 let l:file = fnamemodify(l:file, ':p') " In case it's Windows 8.3-style.
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1309 let l:directory = fnamemodify(l:file, ":p:h")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1310 let l:name = fnamemodify(l:file, ":p:t")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1311
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1312 let l:original_path = &path
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1313 execute "set path=" . l:directory
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1314
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1315 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1316
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1317 call assert_fails("execute 'find " . l:name . "'", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1318 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1319
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1320 execute "find! " . l:name
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1321 call assert_equal(l:file, expand("%:p"))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1322
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1323 execute "set path=" . l:original_path
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1324 call delete(l:file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1325 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1326
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1327 " Fail :first but :first! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1328 func Test_first()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1329 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1330
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1331 let [l:first, _] = s:make_args_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1332 next!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1333
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1334 call assert_fails("first", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1335 call assert_notequal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1336
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1337 first!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1338 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1339 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1340
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1341 " Fail :grep but :grep! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1342 func Test_grep()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1343 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1344 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1345
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1346 edit first.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1347 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1348 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1349 let l:first = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1350
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1351 edit current.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1352 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1353 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1354 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1355
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1356 edit! last.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1357 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1358 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1359 let l:last = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1360
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1361 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1362
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1363 buffer! current.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1364
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1365 call assert_fails("silent! grep some-search-term *.unittest", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1366 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1367 execute "edit! " . l:first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1368
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1369 silent! grep! some-search-term *.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1370 call assert_notequal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1371
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1372 call delete("first.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1373 call delete("current.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1374 call delete("last.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1375 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1376
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1377 " Fail :ijump but :ijump! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1378 func Test_ijump()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1379 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1380
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1381 let l:include_file = tempname() . ".h"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1382 call writefile([
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1383 \ '#include "' . l:include_file . '"'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1384 \ ],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1385 \ "main.c")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1386 call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1387 edit main.c
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1388
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1389 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1390
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1391 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1392
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1393 set define=^\\s*#\\s*define
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1394 set include=^\\s*#\\s*include
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1395 set path=.,/usr/include,,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1396
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1397 call assert_fails("ijump /min/", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1398 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1399
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1400 set nowinfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1401
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1402 ijump! /min/
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1403 call assert_notequal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1404
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1405 set define&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1406 set include&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1407 set path&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1408 call delete("main.c")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1409 call delete(l:include_file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1410 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1411
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1412 " Fail :lNext but :lNext! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1413 func Test_lNext()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1414 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1415 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1416
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1417 let [l:first, l:middle, _] = s:make_simple_location_list()
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1418 call assert_equal(1, getloclist(0, #{idx: 0}).idx)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1419
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1420 lnext!
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1421 call assert_equal(2, getloclist(0, #{idx: 0}).idx)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1422 call assert_equal(l:middle, bufnr())
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1423
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1424 call assert_fails("lNext", "E1513:")
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1425 " Ensure the entry didn't change.
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1426 call assert_equal(2, getloclist(0, #{idx: 0}).idx)
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1427 call assert_equal(l:middle, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1428
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1429 lnext!
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1430 call assert_equal(3, getloclist(0, #{idx: 0}).idx)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1431 call assert_equal(l:middle, bufnr())
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1432
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1433 lNext!
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1434 call assert_equal(2, getloclist(0, #{idx: 0}).idx)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1435 call assert_equal(l:middle, bufnr())
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1436
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1437 lNext!
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1438 call assert_equal(1, getloclist(0, #{idx: 0}).idx)
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1439 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1440 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1441
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1442 " Fail :lNfile but :lNfile! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1443 func Test_lNfile()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1444 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1445 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1446
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1447 let [l:first, l:current, _] = s:make_simple_location_list()
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1448 call assert_equal(1, getloclist(0, #{idx: 0}).idx)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1449
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1450 lnext!
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1451 call assert_equal(2, getloclist(0, #{idx: 0}).idx)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1452 call assert_equal(l:current, bufnr())
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1453
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1454 call assert_fails("lNfile", "E1513:")
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1455 " Ensure the entry didn't change.
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1456 call assert_equal(2, getloclist(0, #{idx: 0}).idx)
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1457 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1458
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1459 lnext!
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1460 call assert_equal(3, getloclist(0, #{idx: 0}).idx)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1461 call assert_equal(l:current, bufnr())
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1462
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1463 lNfile!
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1464 call assert_equal(1, getloclist(0, #{idx: 0}).idx)
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1465 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1466 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1467
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1468 " Allow :laddexpr because it doesn't change the current buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1469 func Test_laddexpr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1470 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1471 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1472
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1473 let l:file_path = tempname()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1474 call writefile(["Error - bad-thing-found"], l:file_path)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1475 execute "edit " . l:file_path
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1476 let l:file_buffer = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1477 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1478
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1479 edit first.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1480 call append(0, ["some-search-term bad-thing-found"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1481
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1482 edit! other.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1483
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1484 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1485
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1486 execute "buffer! " . l:file_buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1487
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1488 execute 'laddexpr expand("%") .. ":" .. line(".") .. ":" .. getline(".")'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1489 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1490
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1491 call delete(l:file_path)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1492 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1493
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1494 " Fail :last but :last! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1495 func Test_last()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1496 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1497
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1498 let [_, l:last] = s:make_args_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1499 next!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1500
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1501 call assert_fails("last", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1502 call assert_notequal(l:last, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1503
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1504 last!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1505 call assert_equal(l:last, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1506 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1507
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1508 " Fail :lbuffer but :lbuffer! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1509 func Test_lbuffer()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1510 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1511 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1512
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1513 let l:file_path = tempname()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1514 call writefile(["first.unittest:1:Error - bad-thing-found"], l:file_path)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1515 execute "edit " . l:file_path
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1516 let l:file_buffer = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1517 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1518
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1519 edit first.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1520 call append(0, ["some-search-term bad-thing-found"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1521
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1522 edit! other.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1523
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1524 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1525
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1526 execute "buffer! " . l:file_buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1527
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1528 call assert_fails("lbuffer " . l:file_buffer)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1529 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1530
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1531 execute "lbuffer! " . l:file_buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1532 call assert_equal("first.unittest", expand("%:t"))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1533
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1534 call delete(l:file_path)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1535 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1536
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1537 " Fail :ldo but :ldo! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1538 func Test_ldo()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1539 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1540 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1541
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1542 let [l:first, l:middle, l:last] = s:make_simple_location_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1543 lnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1544
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1545 call assert_fails('execute "ldo buffer ' . l:first . '"', "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1546 call assert_equal(l:middle, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1547 execute "ldo! buffer " . l:first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1548 call assert_notequal(l:last, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1549 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1550
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1551 " Fail :lfdo but :lfdo! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1552 func Test_lexpr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1553 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1554 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1555
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1556 let l:file = tempname()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1557 let l:entry = '["' . l:file . ':1:bar"]'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1558 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1559
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1560 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1561
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1562 call assert_fails("lexpr " . l:entry)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1563 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1564
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1565 execute "lexpr! " . l:entry
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1566 call assert_equal(fnamemodify(l:file, ":t"), expand("%:t"))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1567 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1568
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1569 " Fail :lfdo but :lfdo! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1570 func Test_lfdo()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1571 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1572 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1573
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1574 let [l:first, l:middle, l:last] = s:make_simple_location_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1575 lnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1576
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1577 call assert_fails('execute "lfdo buffer ' . l:first . '"', "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1578 call assert_equal(l:middle, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1579 execute "lfdo! buffer " . l:first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1580 call assert_notequal(l:last, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1581 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1582
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1583 " Fail :lfile but :lfile! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1584 func Test_lfile()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1585 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1586 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1587
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1588 edit first.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1589 call append(0, ["some-search-term bad-thing-found"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1590 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1591 let l:first = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1592
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1593 edit! second.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1594 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1595 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1596
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1597 let l:file = tempname()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1598 call writefile(["first.unittest:1:Error - bad-thing-found was detected"], l:file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1599
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1600 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1601
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1602 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1603
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1604 call assert_fails(":lfile " . l:file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1605 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1606
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1607 execute ":lfile! " . l:file
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1608 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1609
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1610 call delete(l:file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1611 call delete("first.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1612 call delete("second.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1613 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1614
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1615 " Fail :ll but :ll! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1616 func Test_ll()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1617 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1618 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1619
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1620 let [l:first, l:middle, l:last] = s:make_simple_location_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1621 lopen
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1622 lfirst!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1623 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1624 normal j
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1625
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1626 call assert_fails(".ll", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1627 execute "normal \<C-w>k"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1628 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1629 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1630 .ll!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1631 execute "normal \<C-w>k"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1632 call assert_equal(l:middle, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1633 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1634
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1635 " Fail :llast but :llast! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1636 func Test_llast()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1637 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1638 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1639
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1640 let [l:first, _, l:last] = s:make_simple_location_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1641 lfirst!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1642
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1643 call assert_fails("llast", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1644 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1645
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1646 llast!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1647 call assert_equal(l:last, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1648 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1649
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1650 " Fail :lnext but :lnext! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1651 func Test_lnext()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1652 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1653 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1654
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1655 let [l:first, l:middle, l:last] = s:make_simple_location_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1656 ll!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1657
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1658 call assert_fails("lnext", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1659 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1660
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1661 lnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1662 call assert_equal(l:middle, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1663 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1664
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1665 " Fail :lnfile but :lnfile! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1666 func Test_lnfile()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1667 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1668 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1669
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1670 let [_, l:current, l:last] = s:make_simple_location_list()
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1671 call assert_equal(1, getloclist(0, #{idx: 0}).idx)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1672
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1673 lnext!
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1674 call assert_equal(2, getloclist(0, #{idx: 0}).idx)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1675 call assert_equal(l:current, bufnr())
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1676
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1677 call assert_fails("lnfile", "E1513:")
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
1678 " Ensure the entry didn't change.
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1679 call assert_equal(2, getloclist(0, #{idx: 0}).idx)
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1680 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1681
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1682 lnfile!
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1683 call assert_equal(4, getloclist(0, #{idx: 0}).idx)
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1684 call assert_equal(l:last, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1685 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1686
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1687 " Fail :lpfile but :lpfile! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1688 func Test_lpfile()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1689 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1690 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1691
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1692 let [l:first, l:current, _] = s:make_simple_location_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1693 lnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1694
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1695 call assert_fails("lpfile", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1696 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1697
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1698 lnext! " Reset for the next test call
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1699
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1700 lpfile!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1701 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1702 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1703
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1704 " Fail :lprevious but :lprevious! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1705 func Test_lprevious()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1706 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1707 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1708
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1709 let [l:first, l:middle, _] = s:make_simple_location_list()
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1710 call assert_equal(1, getloclist(0, #{idx: 0}).idx)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1711
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1712 lnext!
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1713 call assert_equal(2, getloclist(0, #{idx: 0}).idx)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1714 call assert_equal(l:middle, bufnr())
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1715
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1716 call assert_fails("lprevious", "E1513:")
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1717 " Ensure the entry didn't change.
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1718 call assert_equal(2, getloclist(0, #{idx: 0}).idx)
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1719 call assert_equal(l:middle, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1720
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1721 lprevious!
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
1722 call assert_equal(1, getloclist(0, #{idx: 0}).idx)
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1723 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1724 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1725
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1726 " Fail :lrewind but :lrewind! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1727 func Test_lrewind()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1728 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1729 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1730
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1731 let [l:first, l:middle, _] = s:make_simple_location_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1732 lnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1733
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1734 call assert_fails("lrewind", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1735 call assert_equal(l:middle, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1736
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1737 lrewind!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1738 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1739 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1740
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1741 " Fail :ltag but :ltag! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1742 func Test_ltag()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1743 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1744
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1745 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1746 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1747 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1748 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1749 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1750 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1751 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1752 call writefile(["one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1753 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1754 execute "normal \<C-]>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1755
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1756 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1757
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1758 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1759
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1760 call assert_fails("ltag one", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1761
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1762 ltag! one
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1763
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1764 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1765 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1766 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1767 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1768 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1769
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1770 " Fail vim.command if we try to change buffers while 'winfixbuf' is set
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1771 func Test_lua_command()
34479
2cf84e8dc58b patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property
Christian Brabandt <cb@256bit.org>
parents: 34470
diff changeset
1772 CheckFeature lua
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1773 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1774
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1775 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1776 file first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1777 let l:previous = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1778
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1779 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1780 file second
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1781 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1782
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1783 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1784
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1785 call assert_fails('lua vim.command("buffer " .. ' . l:previous . ')')
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1786 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1787
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1788 execute 'lua vim.command("buffer! " .. ' . l:previous . ')'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1789 call assert_equal(l:previous, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1790 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1791
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1792 " Fail :lvimgrep but :lvimgrep! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1793 func Test_lvimgrep()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1794 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1795 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1796
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1797 edit first.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1798 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1799 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1800
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1801 edit winfix.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1802 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1803 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1804 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1805
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1806 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1807
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1808 edit! last.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1809 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1810 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1811 let l:last = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1812
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1813 buffer! winfix.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1814
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1815 call assert_fails("lvimgrep /some-search-term/ *.unittest", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1816 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1817
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1818 lvimgrep! /some-search-term/ *.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1819 call assert_notequal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1820
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1821 call delete("first.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1822 call delete("winfix.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1823 call delete("last.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1824 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1825
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1826 " Fail :lvimgrepadd but :lvimgrepadd! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1827 func Test_lvimgrepadd()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1828 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1829 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1830
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1831 edit first.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1832 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1833 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1834
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1835 edit winfix.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1836 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1837 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1838 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1839
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1840 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1841
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1842 edit! last.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1843 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1844 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1845 let l:last = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1846
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1847 buffer! winfix.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1848
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1849 call assert_fails("lvimgrepadd /some-search-term/ *.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1850 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1851
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1852 lvimgrepadd! /some-search-term/ *.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1853 call assert_notequal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1854
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1855 call delete("first.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1856 call delete("winfix.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1857 call delete("last.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1858 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1859
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1860 " Don't allow global marks to change the current 'winfixbuf' window
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1861 func Test_marks_mappings_fail()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1862 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1863
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1864 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1865 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1866 execute "buffer! " . l:other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1867 normal mA
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1868 execute "buffer! " . l:current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1869 normal mB
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1870
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1871 call assert_fails("normal `A", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1872 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1873
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1874 call assert_fails("normal 'A", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1875 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1876
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1877 set nowinfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1878
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1879 normal `A
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1880 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1881 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1882
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1883 " Allow global marks in a 'winfixbuf' window if the jump is the same buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1884 func Test_marks_mappings_pass_intra_move()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1885 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1886
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1887 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1888 call append(0, ["some line", "another line"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1889 normal mA
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1890 normal j
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1891 normal mB
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1892
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1893 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1894
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1895 normal `A
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1896 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1897 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1898
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1899 " Fail :next but :next! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1900 func Test_next()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1901 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1902
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1903 let [l:first, _] = s:make_args_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1904 first!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1905
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1906 call assert_fails("next", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1907 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1908
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1909 next!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1910 call assert_notequal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1911 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1912
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1913 " Ensure :mksession saves 'winfixbuf' details
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1914 func Test_mksession()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1915 CheckFeature mksession
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1916 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1917
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1918 set sessionoptions+=options
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1919 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1920
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1921 mksession test_winfixbuf_Test_mksession.vim
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1922
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1923 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1924 let l:winfixbuf = &winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1925 call assert_equal(0, l:winfixbuf)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1926
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1927 source test_winfixbuf_Test_mksession.vim
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1928
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1929 let l:winfixbuf = &winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1930 call assert_equal(1, l:winfixbuf)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1931
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1932 set sessionoptions&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1933 call delete("test_winfixbuf_Test_mksession.vim")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1934 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1935
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1936 " Allow :next if the next index is the same as the current buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1937 func Test_next_same_buffer()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1938 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1939
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1940 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1941 file foo
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1942 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1943 file bar
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1944 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1945 file fizz
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1946 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1947 file buzz
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1948 args foo foo bar fizz buzz
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1949
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1950 edit foo
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1951 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1952 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1953
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1954 " Allow :next because the args list is `[foo] foo bar fizz buzz
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1955 next
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1956 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1957
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1958 " Fail :next because the args list is `foo [foo] bar fizz buzz
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1959 " and the next buffer would be bar, which is a different buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1960 call assert_fails("next", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1961 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1962 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1963
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1964 " Fail to jump to a tag with g<C-]> if 'winfixbuf' is enabled
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1965 func Test_normal_g_ctrl_square_bracket_right()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1966 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1967
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1968 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1969 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1970 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1971 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1972 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1973 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1974 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1975 call writefile(["one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1976 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1977
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1978 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1979
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1980 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1981
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1982 call assert_fails("normal g\<C-]>", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1983 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1984
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1985 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1986 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1987 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1988 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1989 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1990
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1991 " Fail to jump to a tag with g<RightMouse> if 'winfixbuf' is enabled
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1992 func Test_normal_g_rightmouse()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1993 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1994 set mouse=n
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1995
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1996 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1997 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1998 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1999 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2000 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2001 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2002 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2003 call writefile(["one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2004 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2005 execute "normal \<C-]>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2006
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2007 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2008
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2009 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2010
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2011 call assert_fails("normal g\<RightMouse>", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2012 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2013
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2014 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2015 set mouse&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2016 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2017 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2018 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2019 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2020
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2021 " Fail to jump to a tag with g] if 'winfixbuf' is enabled
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2022 func Test_normal_g_square_bracket_right()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2023 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2024
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2025 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2026 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2027 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2028 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2029 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2030 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2031 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2032 call writefile(["one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2033 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2034
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2035 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2036
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2037 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2038
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2039 call assert_fails("normal g]", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2040 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2041
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2042 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2043 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2044 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2045 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2046 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2047
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2048 " Fail to jump to a tag with <C-RightMouse> if 'winfixbuf' is enabled
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2049 func Test_normal_ctrl_rightmouse()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2050 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2051 set mouse=n
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2052
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2053 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2054 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2055 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2056 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2057 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2058 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2059 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2060 call writefile(["one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2061 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2062 execute "normal \<C-]>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2063
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2064 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2065
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2066 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2067
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2068 call assert_fails("normal \<C-RightMouse>", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2069 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2070
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2071 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2072 set mouse&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2073 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2074 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2075 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2076 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2077
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2078 " Fail to jump to a tag with <C-t> if 'winfixbuf' is enabled
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2079 func Test_normal_ctrl_t()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2080 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2081
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2082 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2083 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2084 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2085 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2086 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2087 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2088 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2089 call writefile(["one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2090 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2091 execute "normal \<C-]>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2092
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2093 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2094
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2095 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2096
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2097 call assert_fails("normal \<C-t>", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2098 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2099
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2100 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2101 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2102 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2103 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2104 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2105
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2106 " Disallow <C-^> in 'winfixbuf' windows
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2107 func Test_normal_ctrl_hat()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2108 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2109 clearjumps
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2110
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2111 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2112 file first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2113 let l:first = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2114
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2115 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2116 file current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2117 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2118
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2119 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2120
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2121 call assert_fails("normal \<C-^>", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2122 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2123 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2124
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2125 " Allow <C-i> in 'winfixbuf' windows if the movement stays within the buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2126 func Test_normal_ctrl_i_pass()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2127 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2128 clearjumps
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2129
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2130 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2131 file first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2132 let l:first = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2133
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2134 enew!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2135 file current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2136 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2137 " Add some lines so we can populate a jumplist"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2138 call append(0, ["some line", "another line"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2139 " Add an entry to the jump list
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2140 " Go up another line
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2141 normal m`
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2142 normal k
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2143 execute "normal \<C-o>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2144
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2145 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2146
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2147 let l:line = getcurpos()[1]
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2148 execute "normal 1\<C-i>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2149 call assert_notequal(l:line, getcurpos()[1])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2150 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2151
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2152 " Disallow <C-o> in 'winfixbuf' windows if it would cause the buffer to switch
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2153 func Test_normal_ctrl_o_fail()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2154 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2155 clearjumps
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2156
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2157 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2158 file first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2159 let l:first = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2160
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2161 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2162 file current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2163 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2164
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2165 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2166
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2167 call assert_fails("normal \<C-o>", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2168 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2169 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2170
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2171 " Allow <C-o> in 'winfixbuf' windows if the movement stays within the buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2172 func Test_normal_ctrl_o_pass()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2173 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2174 clearjumps
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2175
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2176 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2177 file first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2178 let l:first = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2179
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2180 enew!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2181 file current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2182 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2183 " Add some lines so we can populate a jumplist
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2184 call append(0, ["some line", "another line"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2185 " Add an entry to the jump list
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2186 " Go up another line
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2187 normal m`
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2188 normal k
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2189
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2190 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2191
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2192 execute "normal \<C-o>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2193 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2194 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2195
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2196 " Fail to jump to a tag with <C-]> if 'winfixbuf' is enabled
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2197 func Test_normal_ctrl_square_bracket_right()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2198 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2199
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2200 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2201 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2202 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2203 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2204 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2205 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2206 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2207 call writefile(["one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2208 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2209
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2210 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2211
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2212 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2213
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2214 call assert_fails("normal \<C-]>", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2215 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2216
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2217 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2218 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2219 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2220 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2221 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2222
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2223 " Allow <C-w><C-]> with 'winfixbuf' enabled because it runs in a new, split window
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2224 func Test_normal_ctrl_w_ctrl_square_bracket_right()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2225 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2226
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2227 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2228 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2229 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2230 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2231 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2232 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2233 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2234 call writefile(["one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2235 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2236
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2237 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2238
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2239 let l:current_windows = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2240 execute "normal \<C-w>\<C-]>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2241 call assert_equal(l:current_windows + 1, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2242
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2243 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2244 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2245 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2246 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2247 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2248
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2249 " Allow <C-w>g<C-]> with 'winfixbuf' enabled because it runs in a new, split window
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2250 func Test_normal_ctrl_w_g_ctrl_square_bracket_right()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2251 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2252
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2253 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2254 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2255 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2256 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2257 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2258 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2259 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2260 call writefile(["one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2261 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2262
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2263 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2264
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2265 let l:current_windows = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2266 execute "normal \<C-w>g\<C-]>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2267 call assert_equal(l:current_windows + 1, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2268
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2269 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2270 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2271 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2272 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2273 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2274
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2275 " Fail to jump to a tag with <C-]> if 'winfixbuf' is enabled
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2276 func Test_normal_gt()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2277 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2278
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2279 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2280 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2281 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2282 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2283 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2284 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2285 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2286 call writefile(["one", "two", "three"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2287 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2288
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2289 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2290
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2291 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2292
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2293 call assert_fails("normal \<C-]>", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2294 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2295
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2296 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2297 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2298 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2299 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2300 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2301
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2302 " Prevent gF from switching a 'winfixbuf' window's buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2303 func Test_normal_gF()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2304 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2305
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2306 let l:file = tempname()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2307 call append(0, [l:file])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2308 call writefile([], l:file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2309 " Place the cursor onto the line that has `l:file`
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2310 normal gg
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2311 " Prevent Vim from erroring with "No write since last change @ command
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2312 " line" when we try to call gF, later.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2313 set hidden
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2314
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2315 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2316
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2317 let l:buffer = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2318
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2319 call assert_fails("normal gF", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2320 call assert_equal(l:buffer, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2321
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2322 set nowinfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2323
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2324 normal gF
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2325 call assert_notequal(l:buffer, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2326
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2327 call delete(l:file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2328 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2329
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2330 " Prevent gf from switching a 'winfixbuf' window's buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2331 func Test_normal_gf()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2332 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2333
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2334 let l:file = tempname()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2335 call append(0, [l:file])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2336 call writefile([], l:file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2337 " Place the cursor onto the line that has `l:file`
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2338 normal gg
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2339 " Prevent Vim from erroring with "No write since last change @ command
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2340 " line" when we try to call gf, later.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2341 set hidden
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2342
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2343 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2344
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2345 let l:buffer = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2346
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2347 call assert_fails("normal gf", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2348 call assert_equal(l:buffer, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2349
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2350 set nowinfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2351
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2352 normal gf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2353 call assert_notequal(l:buffer, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2354
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2355 call delete(l:file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2356 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2357
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2358 " Fail "goto file under the cursor" (using [f, which is the same as `:normal gf`)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2359 func Test_normal_square_bracket_left_f()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2360 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2361
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2362 let l:file = tempname()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2363 call append(0, [l:file])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2364 call writefile([], l:file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2365 " Place the cursor onto the line that has `l:file`
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2366 normal gg
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2367 " Prevent Vim from erroring with "No write since last change @ command
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2368 " line" when we try to call gf, later.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2369 set hidden
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2370
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2371 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2372
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2373 let l:buffer = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2374
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2375 call assert_fails("normal [f", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2376 call assert_equal(l:buffer, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2377
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2378 set nowinfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2379
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2380 normal [f
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2381 call assert_notequal(l:buffer, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2382
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2383 call delete(l:file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2384 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2385
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2386 " Fail to go to a C macro with [<C-d> if 'winfixbuf' is enabled
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2387 func Test_normal_square_bracket_left_ctrl_d()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2388 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2389
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2390 let l:include_file = tempname() . ".h"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2391 call writefile(["min(1, 12);",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2392 \ '#include "' . l:include_file . '"'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2393 \ ],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2394 \ "main.c")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2395 call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2396 edit main.c
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2397 normal ]\<C-d>
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2398
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2399 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2400
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2401 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2402
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2403 call assert_fails("normal [\<C-d>", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2404 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2405
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2406 set nowinfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2407
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2408 execute "normal [\<C-d>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2409 call assert_notequal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2410
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2411 call delete("main.c")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2412 call delete(l:include_file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2413 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2414
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2415 " Fail to go to a C macro with ]<C-d> if 'winfixbuf' is enabled
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2416 func Test_normal_square_bracket_right_ctrl_d()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2417 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2418
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2419 let l:include_file = tempname() . ".h"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2420 call writefile(["min(1, 12);",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2421 \ '#include "' . l:include_file . '"'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2422 \ ],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2423 \ "main.c")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2424 call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2425 edit main.c
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2426
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2427 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2428
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2429 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2430
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2431 call assert_fails("normal ]\<C-d>", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2432 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2433
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2434 set nowinfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2435
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2436 execute "normal ]\<C-d>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2437 call assert_notequal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2438
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2439 call delete("main.c")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2440 call delete(l:include_file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2441 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2442
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2443 " Fail to go to a C macro with [<C-i> if 'winfixbuf' is enabled
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2444 func Test_normal_square_bracket_left_ctrl_i()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2445 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2446
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2447 let l:include_file = tempname() . ".h"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2448 call writefile(['#include "' . l:include_file . '"',
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2449 \ "min(1, 12);",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2450 \ ],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2451 \ "main.c")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2452 call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2453 edit main.c
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2454 " Move to the line with `min(1, 12);` on it"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2455 normal j
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2456
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2457 set define=^\\s*#\\s*define
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2458 set include=^\\s*#\\s*include
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2459 set path=.,/usr/include,,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2460
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2461 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2462
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2463 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2464
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2465 call assert_fails("normal [\<C-i>", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2466
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2467 set nowinfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2468
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2469 execute "normal [\<C-i>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2470 call assert_notequal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2471
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2472 set define&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2473 set include&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2474 set path&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2475 call delete("main.c")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2476 call delete(l:include_file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2477 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2478
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2479 " Fail to go to a C macro with ]<C-i> if 'winfixbuf' is enabled
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2480 func Test_normal_square_bracket_right_ctrl_i()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2481 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2482
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2483 let l:include_file = tempname() . ".h"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2484 call writefile(["min(1, 12);",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2485 \ '#include "' . l:include_file . '"'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2486 \ ],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2487 \ "main.c")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2488 call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2489 edit main.c
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2490
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2491 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2492
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2493 set define=^\\s*#\\s*define
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2494 set include=^\\s*#\\s*include
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2495 set path=.,/usr/include,,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2496
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2497 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2498
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2499 call assert_fails("normal ]\<C-i>", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2500 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2501
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2502 set nowinfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2503
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2504 execute "normal ]\<C-i>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2505 call assert_notequal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2506
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2507 set define&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2508 set include&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2509 set path&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2510 call delete("main.c")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2511 call delete(l:include_file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2512 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2513
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2514 " Fail "goto file under the cursor" (using ]f, which is the same as `:normal gf`)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2515 func Test_normal_square_bracket_right_f()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2516 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2517
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2518 let l:file = tempname()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2519 call append(0, [l:file])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2520 call writefile([], l:file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2521 " Place the cursor onto the line that has `l:file`
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2522 normal gg
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2523 " Prevent Vim from erroring with "No write since last change @ command
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2524 " line" when we try to call gf, later.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2525 set hidden
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2526
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2527 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2528
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2529 let l:buffer = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2530
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2531 call assert_fails("normal ]f", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2532 call assert_equal(l:buffer, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2533
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2534 set nowinfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2535
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2536 normal ]f
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2537 call assert_notequal(l:buffer, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2538
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2539 call delete(l:file)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2540 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2541
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2542 " Fail to jump to a tag with v<C-]> if 'winfixbuf' is enabled
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2543 func Test_normal_v_ctrl_square_bracket_right()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2544 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2545
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2546 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2547 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2548 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2549 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2550 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2551 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2552 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2553 call writefile(["one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2554 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2555
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2556 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2557
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2558 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2559
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2560 call assert_fails("normal v\<C-]>", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2561 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2562
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2563 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2564 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2565 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2566 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2567 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2568
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2569 " Fail to jump to a tag with vg<C-]> if 'winfixbuf' is enabled
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2570 func Test_normal_v_g_ctrl_square_bracket_right()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2571 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2572
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2573 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2574 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2575 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2576 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2577 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2578 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2579 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2580 call writefile(["one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2581 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2582
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2583 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2584
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2585 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2586
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2587 call assert_fails("normal vg\<C-]>", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2588 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2589
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2590 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2591 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2592 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2593 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2594 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2595
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2596 " Allow :pedit because, unlike :edit, it uses a separate window
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2597 func Test_pedit()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2598 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2599
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2600 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2601
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2602 pedit other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2603
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2604 execute "normal \<C-w>w"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2605 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2606 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2607
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2608 " Fail :pop but :pop! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2609 func Test_pop()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2610 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2611
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2612 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2613 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2614 \ "thesame\tXfile\t1;\"\td\tfile:",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2615 \ "thesame\tXfile\t2;\"\td\tfile:",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2616 \ "thesame\tXfile\t3;\"\td\tfile:",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2617 \ ],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2618 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2619 call writefile(["thesame one", "thesame two", "thesame three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2620 call writefile(["thesame one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2621 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2622
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2623 tag thesame
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2624
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2625 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2626
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2627 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2628
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2629 call assert_fails("pop", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2630 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2631
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2632 pop!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2633 call assert_notequal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2634
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2635 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2636 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2637 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2638 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2639 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2640
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2641 " Fail :previous but :previous! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2642 func Test_previous()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2643 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2644
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2645 let [l:first, _] = s:make_args_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2646 next!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2647
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2648 call assert_fails("previous", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2649 call assert_notequal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2650
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2651 previous!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2652 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2653 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2654
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
2655 " Fail pyxdo if it changes a window with 'winfixbuf' is set
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
2656 func Test_pythonx_pyxdo()
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2657 CheckFeature pythonx
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2658 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2659
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2660 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2661 file first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2662 let g:_previous_buffer = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2663
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2664 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2665 file second
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2666
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2667 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2668
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
2669 pythonx << EOF
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2670 import vim
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2671
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
2672 def test_winfixbuf_Test_pythonx_pyxdo_set_buffer():
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2673 buffer = vim.vars['_previous_buffer']
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2674 vim.current.buffer = vim.buffers[buffer]
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2675 EOF
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2676
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2677 try
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
2678 pyxdo test_winfixbuf_Test_pythonx_pyxdo_set_buffer()
34554
495218030237 patch 9.1.0178: E1513 might be confusing
Christian Brabandt <cb@256bit.org>
parents: 34500
diff changeset
2679 catch /Vim\%((\a\+)\)\=:E1513:/
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2680 let l:caught = 1
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2681 endtry
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2682
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2683 call assert_equal(1, l:caught)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2684
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2685 unlet g:_previous_buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2686 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2687
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
2688 " Fail pyxfile if it changes a window with 'winfixbuf' is set
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
2689 func Test_pythonx_pyxfile()
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2690 CheckFeature pythonx
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2691 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2692
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2693 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2694 file first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2695 let g:_previous_buffer = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2696
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2697 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2698 file second
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2699
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2700 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2701
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2702 call writefile(["import vim",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2703 \ "buffer = vim.vars['_previous_buffer']",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2704 \ "vim.current.buffer = vim.buffers[buffer]",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2705 \ ],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2706 \ "file.py")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2707
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2708 try
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
2709 pyxfile file.py
34554
495218030237 patch 9.1.0178: E1513 might be confusing
Christian Brabandt <cb@256bit.org>
parents: 34500
diff changeset
2710 catch /Vim\%((\a\+)\)\=:E1513:/
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2711 let l:caught = 1
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2712 endtry
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2713
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2714 call assert_equal(1, l:caught)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2715
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2716 call delete("file.py")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2717 unlet g:_previous_buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2718 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2719
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2720 " Fail vim.current.buffer if 'winfixbuf' is set
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
2721 func Test_pythonx_vim_current_buffer()
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2722 CheckFeature pythonx
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2723 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2724
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2725 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2726 file first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2727 let g:_previous_buffer = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2728
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2729 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2730 file second
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2731
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2732 let l:caught = 0
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2733
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2734 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2735
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2736 try
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
2737 pythonx << EOF
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2738 import vim
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2739
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2740 buffer = vim.vars["_previous_buffer"]
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2741 vim.current.buffer = vim.buffers[buffer]
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2742 EOF
34554
495218030237 patch 9.1.0178: E1513 might be confusing
Christian Brabandt <cb@256bit.org>
parents: 34500
diff changeset
2743 catch /Vim\%((\a\+)\)\=:E1513:/
34470
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2744 let l:caught = 1
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2745 endtry
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2746
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2747 call assert_equal(1, l:caught)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2748 unlet g:_previous_buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2749 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2750
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2751 " Ensure remapping to a disabled action still triggers failures
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2752 func Test_remap_key_fail()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2753 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2754
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2755 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2756 file first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2757 let l:first = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2758
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2759 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2760 file current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2761 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2762
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2763 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2764
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2765 nnoremap g <C-^>
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2766
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2767 call assert_fails("normal g", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2768 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2769
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2770 nunmap g
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2771 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2772
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2773 " Ensure remapping a disabled key to something valid does trigger any failures
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2774 func Test_remap_key_pass()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2775 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2776
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2777 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2778 file first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2779 let l:first = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2780
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2781 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2782 file current
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2783 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2784
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2785 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2786
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2787 call assert_fails("normal \<C-^>", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2788 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2789
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2790 " Disallow <C-^> by default but allow it if the command does something else
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2791 nnoremap <C-^> :echo "hello!"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2792
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2793 execute "normal \<C-^>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2794 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2795
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2796 nunmap <C-^>
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2797 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2798
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2799 " Fail :rewind but :rewind! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2800 func Test_rewind()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2801 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2802
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2803 let [l:first, _] = s:make_args_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2804 next!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2805
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2806 call assert_fails("rewind", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2807 call assert_notequal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2808
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2809 rewind!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2810 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2811 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2812
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2813 " Allow :sblast because it opens the buffer in a new, split window
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2814 func Test_sblast()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2815 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2816
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2817 let l:other = s:make_buffer_pairs(1)
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2818 bfirst!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2819 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2820
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2821 sblast
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2822 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2823 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2824
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2825 " Fail :sbprevious but :sbprevious! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2826 func Test_sbprevious()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2827 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2828
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2829 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2830 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2831
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2832 sbprevious
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2833 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2834 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2835
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2836 " Make sure 'winfixbuf' can be set using 'winfixbuf' or 'wfb'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2837 func Test_short_option()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2838 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2839
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2840 call s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2841
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2842 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2843 call assert_fails("edit something_else", "E1513")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2844
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2845 set nowinfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2846 set wfb
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2847 call assert_fails("edit another_place", "E1513")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2848
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2849 set nowfb
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2850 edit last_place
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2851 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2852
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2853 " Allow :snext because it makes a new window
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2854 func Test_snext()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2855 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2856
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2857 let [l:first, _] = s:make_args_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2858 first!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2859
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2860 let l:current_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2861
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2862 snext
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2863 call assert_notequal(l:current_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2864 call assert_notequal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2865 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2866
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2867 " Ensure the first has 'winfixbuf' and a new split window is 'nowinfixbuf'
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2868 func Test_split_window()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2869 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2870
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2871 split
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2872 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2873
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2874 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2875
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2876 let l:winfix_window_1 = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2877 vsplit
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2878 let l:winfix_window_2 = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2879
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2880 call assert_equal(1, getwinvar(l:winfix_window_1, "&winfixbuf"))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2881 call assert_equal(0, getwinvar(l:winfix_window_2, "&winfixbuf"))
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2882 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2883
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2884 " Fail :tNext but :tNext! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2885 func Test_tNext()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2886 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2887
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2888 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2889 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2890 \ "thesame\tXfile\t1;\"\td\tfile:",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2891 \ "thesame\tXfile\t2;\"\td\tfile:",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2892 \ "thesame\tXfile\t3;\"\td\tfile:",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2893 \ ],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2894 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2895 call writefile(["thesame one", "thesame two", "thesame three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2896 call writefile(["thesame one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2897 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2898
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2899 tag thesame
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2900 execute "normal \<C-^>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2901 tnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2902
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2903 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2904
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2905 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2906
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2907 call assert_fails("tNext", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2908 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2909
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2910 tNext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2911
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2912 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2913 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2914 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2915 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2916 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2917
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2918 " Call :tabdo and choose the next available 'nowinfixbuf' window.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2919 func Test_tabdo_choose_available_window()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2920 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2921
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2922 let [l:first, _] = s:make_args_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2923
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2924 " Make a split window that is 'nowinfixbuf' but make it the second-to-last
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2925 " window so that :tabdo will first try the 'winfixbuf' window, pass over it,
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2926 " and prefer the other 'nowinfixbuf' window, instead.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2927 "
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2928 " +-------------------+
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2929 " | 'nowinfixbuf' |
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2930 " +-------------------+
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2931 " | 'winfixbuf' | <-- Cursor is here
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2932 " +-------------------+
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2933 split
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2934 let l:nowinfixbuf_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2935 " Move to the 'winfixbuf' window now
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2936 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2937 let l:winfixbuf_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2938
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2939 let l:expected_windows = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2940 tabdo echo ''
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2941 call assert_equal(l:nowinfixbuf_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2942 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2943 call assert_equal(l:expected_windows, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2944 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2945
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2946 " Call :tabdo and create a new split window if all available windows are 'winfixbuf'.
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2947 func Test_tabdo_make_new_window()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2948 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2949
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2950 let [l:first, _] = s:make_buffers_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2951 execute "buffer! " . l:first
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2952
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2953 let l:current = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2954 let l:current_windows = s:get_windows_count()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2955
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2956 tabdo echo ''
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2957 call assert_notequal(l:current, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2958 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2959 execute "normal \<C-w>j"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2960 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2961 call assert_equal(l:current_windows + 1, s:get_windows_count())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2962 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2963
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2964 " Fail :tag but :tag! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2965 func Test_tag()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2966 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2967
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2968 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2969 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2970 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2971 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2972 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2973 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2974 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2975 call writefile(["one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2976 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2977
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2978 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2979
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2980 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2981
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2982 call assert_fails("tag one", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2983 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2984
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2985 tag! one
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2986 call assert_notequal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2987
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2988 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2989 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2990 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2991 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2992 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2993
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2994
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2995 " Fail :tfirst but :tfirst! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2996 func Test_tfirst()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2997 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2998
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2999 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3000 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3001 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3002 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3003 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3004 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3005 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3006 call writefile(["one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3007 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3008
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3009 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3010
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3011 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3012
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3013 call assert_fails("tfirst", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3014 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3015
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3016 tfirst!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3017 call assert_notequal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3018
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3019 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3020 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3021 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3022 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3023 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3024
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3025 " Fail :tjump but :tjump! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3026 func Test_tjump()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3027 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3028
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3029 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3030 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3031 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3032 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3033 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3034 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3035 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3036 call writefile(["one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3037 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3038
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3039 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3040
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3041 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3042
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3043 call assert_fails("tjump one", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3044 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3045
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3046 tjump! one
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3047 call assert_notequal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3048
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3049 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3050 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3051 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3052 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3053 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3054
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3055 " Fail :tlast but :tlast! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3056 func Test_tlast()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3057 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3058
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3059 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3060 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3061 \ "one\tXfile\t1",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3062 \ "three\tXfile\t3",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3063 \ "two\tXfile\t2"],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3064 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3065 call writefile(["one", "two", "three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3066 edit Xfile
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3067 tjump one
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3068 edit Xfile
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3069
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3070 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3071
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3072 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3073
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3074 call assert_fails("tlast", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3075 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3076
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3077 tlast!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3078 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3079
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3080 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3081 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3082 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3083 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3084
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3085 " Fail :tnext but :tnext! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3086 func Test_tnext()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3087 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3088
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3089 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3090 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3091 \ "thesame\tXfile\t1;\"\td\tfile:",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3092 \ "thesame\tXfile\t2;\"\td\tfile:",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3093 \ "thesame\tXfile\t3;\"\td\tfile:",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3094 \ ],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3095 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3096 call writefile(["thesame one", "thesame two", "thesame three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3097 call writefile(["thesame one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3098 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3099
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3100 tag thesame
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3101 execute "normal \<C-^>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3102
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3103 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3104
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3105 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3106
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3107 call assert_fails("tnext", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3108 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3109
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3110 tnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3111 call assert_notequal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3112
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3113 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3114 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3115 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3116 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3117 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3118
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3119 " Fail :tprevious but :tprevious! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3120 func Test_tprevious()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3121 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3122
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3123 set tags=Xtags
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3124 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3125 \ "thesame\tXfile\t1;\"\td\tfile:",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3126 \ "thesame\tXfile\t2;\"\td\tfile:",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3127 \ "thesame\tXfile\t3;\"\td\tfile:",
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3128 \ ],
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3129 \ "Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3130 call writefile(["thesame one", "thesame two", "thesame three"], "Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3131 call writefile(["thesame one"], "Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3132 edit Xother
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3133
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3134 tag thesame
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3135 execute "normal \<C-^>"
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3136 tnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3137
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3138 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3139
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3140 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3141
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3142 call assert_fails("tprevious", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3143 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3144
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3145 tprevious!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3146
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3147 set tags&
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3148 call delete("Xtags")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3149 call delete("Xfile")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3150 call delete("Xother")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3151 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3152
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3153 " Fail :view but :view! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3154 func Test_view()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3155 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3156
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3157 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3158 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3159
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3160 call assert_fails("view other", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3161 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3162
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3163 view! other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3164 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3165 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3166
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3167 " Fail :visual but :visual! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3168 func Test_visual()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3169 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3170
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3171 let l:other = s:make_buffer_pairs()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3172 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3173
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3174 call assert_fails("visual other", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3175 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3176
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3177 visual! other
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3178 call assert_equal(l:other, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3179 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3180
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3181 " Fail :vimgrep but :vimgrep! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3182 func Test_vimgrep()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3183 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3184 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3185
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3186 edit first.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3187 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3188 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3189
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3190 edit winfix.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3191 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3192 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3193 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3194
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3195 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3196
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3197 edit! last.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3198 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3199 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3200 let l:last = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3201
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3202 buffer! winfix.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3203
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3204 call assert_fails("vimgrep /some-search-term/ *.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3205 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3206
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3207 " Don't error and also do swap to the first match because ! was included
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3208 vimgrep! /some-search-term/ *.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3209 call assert_notequal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3210
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3211 call delete("first.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3212 call delete("winfix.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3213 call delete("last.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3214 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3215
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3216 " Fail :vimgrepadd but ::vimgrepadd! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3217 func Test_vimgrepadd()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3218 CheckFeature quickfix
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3219 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3220
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3221 edit first.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3222 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3223 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3224
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3225 edit winfix.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3226 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3227 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3228 let l:current = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3229
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3230 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3231
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3232 edit! last.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3233 call append(0, ["some-search-term"])
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3234 write
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3235 let l:last = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3236
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3237 buffer! winfix.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3238
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3239 call assert_fails("vimgrepadd /some-search-term/ *.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3240 call assert_equal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3241
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3242 vimgrepadd! /some-search-term/ *.unittest
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3243 call assert_notequal(l:current, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3244 call delete("first.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3245 call delete("winfix.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3246 call delete("last.unittest")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3247 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3248
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3249 " Fail :wNext but :wNext! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3250 func Test_wNext()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3251 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3252
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3253 let [l:first, _] = s:make_args_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3254 next!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3255
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3256 call assert_fails("wNext", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3257 call assert_notequal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3258
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3259 wNext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3260 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3261
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3262 call delete("first")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3263 call delete("middle")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3264 call delete("last")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3265 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3266
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3267 " Allow :windo unless `:windo foo` would change a 'winfixbuf' window's buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3268 func Test_windo()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3269 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3270
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3271 let l:current_window = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3272 let l:current_buffer = bufnr()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3273 split
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3274 enew
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3275 file some_other_buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3276
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3277 set winfixbuf
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3278
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3279 let l:current = win_getid()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3280
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3281 windo echo ''
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3282 call assert_equal(l:current_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3283
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3284 call assert_fails('execute "windo buffer ' . l:current_buffer . '"', "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3285 call assert_equal(l:current_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3286
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3287 execute "windo buffer! " . l:current_buffer
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3288 call assert_equal(l:current_window, win_getid())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3289 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3290
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3291 " Fail :wnext but :wnext! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3292 func Test_wnext()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3293 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3294
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3295 let [_, l:last] = s:make_args_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3296 next!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3297
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3298 call assert_fails("wnext", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3299 call assert_notequal(l:last, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3300
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3301 wnext!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3302 call assert_equal(l:last, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3303
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3304 call delete("first")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3305 call delete("middle")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3306 call delete("last")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3307 endfunc
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3308
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3309 " Fail :wprevious but :wprevious! is allowed
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3310 func Test_wprevious()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3311 call s:reset_all_buffers()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3312
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3313 let [l:first, _] = s:make_args_list()
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3314 next!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3315
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3316 call assert_fails("wprevious", "E1513:")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3317 call assert_notequal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3318
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3319 wprevious!
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3320 call assert_equal(l:first, bufnr())
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3321
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3322 call delete("first")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3323 call delete("middle")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3324 call delete("last")
dd8f5311cee5 patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3325 endfunc
34479
2cf84e8dc58b patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property
Christian Brabandt <cb@256bit.org>
parents: 34470
diff changeset
3326
2cf84e8dc58b patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property
Christian Brabandt <cb@256bit.org>
parents: 34470
diff changeset
3327 func Test_quickfix_switchbuf_invalid_prevwin()
2cf84e8dc58b patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property
Christian Brabandt <cb@256bit.org>
parents: 34470
diff changeset
3328 call s:reset_all_buffers()
2cf84e8dc58b patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property
Christian Brabandt <cb@256bit.org>
parents: 34470
diff changeset
3329
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3330 call s:make_simple_quickfix()
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3331 call assert_equal(1, getqflist(#{idx: 0}).idx)
34479
2cf84e8dc58b patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property
Christian Brabandt <cb@256bit.org>
parents: 34470
diff changeset
3332
2cf84e8dc58b patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property
Christian Brabandt <cb@256bit.org>
parents: 34470
diff changeset
3333 set switchbuf=uselast
2cf84e8dc58b patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property
Christian Brabandt <cb@256bit.org>
parents: 34470
diff changeset
3334 split
2cf84e8dc58b patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property
Christian Brabandt <cb@256bit.org>
parents: 34470
diff changeset
3335 copen
2cf84e8dc58b patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property
Christian Brabandt <cb@256bit.org>
parents: 34470
diff changeset
3336 execute winnr('#') 'quit'
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3337 call assert_equal(2, winnr('$'))
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3338
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3339 cnext " Would've triggered a null pointer member access
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3340 call assert_equal(2, getqflist(#{idx: 0}).idx)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3341
34479
2cf84e8dc58b patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property
Christian Brabandt <cb@256bit.org>
parents: 34470
diff changeset
3342 set switchbuf&
2cf84e8dc58b patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property
Christian Brabandt <cb@256bit.org>
parents: 34470
diff changeset
3343 endfunc
2cf84e8dc58b patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property
Christian Brabandt <cb@256bit.org>
parents: 34470
diff changeset
3344
34485
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3345 func Test_listdo_goto_prevwin()
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3346 call s:reset_all_buffers()
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3347 call s:make_buffers_list()
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3348
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3349 new
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3350 call assert_equal(0, &winfixbuf)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3351 wincmd p
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3352 call assert_equal(1, &winfixbuf)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3353 call assert_notequal(bufnr(), bufnr('#'))
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3354
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3355 augroup ListDoGotoPrevwin
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3356 au!
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3357 au BufLeave * let s:triggered = 1
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3358 \| call assert_equal(bufnr(), winbufnr(winnr()))
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3359 augroup END
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3360 " Should correctly switch to the window without 'winfixbuf', and curbuf should
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3361 " be consistent with curwin->w_buffer for autocommands.
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3362 bufdo "
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3363 call assert_equal(0, &winfixbuf)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3364 call assert_equal(1, s:triggered)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3365 unlet! s:triggered
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3366 au! ListDoGotoPrevwin
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3367
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3368 set winfixbuf
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3369 wincmd p
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3370 call assert_equal(2, winnr('$'))
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3371 " Both curwin and prevwin have 'winfixbuf' set, so should split a new window
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3372 " without it set.
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3373 bufdo "
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3374 call assert_equal(0, &winfixbuf)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3375 call assert_equal(3, winnr('$'))
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3376
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3377 quit
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3378 call assert_equal(2, winnr('$'))
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3379 call assert_equal(1, &winfixbuf)
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3380 augroup ListDoGotoPrevwin
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3381 au!
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3382 au WinEnter * ++once set winfixbuf
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3383 augroup END
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3384 " Same as before, but naughty autocommands set 'winfixbuf' for the new window.
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3385 " :bufdo should give up in this case.
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3386 call assert_fails('bufdo "', 'E1513:')
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3387
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3388 au! ListDoGotoPrevwin
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3389 augroup! ListDoGotoPrevwin
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3390 endfunc
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3391
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3392 func Test_quickfix_changed_split_failed()
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3393 call s:reset_all_buffers()
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3394
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3395 call s:make_simple_quickfix()
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3396 call assert_equal(1, winnr('$'))
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3397
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3398 " Quickfix code will open a split in an attempt to get a 'nowinfixbuf' window
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3399 " to switch buffers in. Interfere with things by setting 'winfixbuf' in it.
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3400 augroup QfChanged
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3401 au!
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3402 au WinEnter * ++once call assert_equal(2, winnr('$'))
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3403 \| set winfixbuf | call setqflist([], 'f')
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3404 augroup END
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3405 call assert_fails('cnext', ['E1513:', 'E925:'])
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3406 " Check that the split was automatically closed.
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3407 call assert_equal(1, winnr('$'))
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3408
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3409 au! QfChanged
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3410 augroup! QfChanged
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3411 endfunc
157cf882799f patch 9.1.0150: Several minor 'winfixbuf' issues
Christian Brabandt <cb@256bit.org>
parents: 34479
diff changeset
3412
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
3413 func Test_bufdo_cnext_splitwin_fails()
34489
4dd6d243e4f7 patch 9.1.0152: Coverity complains about ignoring return value
Christian Brabandt <cb@256bit.org>
parents: 34485
diff changeset
3414 call s:reset_all_buffers()
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
3415 call s:make_simple_quickfix()
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
3416 call assert_equal(1, getqflist(#{idx: 0}).idx)
34489
4dd6d243e4f7 patch 9.1.0152: Coverity complains about ignoring return value
Christian Brabandt <cb@256bit.org>
parents: 34485
diff changeset
3417 " Make sure there is not enough room to
4dd6d243e4f7 patch 9.1.0152: Coverity complains about ignoring return value
Christian Brabandt <cb@256bit.org>
parents: 34485
diff changeset
3418 " split the winfixedbuf window
4dd6d243e4f7 patch 9.1.0152: Coverity complains about ignoring return value
Christian Brabandt <cb@256bit.org>
parents: 34485
diff changeset
3419 let &winheight=&lines
4dd6d243e4f7 patch 9.1.0152: Coverity complains about ignoring return value
Christian Brabandt <cb@256bit.org>
parents: 34485
diff changeset
3420 let &winminheight=&lines-2
34500
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
3421 " Still want E1513, or it may not be clear why a split was attempted and why
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
3422 " it failing caused the commands to abort.
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
3423 call assert_fails(':bufdo echo 1', ['E36:', 'E1513:'])
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
3424 call assert_fails(':cnext', ['E36:', 'E1513:'])
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
3425 " Ensure the entry didn't change.
4da97f213d15 patch 9.1.0156: Make 'wfb' failing to split still report E1513
Christian Brabandt <cb@256bit.org>
parents: 34489
diff changeset
3426 call assert_equal(1, getqflist(#{idx: 0}).idx)
34489
4dd6d243e4f7 patch 9.1.0152: Coverity complains about ignoring return value
Christian Brabandt <cb@256bit.org>
parents: 34485
diff changeset
3427 set winminheight&vim winheight&vim
4dd6d243e4f7 patch 9.1.0152: Coverity complains about ignoring return value
Christian Brabandt <cb@256bit.org>
parents: 34485
diff changeset
3428 endfunc
4dd6d243e4f7 patch 9.1.0152: Coverity complains about ignoring return value
Christian Brabandt <cb@256bit.org>
parents: 34485
diff changeset
3429
34479
2cf84e8dc58b patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property
Christian Brabandt <cb@256bit.org>
parents: 34470
diff changeset
3430 " vim: shiftwidth=2 sts=2 expandtab