Skip to content

Order custom board option menus as defined in platform configuration #2717

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

gneiss15
Copy link

@gneiss15 gneiss15 commented Apr 22, 2025

The use of sort on configOptions caused the custom board options menus to be ordered according to the lexicographical order of the machine identifiers of the menus instead of allowing the platform developer to control the order in a manner that will be most friendly for human users (via the ordering in the boards.txt platform configuration file).

Removing the sorting code allows the order to be as intended by the platform developer, and aligns the behavior with that of Arduino IDE 1.x.


Fixes #2036

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)

Title: Custom board option menus not following the order sent by the cli

Fixes "Custom board option menus not following the order inside boards.txt"

Line 74-76 of "boards-data-menu-updater.ts":
            for (const { label, option, values } of configOptions.sort(
              ConfigOption.LABEL_COMPARATOR
            )) {
New Line 74:
            for (const { label, option, values } of configOptions ) {

IMHO using sort on configOptions will produce the mentioned failure.
Simply don't sort and the order will be as in Arduino IDE 1.x (as desfined inside board.txt)

I don't have the tools to build and test this change.
I use the AppImage "arduino-ide_2.3.6_Linux_64bit.AppImage"

Signed-off-by: Günter Neiß <gneiss@web.de>
@CLAassistant
Copy link

CLAassistant commented Apr 22, 2025

CLA assistant check
All committers have signed the CLA.

Signed-off-by: Günter Neiß <gneiss@web.de>
@gneiss15
Copy link
Author

gneiss15 commented Apr 22, 2025

@per1234
Just one additional remark.
Before I found this "configOptions.sort...", I are confused about the order of the menu entries.
IMHO these should be either "as defined in boards.txt" (as in IDE 1.x) or alphabetical by name.
But it's sorted by the menu-id (label) instead of value.
Using a sort by value will produce a sorted order that is understandable by a human, but if that is what is wanted the documentation has to be adopted for this.

@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Apr 23, 2025
@per1234 per1234 changed the title Possible Fix for Issue 2036 Order custom board option menus as defined in platform configuration Apr 23, 2025
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.

Thanks for your pull request @gneiss15. Unfortunately it doesn't appear to have fixed #2036.

If the change you propose had fixed #2036 then we would expect the custom board options menus to be ordered as they are in the Arduino IDE 1.8.19 Tools menu. For example, with Tools > Board > esp32 > ESP32 Dev Module selected from the Arduino IDE menus:

image

Note the order of the custom board menus:

  • Upload Speed
  • CPU Frequency
  • Flash Frequency
  • ...

However, when I use the tester build and select Tools > Board > esp32 > ESP32 Dev Module, the Tools menu contains:

image

Note the order of the custom board menus:

  • CPU Frequency
  • Core Debug Level
  • Erase All Flash Before Sketch Upload
  • ...

Signed-off-by: Günter Neiß <gneiss@web.de>
@gneiss15
Copy link
Author

gneiss15 commented Apr 24, 2025

Hi @per1234,
in the meanwhile I had installed all the necessary tools for compiling and testing.
.. And yes my previous PR did not solve the problem.
Now I found, that removing the sort isn't enough, because that will not change the order inside the menu (only the order the confiOptions are processed).
Now I found (I am new to electron, typescript and so on), that the menu entries will be sorted by the last value of 'menuPath', which is currently '${option}'.
And that is the reason why they are sorted as shown above (by You). I now use '${order}`.
order is calculated from the current entry-number (or index of the entry inside configOptions).

So now the PR works as he should be.

PS.: The checks show some errors. I don’t know how to fix them, because they are not related to my PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom board option menus not following the order sent by the cli
3 participants