Closed kittaakos closed 1 year ago
Another alternative solution could be if IDE2 converted the http://librarymanager/All#SparkFun_u-blox_GNSS
URL to the SparkFun u-blox GNSS
query term. Note the _
to ` conversion, but then the IDE2 library manager query field will be populated with
SparkFun u-blox GNSSand not
SparkFun_u-blox_GNSS`; hence the same behavior between IDE 1.x and IDE2 cannot be preserved. See https://github.com/arduino/arduino-ide/issues/1442#issuecomment-1252367198.
for reference here's how the Arduino IDE 1.8.x do the search, I'm going to implement the same search:
private boolean filterCondition(ContributedLibraryReleases lib) {
if (selectedCategoryFilter != null && !selectedCategoryFilter.test(lib)) {
return false;
}
ContributedLibrary latest = lib.getLatest();
String compoundTargetSearchText = latest.getName() + " "
+ latest.getParagraph() + " "
+ latest.getSentence();
if (latest.getProvidesIncludes() != null) {
compoundTargetSearchText += " " + latest.getProvidesIncludes();
}
if (!stringContainsAll(compoundTargetSearchText, selectedFilters)) {
return false;
}
return true;
}
/**
* Check if <b>string</b> contains all the substrings in <b>set</b>. The
* compare is case insensitive.
*
* @param string
* @param filters
* @return <b>true<b> if all the strings in <b>set</b> are contained in
* <b>string</b>.
*/
private boolean stringContainsAll(String string, String filters[]) {
if (string == null) {
return false;
}
if (filters == null) {
return true;
}
for (String filter : filters) {
if (!string.toLowerCase().contains(filter.toLowerCase())) {
return false;
}
}
return true;
}
Thank you for taking care of it!
Where is the _
(underscore) to
(space) escaping in the logic? The problem described in arduino/arduino-ide#1442 is unrelated to the predicate logic you have posted here. Please let me know if more input is required. I would like to avoid implementing something unnecessary.
Where is the _ (underscore) to (space) escaping in the logic?
Very good point... mmmmmmm
ok I think I found it:
public void applyFilter() {
String[] filteredText = new String[0];
if (!showingHint) {
String filter = getText().toLowerCase();
// Replace anything but 0-9, a-z, or : with a space
filter = filter.replaceAll("[^\\x30-\\x39^\\x61-\\x7a^\\x3a]", " ");
filteredText = filter.split(" ");
}
onFilter(filteredText);
}
so in the query we must Replace anything but 0-9, a-z, or : with a space
Describe the problem
There is an inconsistency between the CLI
lib search
output and IDE 1.x's Library Manager functionality.The issue originally popped up here: https://github.com/arduino/arduino-ide/issues/1442
IDE2 wants to produce the same library search results as IDE 1.x. When searching for the
SparkFun_u-blox_GNSS
term, the following results should be returned by the CLI:The CLI returns with one result only, where the
name
matches:./arduino-cli lib search "SparkFun_u-blox_GNSS" --format json
:To reproduce
Compare the library search output of the CLI and the Arduino IDE 1.x. See the description for more details.
Expected behavior
The same lib/core search result is produced by the CLI and IDE 1.x.
Arduino CLI version
arduino-cli Version: 0.27.1 Commit: a900cfb2 Date: 2022-09-06T16:44:27Z
Operating system
macOS
Operating system version
12.5.1
Additional context
No response
Issue checklist