diff options
author | Lluis Sanchez <llsan@microsoft.com> | 2017-06-26 18:39:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-26 18:39:07 +0300 |
commit | 40b07ef4a19c345b534c0528692ec4b153388659 (patch) | |
tree | c59cdd6b2a958a091b71f8e1b1ea998b5c6a48f8 | |
parent | fd1c6052c022ad0c35a02baa7bcd20f59818eaf4 (diff) | |
parent | 8780d08998187ad8c34ff8751b59af88507bbbd5 (diff) |
Merge pull request #2679 from mono/fix-57704-d15-3
Fix quick fix menu load issue
-rw-r--r-- | main/src/addins/CSharpBinding/CSharpBinding.addin.xml | 6 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/QuickFixMenuHandler.cs | 29 |
2 files changed, 17 insertions, 18 deletions
diff --git a/main/src/addins/CSharpBinding/CSharpBinding.addin.xml b/main/src/addins/CSharpBinding/CSharpBinding.addin.xml index 522691b240..75a1ce00fa 100644 --- a/main/src/addins/CSharpBinding/CSharpBinding.addin.xml +++ b/main/src/addins/CSharpBinding/CSharpBinding.addin.xml @@ -289,8 +289,10 @@ <Extension path = "/MonoDevelop/SourceEditor2/ContextMenu/Editor"> <Condition id="FileType" mimeTypes="text/x-csharp"> - <CommandItem id = "MonoDevelop.Refactoring.RefactoryCommands.QuickFixMenu" insertafter="MonoDevelop.SourceEditor.SourceEditorCommands.MarkerOperations" insertbefore="MonoDevelop.Debugger.DebugCommands.ExpressionEvaluator"/> - <CommandItem id = "MonoDevelop.Refactoring.RefactoryCommands.CurrentRefactoryOperations" insertafter="MonoDevelop.SourceEditor.SourceEditorCommands.MarkerOperations" insertbefore="MonoDevelop.Debugger.DebugCommands.ExpressionEvaluator"/> + <ItemSet id = "MonoDevelop.Refactoring.RefactoryCommands.QuickFixMenu" _label = "Quick Fix" autohide = "true" insertafter="MonoDevelop.SourceEditor.SourceEditorCommands.MarkerOperations" insertbefore="MonoDevelop.Debugger.DebugCommands.ExpressionEvaluator"> + <CommandItem id = "MonoDevelop.Refactoring.RefactoryCommands.QuickFixMenu" /> + </ItemSet> + <CommandItem id = "MonoDevelop.Refactoring.RefactoryCommands.CurrentRefactoryOperations" /> <ItemSet id = "Navigate" _label = "Navigate"> <CommandItem id = "MonoDevelop.Refactoring.RefactoryCommands.FindAllReferences"/> diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/QuickFixMenuHandler.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/QuickFixMenuHandler.cs index b9459acfc4..666ae3d01e 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/QuickFixMenuHandler.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/QuickFixMenuHandler.cs @@ -41,27 +41,24 @@ namespace MonoDevelop.Refactoring var ext = editor?.GetContent<CodeActionEditorExtension> (); if (ext == null) return; - var quickFixMenu = new CommandInfoSet (); - quickFixMenu.Text = GettextCatalog.GetString ("Quick Fix"); - quickFixMenu.CommandInfos.Add (new CommandInfo (GettextCatalog.GetString ("Loading..."), false, false), null); - info.Add (quickFixMenu); try { + info.Add (new CommandInfo (GettextCatalog.GetString ("Loading..."), false, false), null); var currentFixes = await ext.GetCurrentFixesAsync (cancelToken); var menu = await CodeFixMenuService.CreateFixMenu (editor, currentFixes, cancelToken); - quickFixMenu.CommandInfos.Clear (); + info.Clear (); foreach (var item in menu.Items) { - AddItem (quickFixMenu, item); + AddItem (info, item); } if (menu.Items.Count == 0) { - quickFixMenu.CommandInfos.Add (new CommandInfo (GettextCatalog.GetString ("No code fixes available"), false, false), null); + info.Add (new CommandInfo (GettextCatalog.GetString ("No code fixes available"), false, false), null); } info.NotifyChanged (); } catch (OperationCanceledException) { } catch (Exception e) { LoggingService.LogError ("Error while creating quick fix menu.", e); - quickFixMenu.CommandInfos.Clear (); - quickFixMenu.CommandInfos.Add (new CommandInfo (GettextCatalog.GetString ("No code fixes available"), false, false), null); + info.Clear (); + info.Add (new CommandInfo (GettextCatalog.GetString ("No code fixes available"), false, false), null); info.NotifyChanged (); } } @@ -71,28 +68,28 @@ namespace MonoDevelop.Refactoring var cis = new CommandInfoSet (); cis.Text = menu.Label; foreach (var item in menu.Items) { - AddItem (cis, item); + AddItem (cis.CommandInfos, item); } return cis; } - void AddItem (CommandInfoSet cis, CodeFixMenuEntry item) + void AddItem (CommandArrayInfo cis, CodeFixMenuEntry item) { if (item == CodeFixMenuEntry.Separator) { - if (cis.CommandInfos.Count == 0) + if (cis.Count == 0) return; - cis.CommandInfos.AddSeparator (); + cis.AddSeparator (); } else if (item is CodeFixMenu) { var menu = (CodeFixMenu)item; var submenu = new CommandInfoSet { Text = menu.Label }; foreach (var subItem in menu.Items) { - AddItem (submenu, subItem); + AddItem (submenu.CommandInfos, subItem); } - cis.CommandInfos.Add (submenu, item.Action); + cis.Add (submenu, item.Action); } else { - cis.CommandInfos.Add (new CommandInfo (item.Label), item.Action); + cis.Add (new CommandInfo (item.Label), item.Action); } } |