Hi Gary,
On 4/27/07, Gary Johnson <[EMAIL PROTECTED]> wrote:
On 2007-04-27, Gary Johnson <[EMAIL PROTECTED]> wrote:
> On 2007-04-26, Navdeep Parhar <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > Currently :cscope has a variant :lcscope that allows the use of
> > the location list instead of the quickfix list. However, :scscope
> > has no equivalent that uses the location list. Please note that
> > :scs splits only if cscope returns some results, so :scs is not
> > the same as ":split cs". Due to this reason ":split lcscope" can
> > not be used to get the same behaviour as the proposed :lscscope.
> >
I'm confused. I tried exercising this patch and I'm not getting the
results I expect, but I don't know if it's the patch, the behavior
of location lists, or me.
This problem is caused by the patch for the ":lscs" command.
When the ":lcs" command is executed, a new location list is
created for the current window and then the cursor is moved to the
first entry in the location list.
The ":lscs" command splits the window after the location list is
created. This results in the problem.
In your case, when you executed the ":lscs" command in the
first window, the new location list is added to the first window
and then the window is split.
When you invoked the second "lscs" command, a new location
list is added to the second window and then the window is split.
Also, when jumping to the match from the location list, the
location list for the window before the split is used. This results
in the second problem you saw after closing the windows.
When the location list support was added to Vim7, as the ":lscscope"
command was not supported, this condition was not taken into
account.
- Yegappan
Here's an example. I cd'd to the src directory of my vim
installation which is currently at patch level 208. Then I built a
cscope database.
$ cscope -b
Then I opened one of the source files,
$ view +3725 buffer.c
added the cscope database,
:cs add cscope.out
moved the cursor to the get_fileformat symbol and opened a new
window containing a location list of the places where that function
is called.
:lscscope find c ^R^W
(1 of 10): <<build_stl_str_hl>> else if (num == CAR &&
get_fileformat(wp->w_buffer) == EOL_MAC)
That happens to be the same line in buffer.c that the cursor had
been on. Then I went to the third location in the list,
:3ll
(3 of 10): <<readfile>> fileformat = get_fileformat(curbuf);
which is line 925 of fileio.c. I moved the cursor to the top of
this function, readfile (line 209), and opened a new window
containing a location list of the places where this function is
called.
:lscscope find c ^R^W
(1 of 12): <<open_buffer>> retval = readfile(curbuf->b_ffname,
curbuf->b_fname,
This window contains buffer.c, which is also being viewed in the
bottom window. The location list is new. We can check the location
list stack state as follows:
:lold
error list 1 of 2; 10 errors
:lnew
error list 2 of 2; 12 errors
Then I went to the 5th location in this list.
:5ll
(5 of 12): <<do_filter>> if (readfile(otmp, NULL, line2, (linenr_T)0,
(linenr_T)MAXLNUM,
This is line 1209 of ex_cmds.c.
At this point, I wanted to stop following this location list, close
this window and return to the place where I executed the :lscscope
command, then pick up where I was in the first location list.
:q
This closed the top window and made the second window "active" with
the cursor on the first line of the readline() function. So far so
good. When I left this window, I had been at location 3 of 10 in
the first location list. Therefore, I expected that executing :ll
would put the cursor back on line 925 of this file, fileio.c.
:ll
(1 of 12): <<open_buffer>> retval = readfile(curbuf->b_ffname,
curbuf->b_fname,
Not only did the :ll command use the "wrong" (i.e., unexpected)
location list, but it jumped to the first location in that list
instead of the last location used, which was number 5. Checking the
location list stack state,
:lold
error list 1 of 2; 10 errors
:lnew
error list 2 of 2; 12 errors
shows that there are still two location lists. I would have
expected that closing that top window would have deleted the newest
list.
So is this a bug, or am I just not getting it?