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

Visual Studio for Mac crashes when opening Edit menu #156

Closed
shirshov opened this issue Aug 18, 2017 · 20 comments
Closed

Visual Studio for Mac crashes when opening Edit menu #156

shirshov opened this issue Aug 18, 2017 · 20 comments
Labels

Comments

@shirshov
Copy link
Collaborator

shirshov commented Aug 18, 2017

Every time I try to open Edit menu, Visual Studio crashes, when at least one source code file is open.
(VS version 7.2 build 487, but I don't think it matters)

It looks like the culprit is the following line:
https://github.com/nosami/XSVim/blob/7.0/XSVim/XSVim.fs#L43
It was introduced in this commit: bb69ad6. If I comment out "Control+I" then the crashes do not happen.

This could be because I manually reassigned CTRL-I to "Format Document", which is the default binding. I tried removing the binding using VS's Preferences dialog, but still got the crashes.

Side note:
I'm not convinced we should disable CTRL-I automatically. This is out-of-the-box binding to one of the most frequently used commands.

@shirshov shirshov added the bug label Aug 18, 2017
@nosami
Copy link
Owner

nosami commented Aug 20, 2017

We shouldn't disable them automatically. There should be an option on the first run to offer to disable them. I disabled them because there have been multiple comments on the issue tracker here and on stack overflow with people not knowing how to configure these (and it's not at all obvious which commands need disabling - it differs by OS for example)

What's the stack trace when it crashes?

@nosami
Copy link
Owner

nosami commented Aug 20, 2017

CTRL-I is one the most frequent vim keybinds that I use by the way. And I never use format document :)

@nosami
Copy link
Owner

nosami commented Aug 20, 2017

OK. Managed to reproduce in 7.1 build 1281 after reassigning Ctrl-I to Format Document

System.InvalidOperationException: Invalid action command id: MonoDevelop.Ide.CodeFormatting.CodeFormattingCommands.FormatBuffer
  at MonoDevelop.Components.Commands.CommandManager.GetCommandInfo (System.Object commandId, MonoDevelop.Components.Commands.CommandTargetRoute targetRoute, System.Threading.CancellationToken cancelToken) [0x001f9] in /Users/builder/data/lanes/4989/cc3abfe9/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1704
  at MonoDevelop.Components.Commands.CommandManager.GetCommandInfo (System.Object commandId, MonoDevelop.Components.Commands.CommandTargetRoute targetRoute) [0x00000] in /Users/builder/data/lanes/4989/cc3abfe9/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1594
  at MonoDevelop.Components.Mac.MDMenuItem.Update (MonoDevelop.Components.Mac.MDMenu parent, System.Int32& index) [0x00014] in /Users/builder/data/lanes/4989/cc3abfe9/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenuItem.cs:106
  at MonoDevelop.Components.Mac.MDMenu.UpdateCommands () [0x00037] in /Users/builder/data/lanes/4989/cc3abfe9/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenu.cs:150
  at MonoDevelop.Components.Mac.MDSubMenuItem.Update (MonoDevelop.Components.Mac.MDMenu parent, System.Int32& index) [0x00000] in /Users/builder/data/lanes/4989/cc3abfe9/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDSubMenuItem.cs:48
  at MonoDevelop.Components.Mac.MDMenu.UpdateCommands () [0x00037] in /Users/builder/data/lanes/4989/cc3abfe9/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenu.cs:150
  at MonoDevelop.Components.Mac.MDMenu.MenuNeedsUpdate (AppKit.NSMenu menu) [0x00019] in /Users/builder/data/lanes/4989/cc3abfe9/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenu.cs:192

@nosami
Copy link
Owner

nosami commented Aug 20, 2017

Broken in 7.2 too... but everything starts to work again as soon as you delete the <C-i> binding.

I spoke to @sevoku recently about unbinding built in keybindings and he hinted that this may be improved in the future.

We shouldn't be using CommandManager.UnregisterCommand but currently there is no other way to do it than manually rebinding each command.

@sevoku
Copy link

sevoku commented Aug 21, 2017

@nosami as a workaround you could try to unset just the binding without messing with the CommandService. Something like this:

IdeApp.CommandService.GetCommand ("MonoDevelop.Ide.CodeFormatting.CodeFormattingCommands.FormatBuffer");
KeyBindingService.CurrentKeyBindingSet.SetBinding (cmd, new string[0]);

Additionally you could enum the bindigs for that command with KeyBindingService.CurrentKeyBindingSet.GetBindings (cmd); and remove just the conflicting one.

@nosami
Copy link
Owner

nosami commented Aug 22, 2017

Thanks @sevoku! I'll try that out.

@nosami
Copy link
Owner

nosami commented Aug 23, 2017

@nosami as a workaround you could try to unset just the binding without messing with the CommandService. Something like this:

IdeApp.CommandService.GetCommand ("MonoDevelop.Ide.CodeFormatting.CodeFormattingCommands.FormatBuffer");
KeyBindingService.CurrentKeyBindingSet.SetBinding (cmd, new string[0]);

@sevoku I tried this but none of the keys that I'm attempting to override can be intercepted by the vim addin.

@mhutch
Copy link

mhutch commented Feb 28, 2018

FWIW, maybe it would be cleaner to have a keybinding set for vim instead of modifying the current one? Or maybe prompt whether the user wants to switch?

@nosami
Copy link
Owner

