4

I have these maps in my .vsvimrc and they work as expected. I presss z followed by / or Shift+/ and comments are added.

map <z></> :vsc ReSharper.ReSharper_LineComment<CR>
map <z><?> :vsc ReSharper.ReSharper_BlockComment<CR>

These do not work.

map <z><w> :vsc ReSharper.ReSharper_ExtendSelection<CR>
map <z><W> :vsc ReSharper.ReSharper_ShrinkSelection<CR>

I have tried mapping them to various other keys (including ones that have been proven to work on other R# commands) but the selection is not being extended.

Is this possible?

Josh Buedel
  • 1,853
  • 16
  • 41
  • I saw another vsvim question with it. Seemed like a good idea. Removed. – Josh Buedel Jun 03 '14 at 20:43
  • I'm not sure the command can be run in this manner. When I open the command window and just type out ReSharper.ReSharper_ExtendSelection i get back an error "Command ReSharper.ReSharper_ExtendSelection" is not supported. – JaredPar Jun 04 '14 at 00:18
  • So there is something different about certain commands that makes them unrunnable then? I suppose I'll need to test by running them in the command window first. Thanks @JaredPar – Josh Buedel Jun 04 '14 at 03:10
  • ReSharper's actions look in a data context to find the information they can act upon. The Extend selection action looks for the current text control. When the action is called as a VS command, there isn't a data context set up, so it tries to use the currently selected UI element to build a context. If it can't find something in the UI hierarchy to build a context, the command is unavailable. – citizenmatt Jun 04 '14 at 12:08
  • @citizenmatt That makes sense as to why it does not work from the command window. That said, my expand/shrink hot keys do work in the code window. – Josh Buedel Jun 04 '14 at 15:41
  • @JaredPar Perhaps VsVim is running commands in a such a way that the selected UI element is not available to ReSharper. This seems like a bug. If you agree I'd be happy to file it. Anyway, thanks for your time guys. – Josh Buedel Jun 04 '14 at 15:42
  • @citizenmatt can you describe a bit more how ReSharper looks for the current text control? Is it looking for WPF keyboard focus or something else? At the moment the command is issued I believe keyboard focus is on a margin control and not the main editor which could be causing the disconnect – JaredPar Jun 04 '14 at 16:56
  • @citizenmatt i through a quick hack fix together which toggled the focus and that does appear to be the factor. Going to push forward with fixing that – JaredPar Jun 04 '14 at 17:21
  • Very cool, thanks for the fix. For WPF views, ReSharper is raising an event against the currently focussed UI element, which bubbles up the hierarchy. R# attaches event handlers to the text view, and that handler populates the context. For winforms, it looks for a control that implements a given interface, which can provide the context. – citizenmatt Jun 05 '14 at 07:42

1 Answers1

5

This appears to be a bug in VsVim. When executing a :vsc command the keyboard focus is on the command line editor control. ReSharper appears to use the keyboard focus to figure out which text editor is currently active. Before executing the command VsVim should be putting the focus in the correct place. I filed the following bug to track fixing it

https://github.com/jaredpar/VsVim/issues/1377

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454