From d2804a0ee4e47d7d66506fc90c3687c204896ae0 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sat, 13 Feb 2021 14:41:49 +1100 Subject: [PATCH 1/2] fix launch session issue --- Flow.Launcher.Plugin.Putty/Plugin.cs | 48 ++++++++++++++++---------- Flow.Launcher.Plugin.Putty/plugin.json | 2 +- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/Flow.Launcher.Plugin.Putty/Plugin.cs b/Flow.Launcher.Plugin.Putty/Plugin.cs index 996ab65..4ad012f 100644 --- a/Flow.Launcher.Plugin.Putty/Plugin.cs +++ b/Flow.Launcher.Plugin.Putty/Plugin.cs @@ -124,26 +124,33 @@ private void SetupPutty() /// The filtered Putty session list public List Query(Query query) { - var results = new List { }; + var results = new List(); if (settings.AddPuttyExeToResults) - { results.Add(CreateResult()); - } + var querySearch = query.Search; if (string.IsNullOrEmpty(querySearch)) { - if (settings.AddPuttyExeToResults) - { - return results; - } - else - { - querySearch = string.Empty; - } + var allPuttySessions = + PuttySessionService + .GetAll() + .Select(x => CreateResult(x.Identifier, x.ToString())); + + return results.Concat(allPuttySessions).ToList(); + } + + var puttySessions = + PuttySessionService.GetAll() + .Where(session => session.Identifier.ToLowerInvariant().Contains(querySearch.ToLowerInvariant())); + + if (!puttySessions.Any()) + { + results.Add(CreateResult(querySearch, $"Start session: {querySearch}", 60)); + + return results; } - var puttySessions = PuttySessionService.GetAll().Where(session => session.Identifier.ToLowerInvariant().Contains(querySearch.ToLowerInvariant())); foreach (var puttySession in puttySessions) { results.Add(CreateResult(puttySession.Identifier, puttySession.ToString())); @@ -158,14 +165,15 @@ public List Query(Query query) /// /// /// A Result object containing the PuttySession identifier and its connection string - private Result CreateResult(string title = "putty.exe", string subTitle = "Launch Clean Putty") + private Result CreateResult(string title = "putty.exe", string subTitle = "Open Putty", int score = 50) { return new Result { Title = title, SubTitle = subTitle, IcoPath = "icon.png", - Action = context => LaunchPuttySession(title), + Action = context => title != "putty.exe" ? LaunchPuttySession(title) : LaunchPuttySession(string.Empty),//load Putty instead, + Score = score }; } @@ -178,15 +186,17 @@ private bool LaunchPuttySession(string sessionIdentifier) { try { - string PuttyPath = "putty.exe"; - if(!string.IsNullOrEmpty(settings.PuttyPath)) - PuttyPath = settings.PuttyPath; - var p = new Process { StartInfo = { FileName = PuttyPath } }; + var puttyPath = settings.PuttyPath; + + if (string.IsNullOrEmpty(settings.PuttyPath)) + puttyPath = "putty.exe"; + + var p = new Process { StartInfo = { FileName = puttyPath } }; // Optionally pass the session identifier if (!string.IsNullOrEmpty(sessionIdentifier)) { - p.StartInfo.Arguments = "-load \"" + sessionIdentifier + "\""; + p.StartInfo.Arguments = "-ssh \"" + sessionIdentifier + "\""; } if (settings.AlwaysStartsSessionMaximized) diff --git a/Flow.Launcher.Plugin.Putty/plugin.json b/Flow.Launcher.Plugin.Putty/plugin.json index 41671bf..83708e6 100644 --- a/Flow.Launcher.Plugin.Putty/plugin.json +++ b/Flow.Launcher.Plugin.Putty/plugin.json @@ -4,7 +4,7 @@ "Name": "Putty", "Description": "Launch Putty Sessions", "Author":"Konstantin Zaitcev, Kai Eichinger (@cH40zLord)", - "Version":"2.0.0", + "Version":"2.0.1", "Language": "csharp", "Website": "https://github.com/jjw24/Flow.Launcher.Plugin.Putty", "ExecuteFileName": "Flow.Launcher.Plugin.Putty.dll", From d6abdf7e7291076154cec530eb914b7555543c23 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sat, 13 Feb 2021 14:45:24 +1100 Subject: [PATCH 2/2] version bump --- Flow.Launcher.Plugin.Putty/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Plugin.Putty/plugin.json b/Flow.Launcher.Plugin.Putty/plugin.json index 83708e6..de215f8 100644 --- a/Flow.Launcher.Plugin.Putty/plugin.json +++ b/Flow.Launcher.Plugin.Putty/plugin.json @@ -4,7 +4,7 @@ "Name": "Putty", "Description": "Launch Putty Sessions", "Author":"Konstantin Zaitcev, Kai Eichinger (@cH40zLord)", - "Version":"2.0.1", + "Version":"2.1.0", "Language": "csharp", "Website": "https://github.com/jjw24/Flow.Launcher.Plugin.Putty", "ExecuteFileName": "Flow.Launcher.Plugin.Putty.dll",