Fix completion for third-party packages (fixes #456)

I'm waiting for feedback from @courtf but so far in my tests it seems to be working ok.