Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,11 @@ public void UpdateQuery_WhenQueryIsWhitespace_ResetsCommand()
fallback.UpdateQuery(" ");

// Assert
Assert.AreEqual(Resources.remotedesktop_command_open, fallback.Title);
Assert.AreEqual(string.Empty, fallback.Title);
Assert.AreEqual(string.Empty, fallback.Subtitle);

var command = fallback.Command as OpenRemoteDesktopCommand;
Assert.IsNotNull(command);
Assert.AreEqual(Resources.remotedesktop_command_open, command.Name);
Assert.AreEqual(string.Empty, GetCommandHost(command));
Assert.IsNull(command);
}

[TestMethod]
Expand All @@ -93,13 +91,11 @@ public void UpdateQuery_WhenQueryIsInvalidHost_ClearsCommand()
fallback.UpdateQuery("not a valid host");

// Assert
Assert.AreEqual(Resources.remotedesktop_command_open, fallback.Title);
Assert.AreEqual(string.Empty, fallback.Title);
Assert.AreEqual(string.Empty, fallback.Subtitle);

var command = fallback.Command as OpenRemoteDesktopCommand;
Assert.IsNotNull(command);
Assert.AreEqual(Resources.remotedesktop_command_open, command.Name);
Assert.AreEqual(string.Empty, GetCommandHost(command));
Assert.IsNull(command);
}

private static string GetCommandHost(OpenRemoteDesktopCommand command)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ internal sealed partial class FallbackRemoteDesktopItem : FallbackCommandItem
];

private static readonly CompositeFormat RemoteDesktopOpenHostFormat = CompositeFormat.Parse(Resources.remotedesktop_open_host);

private readonly IRdpConnectionsManager _rdpConnectionsManager;
private readonly NoOpCommand _emptyCommand = new NoOpCommand();

public FallbackRemoteDesktopItem(IRdpConnectionsManager rdpConnectionsManager)
: base(new OpenRemoteDesktopCommand(string.Empty), Resources.remotedesktop_title)
: base(Resources.remotedesktop_title)
{
_rdpConnectionsManager = rdpConnectionsManager;

Command = _emptyCommand;
Title = string.Empty;
Subtitle = string.Empty;
Icon = Icons.RDPIcon;
Expand All @@ -41,7 +44,7 @@ public override void UpdateQuery(string query)
{
Title = string.Empty;
Subtitle = string.Empty;
Command = new OpenRemoteDesktopCommand(string.Empty);
Command = _emptyCommand;
return;
}

Expand All @@ -68,7 +71,7 @@ public override void UpdateQuery(string query)
{
Title = string.Empty;
Subtitle = string.Empty;
Command = new OpenRemoteDesktopCommand(string.Empty);
Command = _emptyCommand;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ICommandResult Invoke(object sender)
{
using var process = new Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.WorkingDirectory = Environment.SpecialFolder.MyDocuments.ToString();
process.StartInfo.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
process.StartInfo.FileName = "mstsc";

if (!string.IsNullOrWhiteSpace(_rdpHost))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;

public partial class FallbackCommandItem : CommandItem, IFallbackCommandItem, IFallbackHandler
{
private IFallbackHandler? _fallbackHandler;
private readonly IFallbackHandler? _fallbackHandler;

public FallbackCommandItem(string displayTitle)
{
DisplayTitle = displayTitle;
}

public FallbackCommandItem(ICommand command, string displayTitle)
: base(command)
Expand Down