Skip to content

Commit

Permalink
Fix ConsoleWindow init in vs17.12
Browse files Browse the repository at this point in the history
  • Loading branch information
ovidiuvio committed Nov 14, 2024
1 parent 21075f0 commit 994f873
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
10 changes: 10 additions & 0 deletions VSDebugCoreLib/Commands/UI/ConsoleCommand.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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());
}
Expand Down
24 changes: 4 additions & 20 deletions VSDebugCoreLib/VSDebugCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ public class VSDebugContext
/// </summary>
private readonly ICollection<BaseCommand> _commands = new List<BaseCommand>();

/// <summary>
/// VS console window.
/// </summary>
private ConsoleWindow _console;

/// <summary>
/// VSDebugTool console engine.
/// </summary>
Expand Down Expand Up @@ -67,7 +62,7 @@ public VSDebugContext(Package package, Assembly assembly)

public ConsoleEngine ConsoleEngine => _consoleEngine;

public ConsoleWindow Console => _console;
public ConsoleWindow Console { get; set; }

/// <summary>
/// VS IDE that is executing this context.
Expand Down Expand Up @@ -102,7 +97,7 @@ public void Initialize()
InitSettings();

// Initialize console window
InitConsoleTool();
InitConsoleEngine();

// Register commands
InitCommands();
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion VSDebugProPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 994f873

Please sign in to comment.