diff --git a/VSDebugCoreLib/Commands/UI/ConsoleCommand.cs b/VSDebugCoreLib/Commands/UI/ConsoleCommand.cs index af021ea..3654555 100644 --- a/VSDebugCoreLib/Commands/UI/ConsoleCommand.cs +++ b/VSDebugCoreLib/Commands/UI/ConsoleCommand.cs @@ -1,6 +1,7 @@ using System; using Microsoft.VisualStudio; using Microsoft.VisualStudio.Shell.Interop; +using VSDebugCoreLib.Console; using VSDebugCoreLib.UI.Tools; namespace VSDebugCoreLib.Commands.UI @@ -19,6 +20,15 @@ public override void MenuCallback(object sender, EventArgs e) // The last flag is set to true so that if the tool window does not exists it will be created. var window = Context.PACKAGE.FindToolWindow(typeof(ConsoleWindow), 0, true); if (null == window || null == window.Frame) throw new NotSupportedException(Resources.CanNotCreateWindow); + + var console = (ConsoleWindow)window; + + console.LoadHistory(Context.SettingsManager.VSDSettings.CmdHistory); + console.Engine = Context.ConsoleEngine; + console.Context = Context; + + Context.Console = console; + var windowFrame = (IVsWindowFrame) window.Frame; ErrorHandler.ThrowOnFailure(windowFrame.Show()); } diff --git a/VSDebugCoreLib/VSDebugCore.cs b/VSDebugCoreLib/VSDebugCore.cs index bad23db..50f02fe 100644 --- a/VSDebugCoreLib/VSDebugCore.cs +++ b/VSDebugCoreLib/VSDebugCore.cs @@ -32,11 +32,6 @@ public class VSDebugContext /// private readonly ICollection _commands = new List(); - /// - /// VS console window. - /// - private ConsoleWindow _console; - /// /// VSDebugTool console engine. /// @@ -67,7 +62,7 @@ public VSDebugContext(Package package, Assembly assembly) public ConsoleEngine ConsoleEngine => _consoleEngine; - public ConsoleWindow Console => _console; + public ConsoleWindow Console { get; set; } /// /// VS IDE that is executing this context. @@ -102,7 +97,7 @@ public void Initialize() InitSettings(); // Initialize console window - InitConsoleTool(); + InitConsoleEngine(); // Register commands InitCommands(); @@ -122,20 +117,9 @@ private void InitSettings() _settingsManager.LoadSettings(); } - private void InitConsoleTool() - { - var consoleWnd = PACKAGE.FindToolWindow(typeof(ConsoleWindow), 0, true); - if (null == consoleWnd || null == consoleWnd.Frame) - throw new NotSupportedException(Resources.CanNotCreateWindow); - - _console = (ConsoleWindow) consoleWnd; - - _console.LoadHistory(_settingsManager.VSDSettings.CmdHistory); - + private void InitConsoleEngine() + { _consoleEngine = new ConsoleEngine(this, _commands); - - _console.Engine = _consoleEngine; - _console.Context = this; } private void RegisterBaseCommand(BaseCommand cmd) diff --git a/VSDebugProPackage.cs b/VSDebugProPackage.cs index 8bf2503..a5288f0 100644 --- a/VSDebugProPackage.cs +++ b/VSDebugProPackage.cs @@ -15,7 +15,6 @@ namespace VSDebugPro { [PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] // This attribute is used to register the information needed to show this context - [ProvideAutoLoad("1336C085-E903-4333-BF29-7D4DF860DF9F")] // Force auto load [ProvideToolWindow(typeof(ConsoleWindow))] // console window [ProvideMenuResource("Menus.ctmenu", 1)] [Guid(GuidList.GuidVSDebugProPkgString)]