Skip to content

Commit 9514fcd

Browse files
committed
fix: KiTTY session file selection dialog does not appear close #787
1 parent 32ea7a7 commit 9514fcd

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Ui/Utils/KiTTY/Model/KittyConfig.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public static List<KittyConfigKeyValuePair> Read(string path)
3737
{
3838
var para = line.Substring(0, i0);
3939
var val = line.Substring(i0 + 1).TrimEnd('\\');
40+
if (string.IsNullOrWhiteSpace(para) || string.IsNullOrWhiteSpace(val))
41+
{
42+
continue;
43+
}
4044
if (double.TryParse(val.Replace(',', '_'), out _))
4145
{
4246
ret.Add(new KittyConfigKeyValuePair() { Key = para, Value = val, ValueKind = RegistryValueKind.DWord });

Ui/View/Editor/Forms/SshFormView.xaml.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Windows.Controls;
55
using System.Windows.Data;
66
using _1RM.Model.Protocol;
7+
using _1RM.Utils;
78
using _1RM.Utils.KiTTY;
89
using _1RM.Utils.KiTTY.Model;
910
using Shawn.Utils.Wpf.FileSystem;
@@ -60,18 +61,18 @@ private void CbUsePrivateKey_OnChecked(object sender, RoutedEventArgs e)
6061

6162
private void ButtonSelectSessionConfigFile_OnClick(object sender, RoutedEventArgs e)
6263
{
63-
if (DataContext is IKittyConnectable pc)
64+
if (DataContext is SshFormViewModel vm)
6465
{
6566
var path = SelectFileHelper.OpenFile(filter: "KiTTY Session|*.*");
6667
if (path == null) return;
67-
if (File.Exists(path)
68-
&& KittyConfig.Read(path)?.Count > 0)
68+
if (File.Exists(path) && KittyConfig.Read(path)?.Count > 0)
6969
{
70-
pc.ExternalKittySessionConfigPath = path;
70+
vm.New.ExternalKittySessionConfigPath = path;
7171
}
7272
else
7373
{
74-
pc.ExternalKittySessionConfigPath = "";
74+
vm.New.ExternalKittySessionConfigPath = "";
75+
MessageBoxHelper.Warning("Invalid KiTTY session config file.");
7576
}
7677
}
7778
}

0 commit comments

Comments
 (0)