blob: 9d1a2c83a504a1143a4248e3d33218d98e570035 [file] [log] [blame]
Bram Moolenaarf5901aa2013-07-01 21:25:25 +02001This will test for problems in quickfix:
2A. incorrectly copying location lists which caused the location list to show a
3 different name than the file that was actually being displayed.
4B. not reusing the window for which the location list window is opened but
5 instead creating new windows.
6C. make sure that the location list window is not reused instead of the window
7 it belongs to.
8
9Note: to debug a problem comment out the last ":b 1" in a test and testing will
10stop at this point.
11
12STARTTEST
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
52ENDTEST
53
54Test A:
55STARTTEST
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
Bram Moolenaaree0ee2a2013-07-03 21:19:07 +020075:let fileName = substitute(fileName, '\\', '/', 'g')
76:let locationListFileName = substitute(locationListFileName, '\\', '/', 'g')
Bram Moolenaarf5901aa2013-07-01 21:25:25 +020077:call append(line('$'), "Test A:")
78:call append(line('$'), " - file name displayed: " . fileName)
79:call append(line('$'), " - quickfix claims that the file name displayed is: " . locationListFileName)
80:w
81:wincmd o
82:b 1
83ENDTEST
84
85Test B:
86STARTTEST
87:lrewind
88:lopen
89:2
90:exe "normal \<CR>"
91:wincmd p
92:3
93:exe "normal \<CR>"
94:wincmd p
95:4
96:exe "normal \<CR>"
97:let numberOfWindowsOpen = winnr('$')
98:wincmd n
99:wincmd K
100:b test.out
101:call append(line('$'), "Test B:")
102:call append(line('$'), " - number of window open: " . numberOfWindowsOpen)
103:w
104:wincmd o
105:b 1
106ENDTEST
107
108Test C:
109STARTTEST
110:lrewind
111:lopen
112:" Let's move the location list window to the top to check whether it (the first
113:" window found) will be reused when we try to open new windows:
114:wincmd K
115:2
116:exe "normal \<CR>"
117:wincmd p
118:3
119:exe "normal \<CR>"
120:wincmd p
121:4
122:exe "normal \<CR>"
123:1wincmd w
124:let locationListWindowBufType = &buftype
125:2wincmd w
126:let bufferName = expand("%")
127:wincmd n
128:wincmd K
129:b test.out
Bram Moolenaaree0ee2a2013-07-03 21:19:07 +0200130:let bufferName = substitute(bufferName, '\\', '/', 'g')
Bram Moolenaarf5901aa2013-07-01 21:25:25 +0200131:call append(line('$'), "Test C:")
132:call append(line('$'), " - 'buftype' of the location list window: " . locationListWindowBufType)
133:call append(line('$'), " - buffer displayed in the 2nd window: " . bufferName)
134:w
135:wincmd o
136:b 1
137ENDTEST
138
139STARTTEST
140:qa
141ENDTEST
142