File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
G33kShell.Desktop/Terminal/Commands Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 88// about your modifications. Your contributions are valued!
99//
1010// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND.
11+
12+ using System ;
1113using System . IO ;
1214using System . Linq ;
1315using System . Threading . Tasks ;
@@ -34,15 +36,24 @@ protected override Task<bool> Run(ITerminalState state)
3436 . Select ( o => ( o , GetScore ( o , Path ) ) )
3537 . OrderByDescending ( o => o . Item2 )
3638 . ToArray ( ) ;
37- var result = candidates . FirstOrDefault ( ) ;
39+
40+ // Check for a perfect match.
41+ var result = candidates . FirstOrDefault ( o => System . IO . Path . GetFileName ( o . o ) ? . Equals ( Path , StringComparison . OrdinalIgnoreCase ) == true ) ;
42+
43+ // ...failing that, find the best match.
44+ if ( result . Item2 == 0.0 )
45+ result = candidates . FirstOrDefault ( ) ;
46+
3847 if ( result . Item2 > 0.7 )
3948 {
49+ // Good enough to be a likely match - Use it.
4050 var newDir = result . o . ToDir ( ) ;
4151 state . CurrentDirectory = newDir ;
4252 Settings . Instance . AppendPathToHistory ( newDir . FullName ) ;
4353 return Task . FromResult ( true ) ;
4454 }
4555
56+ // Not enough info - Report what matches _might_ exist.
4657 if ( candidates . Any ( ) )
4758 {
4859 WriteLine ( "Candidates:" ) ;
You can’t perform that action at this time.
0 commit comments