Skip to content

Added sketch tabs don't follow concatenation order #987

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
3 tasks done
per1234 opened this issue May 12, 2022 · 1 comment
Open
3 tasks done

Added sketch tabs don't follow concatenation order #987

per1234 opened this issue May 12, 2022 · 1 comment
Assignees
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented May 12, 2022

Describe the problem

Arduino sketches may consist of multiple files, which are shown in the Arduino IDE as tabs when that sketch is open. All the .ino files of the sketch are concatenated before compiling, starting with the file that matches the sketch name, followed by the rest in lexicographical order:

https://arduino.github.io/arduino-cli/dev/sketch-build-process/#pre-processing

The resulting program structure is conveyed to the user in an intuitive manner by the order of the .ino sketch tabs in the IDE reflecting their concatenation order.

🐛 Tabs of newly added files follow the order of addition rather than the order of sketch concatenation. The concatenation behavior for these files will not be intuitive to a user unfamiliar with the obscure low level details of sketch pre-processing.

To reproduce

  1. Click the button on the right side of the editor toolbar.
  2. Select "New Tab" from the menu.
  3. In the "Name for new file" field, type b.ino
  4. Click the OK button.
  5. Click the button on the right side of the editor toolbar.
  6. In the "Name for new file" field, type a.ino
  7. Click the OK button.

🐛 The "a.ino" tab is added to the right of the "b.ino" tab.

image

Expected behavior

The editor tabs of .ino sketch files match their concatenation order.

Arduino IDE version

Original report

2.0.0-rc6-snapshot-289f9d7

Last verified with

51f69f6

Operating system

Windows

Operating system version

10

Additional context

The bug also occurs when files are added to the sketch externally


The bug also occurs when files are renamed.


Arduino IDE 1.x handles ordering of tabs for added sketch files as expected.

Additional reports

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels May 12, 2022
@kittaakos
Copy link
Contributor

The editor tabs of .ino sketch files match their concatenation order.

Could you please help slightly generalize the expectation and help define the tab order for non .ino and .pde files? I want to tackle them together (also with #643).

The spec says:

No pre-processing is done to files in a sketch with any extension other than .ino or .pde.

What about the other files and their order?

IDE2 allows creating files with these extensions so that they can open up in an editor:

export const MAIN = ['.ino', '.pde'];
export const SOURCE = ['.c', '.cpp', '.s'];
export const ADDITIONAL = [
'.h',
'.c',
'.hpp',
'.hh',
'.cpp',
'.S',
'.json',
'.md',
'.adoc',
];
export const ALL = Array.from(new Set([...MAIN, ...SOURCE, ...ADDITIONAL]));

On the first sketch open, IDE2 opens the main sketch file (MainFile) and the files in the root folder (RootFolderFiles):

readonly mainFileUri: string; // `MainFile`
readonly otherSketchFileUris: string[]; // `OtherSketchFiles`
readonly additionalFileUris: string[]; // `AdditionalFiles`
readonly rootFolderFileUris: string[]; // `RootFolderFiles` (does not include the main sketch file)

Is there any expectation of opening non-sketch-related editors in the main area? For example, when opening the Advanced Settings JSON or graphical editor?

Thank you!

@kittaakos kittaakos self-assigned this Nov 7, 2022
@kittaakos kittaakos removed their assignment Nov 17, 2022
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

No branches or pull requests

3 participants