Hi all,
On Thu, Jul 13, 2017 at 7:30 AM, Daniel Hahler
<[email protected]> wrote:
> Thank you, Yegappan.
>
> My use case is displaying info in the statusline, e.g. the count of items -
> and I've noticed that it makes sense to cache it, since getloclist() seems
> to be rather slow on large (2k items) lists.
>
> There should probably be a better way, e.g. an API to get just the count of
> items (instead of using len(getloclist(0)), but this simple patch is good to
> have already.
>
I am attaching a patch that implements this along with doc update and
a test.
- Yegappan
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index 0ca52aa06..e555451b5 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -425,7 +425,9 @@ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR
LOCATION LIST:
which will indicate the command that produced the
quickfix list. This can be used to compose a custom
status line if the value of 'statusline' is adjusted
- properly.
+ properly. Whenever this buffer is modified by a
+ quickfix command or function, the |b:changedtick|
+ variable is incremented.
*:lop* *:lopen*
:lop[en] [height] Open a window to show the location list for the
diff --git a/src/quickfix.c b/src/quickfix.c
index 3889a9565..320d46ea6 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -3289,6 +3289,7 @@ qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
qf_update_win_titlevar(qi);
qf_fill_buffer(qi, buf, old_last);
+ ++CHANGEDTICK(buf);
if (old_last == NULL)
{
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index b3cc6891a..4dbb64e6e 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -2263,3 +2263,28 @@ func Test_resize_from_copen()
augroup! QF_Test
endtry
endfunc
+
+" Tests for the quickfix buffer b:changedtick variable
+func Xchangedtick_tests(cchar)
+ call s:setup_commands(a:cchar)
+
+ new | only
+
+ Xexpr "" | Xexpr "" | Xexpr ""
+
+ Xopen
+ Xolder
+ Xolder
+ Xaddexpr "F1:10:Line10"
+ Xaddexpr "F2:20:Line20"
+ call g:Xsetlist([{"filename":"F3", "lnum":30, "text":"Line30"}], 'a')
+ call g:Xsetlist([], 'f')
+ let cur_count = getbufvar('%', 'changedtick')
+ call assert_equal(8, cur_count)
+ Xclose
+endfunc
+
+func Test_changedtick()
+ call Xchangedtick_tests('c')
+ call Xchangedtick_tests('l')
+endfunc