5084
|
1 This will test for problems in quickfix:
|
|
2 A. incorrectly copying location lists which caused the location list to show a
|
|
3 different name than the file that was actually being displayed.
|
|
4 B. not reusing the window for which the location list window is opened but
|
|
5 instead creating new windows.
|
|
6 C. make sure that the location list window is not reused instead of the window
|
|
7 it belongs to.
|
|
8
|
|
9 Note: to debug a problem comment out the last ":b 1" in a test and testing will
|
|
10 stop at this point.
|
|
11
|
|
12 STARTTEST
|
|
13 :so small.vim
|
|
14 : enew
|
|
15 : w! test.out
|
|
16 : b 1
|
|
17 : " Set up the test environment:
|
|
18 : function! ReadTestProtocol(name)
|
|
19 : let base = substitute(a:name, '\v^test://(.*)%(\.[^.]+)?', '\1', '')
|
|
20 : let word = substitute(base, '\v(.*)\..*', '\1', '')
|
|
21 :
|
|
22 : setl modifiable
|
|
23 : setl noreadonly
|
|
24 : setl noswapfile
|
|
25 : setl bufhidden=delete
|
|
26 : %del _
|
|
27 : " For problem 2:
|
|
28 : " 'buftype' has to be set to reproduce the constant opening of new windows
|
|
29 : setl buftype=nofile
|
|
30 :
|
|
31 : call setline(1, word)
|
|
32 :
|
|
33 : setl nomodified
|
|
34 : setl nomodifiable
|
|
35 : setl readonly
|
|
36 : exe 'doautocmd BufRead ' . substitute(a:name, '\v^test://(.*)', '\1', '')
|
|
37 : endfunction
|
|
38 : augroup testgroup
|
|
39 : au!
|
|
40 : autocmd BufReadCmd test://* call ReadTestProtocol(expand("<amatch>"))
|
|
41 : augroup END
|
|
42 : let words = [ "foo", "bar", "baz", "quux", "shmoo", "spam", "eggs" ]
|
|
43 :
|
|
44 : let qflist = []
|
|
45 : for word in words
|
|
46 : call add(qflist, {'filename': 'test://' . word . '.txt', 'text': 'file ' . word . '.txt', })
|
|
47 : " NOTE: problem 1:
|
|
48 : " intentionally not setting 'lnum' so that the quickfix entries are not
|
|
49 : " valid
|
|
50 : call setloclist(0, qflist, ' ')
|
|
51 : endfor
|
|
52 ENDTEST
|
|
53
|
|
54 Test A:
|
|
55 STARTTEST
|
|
56 :lrewind
|
|
57 :enew
|
|
58 :lopen
|
|
59 :lnext
|
|
60 :lnext
|
|
61 :lnext
|
|
62 :lnext
|
|
63 :vert split
|
|
64 :wincmd L
|
|
65 :lopen
|
|
66 :wincmd p
|
|
67 :lnext
|
|
68 :"b 1
|
|
69 :let fileName = expand("%")
|
|
70 :wincmd p
|
|
71 :let locationListFileName = substitute(getline(line('.')), '\([^|]*\)|.*', '\1', '')
|
|
72 :wincmd n
|
|
73 :wincmd K
|
|
74 :b test.out
|
|
75 :call append(line('$'), "Test A:")
|
|
76 :call append(line('$'), " - file name displayed: " . fileName)
|
|
77 :call append(line('$'), " - quickfix claims that the file name displayed is: " . locationListFileName)
|
|
78 :w
|
|
79 :wincmd o
|
|
80 :b 1
|
|
81 ENDTEST
|
|
82
|
|
83 Test B:
|
|
84 STARTTEST
|
|
85 :lrewind
|
|
86 :lopen
|
|
87 :2
|
|
88 :exe "normal \<CR>"
|
|
89 :wincmd p
|
|
90 :3
|
|
91 :exe "normal \<CR>"
|
|
92 :wincmd p
|
|
93 :4
|
|
94 :exe "normal \<CR>"
|
|
95 :let numberOfWindowsOpen = winnr('$')
|
|
96 :wincmd n
|
|
97 :wincmd K
|
|
98 :b test.out
|
|
99 :call append(line('$'), "Test B:")
|
|
100 :call append(line('$'), " - number of window open: " . numberOfWindowsOpen)
|
|
101 :w
|
|
102 :wincmd o
|
|
103 :b 1
|
|
104 ENDTEST
|
|
105
|
|
106 Test C:
|
|
107 STARTTEST
|
|
108 :lrewind
|
|
109 :lopen
|
|
110 :" Let's move the location list window to the top to check whether it (the first
|
|
111 :" window found) will be reused when we try to open new windows:
|
|
112 :wincmd K
|
|
113 :2
|
|
114 :exe "normal \<CR>"
|
|
115 :wincmd p
|
|
116 :3
|
|
117 :exe "normal \<CR>"
|
|
118 :wincmd p
|
|
119 :4
|
|
120 :exe "normal \<CR>"
|
|
121 :1wincmd w
|
|
122 :let locationListWindowBufType = &buftype
|
|
123 :2wincmd w
|
|
124 :let bufferName = expand("%")
|
|
125 :wincmd n
|
|
126 :wincmd K
|
|
127 :b test.out
|
|
128 :call append(line('$'), "Test C:")
|
|
129 :call append(line('$'), " - 'buftype' of the location list window: " . locationListWindowBufType)
|
|
130 :call append(line('$'), " - buffer displayed in the 2nd window: " . bufferName)
|
|
131 :w
|
|
132 :wincmd o
|
|
133 :b 1
|
|
134 ENDTEST
|
|
135
|
|
136 STARTTEST
|
|
137 :qa
|
|
138 ENDTEST
|
|
139
|