nosami commented Mar 1, 2018

@mhutch I'm not sure if it's possible to have a keybinding set for vim due to the many combinations of keys that can be formed to create a command.

I could make it so that the user needs to opt-in to automatic keys override though I guess.

@dnlbschff
Copy link

Hey, I'm having the same issue. However, I'm on a fresh install of VS 7.3.3 without any keybindings customised. Can I support you with any information to help sort out the problem?

@nosami
Copy link
Owner

nosami commented Mar 1, 2018

@dnlbschff Do you get the same stack trace in the log? Help -> Open Log Directory

@dnlbschff
Copy link

Pretty much. The line numbers differ slightly.

System.InvalidOperationException: Invalid action command id: MonoDevelop.Ide.CodeFormatting.CodeFormattingCommands.FormatBuffer
  at MonoDevelop.Components.Commands.CommandManager.GetCommandInfo (System.Object commandId, MonoDevelop.Components.Commands.CommandTargetRoute targetRoute, System.Threading.CancellationToken cancelToken) [0x001f9] in /Users/builder/data/lanes/5402/e02ab111/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1704 
  at MonoDevelop.Components.Commands.CommandManager.GetCommandInfo (System.Object commandId, MonoDevelop.Components.Commands.CommandTargetRoute targetRoute) [0x00000] in /Users/builder/data/lanes/5402/e02ab111/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1594 
  at MonoDevelop.Components.Mac.MDMenuItem.Update (MonoDevelop.Components.Mac.MDMenu parent, System.Int32& index) [0x00014] in /Users/builder/data/lanes/5402/e02ab111/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenuItem.cs:108 
  at MonoDevelop.Components.Mac.MDMenu.UpdateCommands () [0x00037] in /Users/builder/data/lanes/5402/e02ab111/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenu.cs:157 
  at MonoDevelop.Components.Mac.MDSubMenuItem.Update (MonoDevelop.Components.Mac.MDMenu parent, System.Int32& index) [0x00000] in /Users/builder/data/lanes/5402/e02ab111/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDSubMenuItem.cs:48 
  at MonoDevelop.Components.Mac.MDMenu.UpdateCommands () [0x00037] in /Users/builder/data/lanes/5402/e02ab111/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenu.cs:157 
  at MonoDevelop.Components.Mac.MDMenu.MenuNeedsUpdate (AppKit.NSMenu menu) [0x00019] in /Users/builder/data/lanes/5402/e02ab111/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenu.cs:199

(I really love the extension otherwise though!)

@nosami
Copy link
Owner

nosami commented Mar 1, 2018

@dnlbschff Thanks! Although I'm pretty sure that the only way to get that stack trace is if you rebind the FormatBuffer key. Maybe you did it in a previous version of VS?

For now, you can workaround it by opening the preferences dialog before you load any solution from the Welcome Page (so that this extension doesn't get chance to load) and then just delete the keybinding for Format Document

image

@dnlbschff
Copy link

Well to be precise, I had a previous installation and removed it with the uninstall script provided by Microsoft. Now I reinstalled VS and checked again. The problem persisted, which is why I posted here.

Thanks, your hint resolved the problem. I tried that with my last install and it didn't. But I also know why now: I was using the Windows keybinding set before (because I'm more familiar with that, coming from a windows machine).

So once you switch to the Windows preset, you get the error for Format Document, Redo, Cut, etc. 😄 So manually cleaning out all those conflicting keybindings, is not something I want to do right now, which is why I left the preset at the default, with the Format Document binding removed. Thanks for your support!

@nosami
Copy link
Owner

nosami commented Mar 1, 2018

Ah, I see! I'll try and come up with a solution for this soon.

@mhutch
Copy link

mhutch commented Mar 1, 2018

@nosami I didn't mean implementing it as keybindings, I meant have a keybinding set that doesn't conflict with the vim stuff.

@nosami
Copy link
Owner

nosami commented Mar 1, 2018

@mhutch - Yeah, I guess that could work for the few ctrl-key bindings that are conflicted.

@mhutch
Copy link

mhutch commented Mar 1, 2018

And you could add new bindings for those commands :)

@nosami
Copy link
Owner

nosami commented Mar 10, 2018

Just attempted to add a Vim keybinding set just for control-D to test out but I get conflicting shortcuts. No idea how to make this work.

image

nosami added a commit that referenced this issue Mar 12, 2018
Fixes #156

Create commands for all keybinds that may conflict with built in keybinding
schemes (Just Visual Studio for Mac default for now).

Also created Visual Studio + Vim keybinding scheme to set vim keys for users
that want that behaviour.
@nosami
Copy link
Owner

nosami commented Mar 19, 2018

Looks like this bug was fixed in Monodevelop itself - mono/monodevelop#4214

Should be in 7.4 service release 1.

nosami added a commit that referenced this issue May 10, 2018
Fixes #156

Create commands for all keybinds that may conflict with built in keybinding
schemes (Just Visual Studio for Mac default for now).

Also created Visual Studio + Vim keybinding scheme to set vim keys for users
that want that behaviour.
nosami added a commit that referenced this issue May 10, 2018
Fixes #156

Create commands for all keybinds that may conflict with built in keybinding
schemes (Just Visual Studio for Mac default for now).

Also created Visual Studio + Vim keybinding scheme to set vim keys for users
that want that behaviour.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants