Mercurial > vim
comparison src/testdir/test_quickfix.vim @ 16019:096b8ccd855e v8.1.1015
patch 8.1.1015: quickfix buffer shows up in list, can't get buffer number
commit https://github.com/vim/vim/commit/647e24ba3dbf7ff448aa471b1a659a18267ae056
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 17 16:39:46 2019 +0100
patch 8.1.1015: quickfix buffer shows up in list, can't get buffer number
Problem: Quickfix buffer shows up in list, can't get buffer number.
Solution: Make the quickfix buffer unlisted when the quickfix window is
closed. get the quickfix buffer number with getqflist().
(Yegappan Lakshmanan, closes #4113)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 17 Mar 2019 16:45:11 +0100 |
parents | f376cd250b07 |
children | 4202f556aefe |
comparison
equal
deleted
inserted
replaced
16018:aa208549a80b | 16019:096b8ccd855e |
---|---|
3108 call assert_equal('', g:Xgetlist({'title' : 0}).title) | 3108 call assert_equal('', g:Xgetlist({'title' : 0}).title) |
3109 call assert_equal(0, g:Xgetlist({'winid' : 0}).winid) | 3109 call assert_equal(0, g:Xgetlist({'winid' : 0}).winid) |
3110 call assert_equal(0, g:Xgetlist({'changedtick' : 0}).changedtick) | 3110 call assert_equal(0, g:Xgetlist({'changedtick' : 0}).changedtick) |
3111 if a:cchar == 'c' | 3111 if a:cchar == 'c' |
3112 call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, | 3112 call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, |
3113 \ 'items' : [], 'nr' : 0, 'size' : 0, | 3113 \ 'items' : [], 'nr' : 0, 'size' : 0, 'qfbufnr' : 0, |
3114 \ 'title' : '', 'winid' : 0, 'changedtick': 0}, | 3114 \ 'title' : '', 'winid' : 0, 'changedtick': 0}, |
3115 \ g:Xgetlist({'all' : 0})) | 3115 \ g:Xgetlist({'all' : 0})) |
3116 else | 3116 else |
3117 call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, | 3117 call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, |
3118 \ 'items' : [], 'nr' : 0, 'size' : 0, 'title' : '', | 3118 \ 'items' : [], 'nr' : 0, 'size' : 0, 'title' : '', |
3119 \ 'winid' : 0, 'changedtick': 0, 'filewinid' : 0}, | 3119 \ 'winid' : 0, 'changedtick': 0, 'filewinid' : 0, |
3120 \ 'qfbufnr' : 0}, | |
3120 \ g:Xgetlist({'all' : 0})) | 3121 \ g:Xgetlist({'all' : 0})) |
3121 endif | 3122 endif |
3122 | 3123 |
3123 " Quickfix window with empty stack | 3124 " Quickfix window with empty stack |
3124 silent! Xopen | 3125 silent! Xopen |
3125 let qfwinid = (a:cchar == 'c') ? win_getid() : 0 | 3126 let qfwinid = (a:cchar == 'c') ? win_getid() : 0 |
3127 let qfbufnr = (a:cchar == 'c') ? bufnr('') : 0 | |
3126 call assert_equal(qfwinid, g:Xgetlist({'winid' : 0}).winid) | 3128 call assert_equal(qfwinid, g:Xgetlist({'winid' : 0}).winid) |
3127 Xclose | 3129 Xclose |
3128 | 3130 |
3129 " Empty quickfix list | 3131 " Empty quickfix list |
3130 Xexpr "" | 3132 Xexpr "" |
3152 call assert_equal(0, g:Xgetlist({'id' : qfid, 'winid' : 0}).winid) | 3154 call assert_equal(0, g:Xgetlist({'id' : qfid, 'winid' : 0}).winid) |
3153 call assert_equal(0, g:Xgetlist({'id' : qfid, 'changedtick' : 0}).changedtick) | 3155 call assert_equal(0, g:Xgetlist({'id' : qfid, 'changedtick' : 0}).changedtick) |
3154 if a:cchar == 'c' | 3156 if a:cchar == 'c' |
3155 call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [], | 3157 call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [], |
3156 \ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0, | 3158 \ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0, |
3159 \ 'qfbufnr' : qfbufnr, | |
3157 \ 'changedtick' : 0}, g:Xgetlist({'id' : qfid, 'all' : 0})) | 3160 \ 'changedtick' : 0}, g:Xgetlist({'id' : qfid, 'all' : 0})) |
3158 else | 3161 else |
3159 call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [], | 3162 call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [], |
3160 \ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0, | 3163 \ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0, |
3161 \ 'changedtick' : 0, 'filewinid' : 0}, | 3164 \ 'changedtick' : 0, 'filewinid' : 0, 'qfbufnr' : 0}, |
3162 \ g:Xgetlist({'id' : qfid, 'all' : 0})) | 3165 \ g:Xgetlist({'id' : qfid, 'all' : 0})) |
3163 endif | 3166 endif |
3164 | 3167 |
3165 " Non-existing quickfix list number | 3168 " Non-existing quickfix list number |
3166 call assert_equal('', g:Xgetlist({'nr' : 5, 'context' : 0}).context) | 3169 call assert_equal('', g:Xgetlist({'nr' : 5, 'context' : 0}).context) |
3173 call assert_equal(0, g:Xgetlist({'nr' : 5, 'winid' : 0}).winid) | 3176 call assert_equal(0, g:Xgetlist({'nr' : 5, 'winid' : 0}).winid) |
3174 call assert_equal(0, g:Xgetlist({'nr' : 5, 'changedtick' : 0}).changedtick) | 3177 call assert_equal(0, g:Xgetlist({'nr' : 5, 'changedtick' : 0}).changedtick) |
3175 if a:cchar == 'c' | 3178 if a:cchar == 'c' |
3176 call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [], | 3179 call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [], |
3177 \ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0, | 3180 \ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0, |
3178 \ 'changedtick' : 0}, g:Xgetlist({'nr' : 5, 'all' : 0})) | 3181 \ 'changedtick' : 0, 'qfbufnr' : qfbufnr}, |
3182 \ g:Xgetlist({'nr' : 5, 'all' : 0})) | |
3179 else | 3183 else |
3180 call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [], | 3184 call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [], |
3181 \ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0, | 3185 \ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0, |
3182 \ 'changedtick' : 0, 'filewinid' : 0}, | 3186 \ 'changedtick' : 0, 'filewinid' : 0, 'qfbufnr' : 0}, |
3183 \ g:Xgetlist({'nr' : 5, 'all' : 0})) | 3187 \ g:Xgetlist({'nr' : 5, 'all' : 0})) |
3184 endif | 3188 endif |
3185 endfunc | 3189 endfunc |
3186 | 3190 |
3187 func Test_getqflist() | 3191 func Test_getqflist() |
3910 Xopen | 3914 Xopen |
3911 let qfbnum = bufnr('') | 3915 let qfbnum = bufnr('') |
3912 Xclose | 3916 Xclose |
3913 " Even after the quickfix window is closed, the buffer should be loaded | 3917 " Even after the quickfix window is closed, the buffer should be loaded |
3914 call assert_true(bufloaded(qfbnum)) | 3918 call assert_true(bufloaded(qfbnum)) |
3919 call assert_true(qfbnum, g:Xgetlist({'qfbufnr' : 0}).qfbufnr) | |
3915 Xopen | 3920 Xopen |
3916 " Buffer should be reused when opening the window again | 3921 " Buffer should be reused when opening the window again |
3917 call assert_equal(qfbnum, bufnr('')) | 3922 call assert_equal(qfbnum, bufnr('')) |
3918 Xclose | 3923 Xclose |
3919 | 3924 |
3928 let qfbnum = bufnr('') | 3933 let qfbnum = bufnr('') |
3929 call assert_match(qfbnum . ' %a- "\[Location List]"', execute('ls')) | 3934 call assert_match(qfbnum . ' %a- "\[Location List]"', execute('ls')) |
3930 close | 3935 close |
3931 " When the location list window is closed, the buffer name should not | 3936 " When the location list window is closed, the buffer name should not |
3932 " change to 'Quickfix List' | 3937 " change to 'Quickfix List' |
3933 call assert_match(qfbnum . ' h- "\[Location List]"', execute('ls')) | 3938 call assert_match(qfbnum . 'u h- "\[Location List]"', execute('ls!')) |
3934 call assert_true(bufloaded(qfbnum)) | 3939 call assert_true(bufloaded(qfbnum)) |
3935 | 3940 |
3936 " After deleting a location list buffer using ":bdelete", opening the | 3941 " After deleting a location list buffer using ":bdelete", opening the |
3937 " location list window should mark the buffer as a location list buffer. | 3942 " location list window should mark the buffer as a location list buffer. |
3938 exe "bdelete " . qfbnum | 3943 exe "bdelete " . qfbnum |
3945 | 3950 |
3946 " When the location list is cleared for the window, the buffer should be | 3951 " When the location list is cleared for the window, the buffer should be |
3947 " removed | 3952 " removed |
3948 call setloclist(0, [], 'f') | 3953 call setloclist(0, [], 'f') |
3949 call assert_false(bufexists(qfbnum)) | 3954 call assert_false(bufexists(qfbnum)) |
3955 call assert_equal(0, getloclist(0, {'qfbufnr' : 0}).qfbufnr) | |
3950 | 3956 |
3951 " When the location list is freed with the location list window open, the | 3957 " When the location list is freed with the location list window open, the |
3952 " location list buffer should not be lost. It should be reused when the | 3958 " location list buffer should not be lost. It should be reused when the |
3953 " location list is again populated. | 3959 " location list is again populated. |
3954 lexpr "F1:10:Line10" | 3960 lexpr "F1:10:Line10" |