diff options
author | James McCoy <jamessan@jamessan.com> | 2016-11-15 13:41:01 -0500 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2016-12-28 14:57:38 -0500 |
commit | 4453aa0d29d7a4e488a4c1799c9d33bcbde432eb (patch) | |
tree | 51433dcc609844f2afef9277483afcae548fd781 | |
parent | 6205846cd969bf6bafc933cb295c4cef819b9e84 (diff) | |
download | rneovim-4453aa0d29d7a4e488a4c1799c9d33bcbde432eb.tar.gz rneovim-4453aa0d29d7a4e488a4c1799c9d33bcbde432eb.tar.bz2 rneovim-4453aa0d29d7a4e488a4c1799c9d33bcbde432eb.zip |
vim-patch:7.4.2215
Problem: It's not easy to find out if a window is a quickfix or location
list window.
Solution: Add "loclist" and "quickfix" entries to the dict returnec by
getwininfo(). (Yegappan Lakshmanan)
https://github.com/vim/vim/commit/386600f0cbcb8add099c723cf84634f46df2f788
-rw-r--r-- | runtime/doc/eval.txt | 18 | ||||
-rw-r--r-- | src/nvim/eval.c | 5 | ||||
-rw-r--r-- | src/nvim/testdir/test_bufwintabinfo.vim | 45 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
4 files changed, 61 insertions, 9 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 9e08c64de9..3bf13dfc34 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4166,14 +4166,16 @@ getwininfo([{winid}]) *getwininfo()* pages is returned. Each List item is a Dictionary with the following entries: - nr window number. - tpnr tab page number. - winid window ID. - height window height. - width window width. - bufnum number of buffer in the window. - options dictionary of window local options. - variables dictionary of window local variables. + bufnum number of buffer in the window + height window height + loclist 1 if showing a location list + nr window number + options dictionary of window local options + quickfix 1 if quickfix or location list window + tpnr tab page number + variables dictionary of window local variables + width window width + winid window ID getwinvar({winnr}, {varname} [, {def}]) *getwinvar()* Like |gettabwinvar()| for the current tabpage. diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 91f7233a21..a59bfca2a5 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10905,6 +10905,11 @@ static dict_T *get_win_info(win_T *wp, short tpnr, short winnr) dict_add_nr_str(dict, "width", wp->w_width, NULL); dict_add_nr_str(dict, "bufnum", wp->w_buffer->b_fnum, NULL); + dict_add_nr_str(dict, "quickfix", bt_quickfix(wp->w_buffer), NULL); + dict_add_nr_str(dict, "loclist", + (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL), + NULL); + // Copy window variables dict_T *vars = dict_copy(NULL, wp->w_vars, true, 0); if (vars != NULL) { diff --git a/src/nvim/testdir/test_bufwintabinfo.vim b/src/nvim/testdir/test_bufwintabinfo.vim index 236ca30f99..fa9d97bc85 100644 --- a/src/nvim/testdir/test_bufwintabinfo.vim +++ b/src/nvim/testdir/test_bufwintabinfo.vim @@ -14,6 +14,27 @@ function Test_getbufwintabinfo() hide enew call assert_equal(3, len(getbufinfo({'bufloaded':1}))) + set tabstop&vim + let b:editor = 'vim' + let l = getbufinfo('%') + call assert_equal(bufnr('%'), l[0].nr) + call assert_equal(8, l[0].options.tabstop) + call assert_equal('vim', l[0].variables.editor) + call assert_notequal(-1, index(l[0].windows, bufwinid('%'))) + + if has('signs') + call append(0, ['Linux', 'Windows', 'Mac']) + sign define Mark text=>> texthl=Search + exe "sign place 2 line=3 name=Mark buffer=" . bufnr('%') + let l = getbufinfo('%') + call assert_equal(2, l[0].signs[0].id) + call assert_equal(3, l[0].signs[0].lnum) + call assert_equal('Mark', l[0].signs[0].name) + sign unplace * + sign undefine Mark + enew! + endif + only let w1_id = win_getid() new @@ -21,18 +42,42 @@ function Test_getbufwintabinfo() tabnew | let w3_id = win_getid() new | let w4_id = win_getid() new | let w5_id = win_getid() + call setwinvar(0, 'signal', 'green') tabfirst let winlist = getwininfo() call assert_equal(5, len(winlist)) + call assert_equal(winbufnr(2), winlist[1].bufnum) + call assert_equal(winheight(2), winlist[1].height) + call assert_equal(1, winlist[2].nr) + call assert_equal('auto', winlist[0].options.signcolumn) call assert_equal(2, winlist[3].tpnr) + call assert_equal('green', winlist[2].variables.signal) + call assert_equal(winwidth(1), winlist[0].width) + call assert_equal(w4_id, winlist[3].winid) let winfo = getwininfo(w5_id)[0] call assert_equal(2, winfo.tpnr) call assert_equal([], getwininfo(3)) + call settabvar(1, 'space', 'build') let tablist = gettabinfo() call assert_equal(2, len(tablist)) call assert_equal(3, len(tablist[1].windows)) + call assert_equal(2, tablist[1].nr) + call assert_equal('build', tablist[0].variables.space) + call assert_equal(w2_id, tablist[0].windows[0]) call assert_equal([], gettabinfo(3)) tabonly | only + + lexpr '' + lopen + copen + let winlist = getwininfo() + call assert_false(winlist[0].quickfix) + call assert_false(winlist[0].loclist) + call assert_true(winlist[1].quickfix) + call assert_true(winlist[1].loclist) + call assert_true(winlist[2].quickfix) + call assert_false(winlist[2].loclist) + wincmd t | only endfunction diff --git a/src/nvim/version.c b/src/nvim/version.c index b1bb9f02f4..8e9f7938cc 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -225,7 +225,7 @@ static int included_patches[] = { // 2218 NA 2217, // 2216 NA - // 2215, + 2215, // 2214 NA 2213, 2212, |