@@ -29,58 +29,54 @@ import (
2929
3030// PlatformSearch FIXMEDOC
3131func PlatformSearch (req * rpc.PlatformSearchRequest ) (* rpc.PlatformSearchResponse , error ) {
32- searchArgs := strings .TrimSpace (req .SearchArgs )
33- allVersions := req .AllVersions
3432 pme , release := commands .GetPackageManagerExplorer (req )
3533 if pme == nil {
3634 return nil , & arduino.InvalidInstanceError {}
3735 }
3836 defer release ()
3937
4038 res := []* cores.PlatformRelease {}
41- if isUsb , _ := regexp .MatchString ("[0-9a-f]{4}:[0-9a-f]{4}" , searchArgs ); isUsb {
42- vid , pid := searchArgs [:4 ], searchArgs [5 :]
39+ if isUsb , _ := regexp .MatchString ("[0-9a-f]{4}:[0-9a-f]{4}" , req . SearchArgs ); isUsb {
40+ vid , pid := req . SearchArgs [:4 ], req . SearchArgs [5 :]
4341 res = pme .FindPlatformReleaseProvidingBoardsWithVidPid (vid , pid )
4442 } else {
45-
43+ searchArgs := utils .SearchTermsFromQueryString (req .SearchArgs )
44+ allVersions := req .AllVersions
4645 for _ , targetPackage := range pme .GetPackages () {
4746 for _ , platform := range targetPackage .Platforms {
48- // discard invalid platforms
4947 // Users can install platforms manually in the Sketchbook hardware folder,
5048 // the core search command must operate only on platforms installed through
5149 // the PlatformManager, thus we skip the manually installed ones.
5250 if platform == nil || platform .Name == "" || platform .ManuallyInstalled {
5351 continue
5452 }
5553
56- // discard invalid releases
57- platformRelease := platform .GetLatestRelease ()
58- if platformRelease == nil {
54+ // Discard platforms with no releases
55+ latestRelease := platform .GetLatestRelease ()
56+ if latestRelease == nil {
5957 continue
6058 }
6159
6260 // Gather all strings that can be used for searching
63- toTest := []string {
64- platform .String (),
65- platform .Name ,
66- platform .Architecture ,
67- targetPackage .Name ,
68- targetPackage .Maintainer ,
69- targetPackage .WebsiteURL ,
70- }
71- for _ , board := range platformRelease .BoardsManifest {
72- toTest = append (toTest , board .Name )
61+ toTest := platform .String () + " " +
62+ platform .Name + " " +
63+ platform .Architecture + " " +
64+ targetPackage .Name + " " +
65+ targetPackage .Maintainer + " " +
66+ targetPackage .WebsiteURL
67+ for _ , board := range latestRelease .BoardsManifest {
68+ toTest += board .Name + " "
7369 }
7470
7571 // Search
76- if ! utils .MatchAny ( searchArgs , toTest ) {
72+ if ! utils .Match ( toTest , searchArgs ) {
7773 continue
7874 }
7975
8076 if allVersions {
8177 res = append (res , platform .GetAllReleases ()... )
8278 } else {
83- res = append (res , platformRelease )
79+ res = append (res , latestRelease )
8480 }
8581 }
8682 }
0 commit comments