Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to import multiple traits fails if they're on the same line #13

Open
adamors opened this issue May 27, 2014 · 2 comments
Open

Trying to import multiple traits fails if they're on the same line #13

adamors opened this issue May 27, 2014 · 2 comments

Comments

@adamors
Copy link

adamors commented May 27, 2014

One small bug I noticed:

if I'm using multiple traits in a class like this:

class Foo {
    use BarTrait, FoobarTrait;
}

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:

class Foo {
    use BarTrait;
    use FoobarTrait;
}

This second example works without any issues.

Thanks for doing this plugin, I use it daily. If I new VimL I'd contribute :(

@arnaud-lb
Copy link
Owner

Confirmed

@feistiny
Copy link

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")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants