Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix boards listing #1520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
AlbyIanna merged 5 commits into main from fix-board-listing
Oct 17, 2022
Merged

Fix boards listing #1520

AlbyIanna merged 5 commits into main from fix-board-listing
Oct 17, 2022

Conversation

@AlbyIanna
Copy link
Contributor

@AlbyIanna AlbyIanna commented Oct 4, 2022
edited
Loading

Motivation

The IDE needs to sort the menu for each platform in Tools > Board (e.g., Tools > Board > Arduino AVR Boards) according to the order of occurrence of the name property for each board definitions in the platform's boards.txt configuration file.

Change description

  • use listall instead of search command in the arduino-cli
  • add a proper order to the menu item when registering a board
  • update the arduino-cli to use the sorting fix

Other information

Fixes #802.

This needed a fix in the CLI to get the correct order: arduino/arduino-cli#1903

This PR is in draft because there isn't a release for the arduino-cli yet, but it can already be tested.

Arduino IDE 2.x before this change:
image

Arduino IDE 2.x after this change:
Screenshot 2022年10月04日 at 10 51 36

Arduino IDE 1.x:
Screenshot 2022年10月04日 at 10 51 46

Reviewer checklist

  • PR addresses a single concern.
  • The PR has no duplicates (please search among the Pull Requests before creating one)
  • PR title and description are properly filled.
  • Docs have been added / updated (for bug fixes / features)

Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work. If IDE2 uses board list instead of board search, then only boards from installed platforms will be searched.

Steps to reproduce:

  • Delete ⚠️ (or rename) the directories/data location,
  • Start IDE2 from this PR,
  • Use the board search.
board-search.mp4

@kittaakos kittaakos added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Oct 4, 2022
Copy link
Contributor Author

This won't work. If IDE2 uses board list instead of board search, then only boards from installed platforms will be searched.

Right. I've fixed it by adding a separate method to get only the installed boards.

Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Please reuse the code instead of copy/pasting it.

Done

Copy link
Contributor

Done

Thank you! I will do the verification soon. Which issue does this PR suppose to close? I could not find it in the commits or PR description. The closest was #801.

Copy link
Contributor Author

The closest was #801.

Pretty close, it fixes #802. Added to the PR's description.

kittaakos reacted with thumbs up emoji

Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of the boards is not correct for me:

image

Arduino IDE version

2.0.1-snapshot-3f7230e (tester build for 56f2ac3)

Operating system

Windows 10, Ubuntu 20.04

Additional context

The order is as expected when using Arduino CLI:

$ arduino-cli version
arduino-cli.exe Version: git-snapshot Commit: 3d5a87e1 Date: 2022年10月04日T18:01:41Z
$ arduino-cli board listall arduino:avr --format json | jq '.boards[] | .name'
"Arduino Yún"
"Arduino Uno"
"Arduino Uno Mini"
"Arduino Duemilanove or Diecimila"
"Arduino Nano"
"Arduino Mega or Mega 2560"
"Arduino Mega ADK"
"Arduino Leonardo"
"Arduino Leonardo ETH"
"Arduino Micro"
"Arduino Esplora"
"Arduino Mini"
"Arduino Ethernet"
"Arduino Fio"
"Arduino BT"
"LilyPad Arduino USB"
"LilyPad Arduino"
"Arduino Pro or Pro Mini"
"Arduino NG or older"
"Arduino Robot Control"
"Arduino Robot Motor"
"Arduino Gemma"
"Adafruit Circuit Playground"
"Arduino Yún Mini"
"Arduino Industrial 101"
"Linino One"
"Arduino Uno WiFi"

Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have noticed that sometimes the order of installed boards does not match with IDE 1.x Sometimes it's correct.

IDE2 SAMD:
Screen Shot 2022年10月05日 at 16 47 00

IDE 1.x SAMD:
Screen Shot 2022年10月05日 at 16 45 50

IDE2 AVR:
Screen Shot 2022年10月05日 at 16 47 10

IDE 1.x AVR:
Screen Shot 2022年10月05日 at 16 47 24

return this.handleListBoards(client.boardListAll.bind(client), req);
}

async handleListBoards(
Copy link
Contributor

@kittaakos kittaakos Oct 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The visibility should be private if it's not called from outside of the module.

const menuAction = {
commandId: id,
label: name,
order: `${index}`,
Copy link
Contributor

@kittaakos kittaakos Oct 5, 2022
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can check them together, but I think this is the classic alphanumeric ordering issue.

% node 
Welcome to Node.js v14.19.0.
Type ".help" for more information.
> ['1', '2', '3', '11', '12', '111'].sort()
[ '1', '11', '111', '12', '2', '3' ]
> .exit

With some zero padding, it works for me locally:

diff --git a/arduino-ide-extension/src/browser/contributions/board-selection.ts b/arduino-ide-extension/src/browser/contributions/board-selection.ts
index 2241c925..466e4f63 100644
--- a/arduino-ide-extension/src/browser/contributions/board-selection.ts
+++ b/arduino-ide-extension/src/browser/contributions/board-selection.ts
@@ -243,7 +243,7 @@ PID: ${PID}`;
 const menuAction = {
 commandId: id,
 label: name,
- order: `${index}`,
+ order: String(index).padStart(4), // pads with leading zeros for alphanumeric sort where order is 1, 2, 11, and NOT 1, 11, 2
 };
 this.commandRegistry.registerCommand(command, handler);
 this.toDisposeBeforeMenuRebuild.push(

Great that your changes revealed the flaw in the codebase. These are probably all incorrect:

👇 This probably works only because the open recent is limited to ten items.

Copy link
Contributor Author

@AlbyIanna AlbyIanna Oct 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one! Thank you for the suggestion!

Copy link
Contributor Author

@AlbyIanna AlbyIanna Oct 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed the suggestion, could you please verify it now?

Copy link
Contributor

@AlbyIanna, I have restarted the failed job. If you mark the PR ready, I will do the final verification. The code looks great. Thanks!

AlbyIanna reacted with thumbs up emoji

Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is working perfectly for me now.

Thanks Alberto!

@AlbyIanna AlbyIanna marked this pull request as ready for review October 7, 2022 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@per1234 per1234 per1234 approved these changes

@davegarthsimpson davegarthsimpson Awaiting requested review from davegarthsimpson

@francescospissu francescospissu Awaiting requested review from francescospissu

+1 more reviewer

@kittaakos kittaakos kittaakos approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Sort Board menus as done in Arduino IDE 1.x

AltStyle によって変換されたページ (->オリジナル) /