Detecting and dismissing Intellisense from an extension

I'm the author of the VsVim extension for Visual Studio.  As part of that extension I need to interact with Intellisense in a number of scenarios.  Mostly just detecting that it is active so that I can allow key strokes to go to it vs. interpreting them as vim commands and dismissing it when i leave insert mode.  

ReSharper is causing me a bit problem because it doesn't export the standard services used for Intellisense.  In general Visual Studio 2010+ uses the ICompletionBroken interface to let extensions interact with Intellisense.  ReShaprer, at least version 7.*, doesn't export this service.  I tried probing a number of other Visual Studio interfaces that relate to Intellisense and couldn't find anything I could use to detect when ReSharper intellisense is active.  

Is there a way that an extension can detect ReSharper Intellisense is active?  

Is there a way to dismiss it besides sending <Esc> down the IOleCommandTarget for the corresponding ITextView.  That actually isn't so bad.  It feels hacky but it's a relaible way of dismissing it.  Detecting it's up in the first place is the more difficult problem.  

6 comments
Comment actions Permalink

Hi Jared. Since ReSharper's code completion has a completely different infrastructure to Visual Studio's, it doesn't integrate with the VS intellisense interfaces. There are ReSharper classes and interfaces that can notify you when a code completion window is shown and hidden, but these require linking against ReSharper - effectively being a plugin (I'm working on a sample that allows VSIXs to distribute plugins, which should make this kind of integration easier). The interface you need is ILookupWindowManager, which includes "BeforeLookupWindowShown" and "LookupWindowClosed" events. The implementation of the interface is available via IntellisenseManager.LookupWindowManager. And ReSharper's container can inject this via a constructor parameter in a plugin. You can look at these classes and interfaces by pointing dotPeek at the ReSharper bin directory and just decompiling the classes.

I'm more than happy to help out with further details, samples, or any other questions you'd have - we're keen to integrate well with VsVim.

0
Comment actions Permalink

ILookupWindowManager definitely seems to be the interface that I'm after and a VSIX distribution story would be ideal for me.  Can you post back when you have the VSIX sample avaliable?  I had some rough ideas on how to construct one based on the documentation but they all seemed a bit hacky.  I'm sure i'm missing a better way to do it.

Thanks!

0
Comment actions Permalink

Will do, I'll get it brushed up this week. What version(s) of ReSharper are you targetting?

0
Comment actions Permalink

My immediate concern is cleaning up the interaction with R# 8.0.  The solution I have works but it could be made a lot better if I interact directly with the R# APIs.  It would take a bit of the guess work out.  

Once I get that handled I may step backwards and try to do the same for 7.X as well

0
Comment actions Permalink

I've just pushed the source of my VSIX integration project to GitHub: https://github.com/JetBrains/resharper-vsix

It's actually two projects - one will load a VSIX that's bundled inside a ReSharper extension, and the other (which is more applicable for VsVim) loads a ReSharper extension from a VSIX.

It's at about alpha quality - it works, but it's still got a few rough edges. There's no sample yet. Unfortunately, my test project was way too messy to push - I'll do that on Monday. But there's a big old readme that should explain what's going on.

I'd appreciate any feedback, especially on the API and if there are better ways of handling the initial wiring up (MEF vs packages and services).

Thanks
Matt

0
Comment actions Permalink

Thanks for taking the time to put up those samples.  I'm taking a look at them now.  

0

Please sign in to leave a comment.