Skip to content

Commit

Permalink
Fixing a bug with mosh links. (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
peske authored and felixse committed Jun 16, 2019
1 parent 8ec0d58 commit 94855b7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
2 changes: 0 additions & 2 deletions FluentTerminal.App/Dialogs/SshInfoDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public SshInfoDialog(ISettingsService settingsService, ISshHelperService sshHelp
{
TerminalThemes.Add(theme);
}


}

private void SetupFocus()
Expand Down
4 changes: 3 additions & 1 deletion FluentTerminal.App/Services/SshHelperService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public ISshConnectionInfo ParseSsh(Uri uri)
if (match.Success)
{
vm.MoshPortFrom = ushort.Parse(match.Groups["from"].Value);
vm.MoshPortFrom = ushort.Parse(match.Groups["to"].Value);
vm.MoshPortTo = ushort.Parse(match.Groups["to"].Value);
}

continue;
Expand Down Expand Up @@ -235,6 +235,8 @@ public string ConvertToUri(ISshConnectionInfo sshConnectionInfo)
sb.Append(sshConnectionInfoVm.SshPort.ToString("#####"));
}

sb.Append("/");

bool queryStringAdded = false;

if (sshConnectionInfoVm.UseMosh)
Expand Down
8 changes: 4 additions & 4 deletions FluentTerminal.Models/ShellProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ public virtual bool EqualTo(ShellProfile other)

return other.Id.Equals(Id)
&& other.PreInstalled.Equals(PreInstalled)
&& other.Name.Equals(Name)
&& other.Arguments.Equals(Arguments)
&& other.Location.Equals(Location)
&& other.WorkingDirectory.Equals(WorkingDirectory)
&& other.Name.NullableEqualTo(Name)
&& other.Arguments.NullableEqualTo(Arguments)
&& other.Location.NullableEqualTo(Location)
&& other.WorkingDirectory.NullableEqualTo(WorkingDirectory)
&& other.TabThemeId.Equals(TabThemeId)
&& other.TerminalThemeId.Equals(TerminalThemeId)
&& other.LineEndingTranslation == LineEndingTranslation
Expand Down
9 changes: 4 additions & 5 deletions FluentTerminal.Models/SshProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@ public override bool EqualTo(ShellProfile other)
return true;
}

return string.Equals(otherSsh.Host, Host)
return otherSsh.Host.NullableEqualTo(Host)
&& otherSsh.SshPort.Equals(SshPort)
&& string.Equals(otherSsh.Username, Username)
&& (string.IsNullOrEmpty(IdentityFile)
? string.IsNullOrEmpty(otherSsh.IdentityFile)
: string.Equals(otherSsh.IdentityFile, IdentityFile)) && otherSsh.UseMosh.Equals(UseMosh)
&& otherSsh.Username.NullableEqualTo(Username)
&& otherSsh.IdentityFile.NullableEqualTo(IdentityFile)
&& otherSsh.UseMosh.Equals(UseMosh)
&& otherSsh.MoshPortFrom.Equals(MoshPortFrom)
&& otherSsh.MoshPortTo.Equals(MoshPortTo);
}
Expand Down
12 changes: 12 additions & 0 deletions FluentTerminal.Models/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace FluentTerminal.Models
{
public static class StringExtensions
{
/// <summary>
/// Compares two strings for equality, but assumes that null string is equal to an empty string.
/// </summary>
public static bool NullableEqualTo(this string original, string other) => string.IsNullOrEmpty(original)
? string.IsNullOrEmpty(other)
: original.Equals(other);
}
}

0 comments on commit 94855b7

Please sign in to comment.