From 63da7fc0c730953a485650c429d280fd815e7320 Mon Sep 17 00:00:00 2001 From: Shresht Srivastav <59516096+Shresht7@users.noreply.github.com> Date: Sun, 4 Feb 2024 12:48:10 +0530 Subject: [PATCH] Improve tooltips --- Module/Library/PSFavoritePredictor.dll | Bin 8192 -> 8704 bytes Predictor/PSFavoritePredictor.cs | 27 ++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Module/Library/PSFavoritePredictor.dll b/Module/Library/PSFavoritePredictor.dll index 9abbe8faf94fd5aa78321467536cb495d733945f..3291c5fe10d3328dc0c3c02ee5102d1f3b9523ff 100644 GIT binary patch delta 2788 zcmZuz4R93Y8Ghbx_jWHAa@^(TE&)RB5@L=d#2iUX4rOWxk)IX;6C9{oy@aHMA{Ud8 z0kOG5P?**Vas3$?OR0z>ik)g^v=uuotuU3TZJBl|Lpuz#HHt0Jc5KHo4DIvnos@RE zd*AcD@ALkB`|Z2Cm$@~waL=yFzI7kGjofh-m63dD1g4R&vg93Y<1gPS|8hiXJjJa* zw-Z(M&KjxltuCcUgkzfXHK~&s&KpuA5$B9lmNm6ygBNpB@Zfuuz}>}wINQovofT?{ zgq*#qUBb@qRJjy6msOP%J2Q={bO{R&mjk})OdepyOrS32Aq-cLtSxFZQROB@Pz}8V z43>mq5n6oK;{)M%o)zAkifYF(R`k`PsL?DAuoa8ZsrI&TmMo+ao2{9dDi+jp!!S83!`(Koar2C=wX{{ty=sQ8O6|<7 zTKlCUV{0AxEXEjO4c9wKb4I?c#W^}1oSkO%{9n>mH3r;5!(uPxu92aEjb9$-0_M0nI;HB0`$?EkENs7BWEOzon}O$m~a1HR%V`-N#avhL~g=4 zoafT&aDn&;E)#zQTUl6cmk`s2HzF${%!ciyM=YIq#MLJA=17H7cqpeWRSDkf?K$mz zkJcW`YBJTDMbG=9;4zNH){V-8J+8J5jXx#Vh-GGWeBUi>YmZIT6P<-;dAb*U^> z1^7o!YnD3{uR5pQEBB~ETz0kb(xXqg*%kW&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cUGNRUi4fg zv3*)*yuXy6_uZ5m%WlXGA0HSvGV$q)Z~fq z%g+ZZDc&{So$4O%nCNcnNTeovQmM&gda`5hcyc_^(cU%LoopL#OQt&~<@Hc&5SIpb zJ_Oo4tXAWGZj1cMvlx=C;eZA8Q6q=KG4IgG`~P}<0-KLN{^3ZMPf9r-PPZ4tvttF3 zGg&J?J#kmnc;vZDUz&S=YvG%SlVD2Ok)>!rjHP5_<=JJ=>Mmnz7sk=eRl2$Fzy$Yg z+$UI>L=U6tll=BgvbvXJlH3w(x1)=-Zsu*QwCR{mOiEevH8G!B_C@|iO9|&c=y{`- diff --git a/Predictor/PSFavoritePredictor.cs b/Predictor/PSFavoritePredictor.cs index bec8601..e26d8b3 100644 --- a/Predictor/PSFavoritePredictor.cs +++ b/Predictor/PSFavoritePredictor.cs @@ -1,6 +1,7 @@ using System.Management.Automation; using System.Management.Automation.Subsystem; using System.Management.Automation.Subsystem.Prediction; +using Microsoft.VisualBasic; namespace PowerShell.Sample { @@ -59,7 +60,7 @@ public SuggestionPackage GetSuggestion(PredictionClient client, PredictionContex .Select(line => (Line: line, Score: DetermineScore(input, line))) // Determine the score for each line. .Where(tuple => tuple.Score >= ScoreThreshold) // Filter out the lines below the score threshold. .OrderByDescending(tuple => tuple.Score) // Order the list by the score in descending order. - .Select(tuple => new PredictiveSuggestion(tuple.Line, tuple.Score.ToString())) // Create a PredictiveSuggestion object for selected line. + .Select(tuple => new PredictiveSuggestion(tuple.Line, GetTooltip(tuple.Line))) // Create a PredictiveSuggestion object for selected line. .ToList(); // Convert to a list of PredictiveSuggestion objects. // Return the list of suggestions. @@ -106,6 +107,30 @@ private int DetermineScore(string input, string line) return score; } + /// + /// Get the tooltip for the suggestion. + /// + /// The line from the favorite's file + /// The tooltip for the suggestion + /// + /// The tooltip is the part of the line after the first '#' character. + /// + /// + /// If the line is "Get-Process # Get the list of processes", the tooltip is "Get the list of processes". + /// + private static string GetTooltip(string line) + { + string[] s = Strings.Split(line, "#"); + if (s.Length > 1) + { + return s[1].Trim(); + } + else + { + return string.Empty; + } + } + #region "interface methods for processing feedback" ///