bogado / file-line

Plugin for vim to enabling opening a file in a given line
http://www.vim.org/scripts/script.php?script_id=2184
299 stars 61 forks source link

How to support "file:line:garbage"? #14

Closed omnium21 closed 10 years ago

omnium21 commented 10 years ago

When I grep for some source, I might get output like this:

arch/arm/include/asm/fiq.h:37:extern void release_fiq(struct fiq_handler *f);
arch/arm/include/asm/fiq.h:38:extern void set_fiq_handler(void *start, unsigned int length);
arch/arm/include/asm/fiq.h:39:extern void enable_fiq(int fiq);

Double clicking will give me the extra "extern" (or some other text) after the : where file_line expects a column number.

I've tried to decypher the matchlist expression, but I cannot work out how to make it pass when "garbage" is passed instead of a column number.

Also keep in mind, at least in C, some of the lines might also have things like # in them:

arch/arm/include/asm/tlbflush.h:13:#ifdef CONFIG_MMU

Is it possible to parse this and discard the garbage?

blueyed commented 10 years ago

That should be possible.

In your case, just removing the $ at the end of the pattern should work:

let names =  matchlist( file, '\(.\{-1,}\):\%(\(\d\+\)\%(:\(\d*\):\?\)\?\)\?')

(the $ anchors the pattern to the end of the string)

While at it, I would like to have it support /path/to/file.py(27) also - which is used with Python's ipdb for example.

omnium21 commented 10 years ago

Thanks! Yes, removing the $ works great

bogado commented 10 years ago

This should be working now.