Open adamors opened 10 years ago
Confirmed
it's likely that the pattern to match namespace lines also match trait use line(more often just the cursor line), thus imports exists. I found that an easy solution is not to match the whole file, instead from the first line to the line above the current, just found the plugin/phpns.vim and change as following
function! s:searchCapture(pattern, nr)
let s:capture = 0
let str = join(getline(0, line('$')),"\n")
let haha = substitute(str, a:pattern, '\=[submatch(0), s:saveCapture(submatch('.a:nr.'))][0]', 'e')
return s:capture
endfunction```
let str = join(getline(0, line('$')),"\n")
let str = join(getline(0, line('.')-1),"\n")
One small bug I noticed:
if I'm using multiple traits in a class like this:
I cannot import the namespace for the second trait. It says that import already exists. The first one gets imported correctly, it doesn't matter if I try to import the first or the last trait's namespace.
If I have just one
use
statement per line, I can import all of them:This second example works without any issues.
Thanks for doing this plugin, I use it daily. If I new VimL I'd contribute :(