Skip to content
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

Allow to close files in certain folders #946

Merged
merged 2 commits into from
Apr 19, 2022
Merged

Conversation

msujew
Copy link
Contributor

@msujew msujew commented Apr 6, 2022

Motivation

Closes #866
Closes #831

Change description

When adding a widget to the tracker we first try to see whether it is contained in one of our ignoreFolders (.vscode, .theia and src so far). If it is, we allow it to stay closable.

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)

@per1234 per1234 added the topic: code Related to content of the project itself label Apr 6, 2022
Copy link
Contributor

@AlbyIanna AlbyIanna left a comment

Choose a reason for hiding this comment

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

Works for me! Thanks! 🐸

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.

As I see additional folders added selectively to the exclusion, it occurs to me it may be better to go at this from the other direction: by simply making the root of the sketch folder the "non-closable" area, with any files from subfolders always being closable.

That will provide symmetry with the sketch files that are opened by default and avoid the poor user experience of being able to open an additional file via the Sketchbook view (when "☐ Show files inside Sketches" is enabled), but then not being allowed to close it again.

For example, the Arduino Sketch Specification provides a data subfolder "to add additional files to the sketch, which will not be compiled". Since these will not be part of the sketch program by definition, there is no reason we should force the user to keep the tab open.

@AlbyIanna
Copy link
Contributor

@per1234 that makes sense. @msujew do you think you can tackle this as Per suggested?

@msujew
Copy link
Contributor Author

msujew commented Apr 12, 2022

@per1234 Thanks for the input, I've updated the code to only prevent file from closing which are direct children of the sketch directory. As far as I could see in the sketch spec this seems to be the intended behavior. Or does it only apply to *.ino files?

@AlbyIanna AlbyIanna requested a review from per1234 April 12, 2022 14:09
@per1234
Copy link
Contributor

per1234 commented Apr 12, 2022

I've updated the code to only prevent file from closing which are direct children of the sketch directory.

Very nice. Thanks!

As far as I could see in the sketch spec this seems to be the intended behavior. Or does it only apply to *.ino files?

The established behavior from Arduino IDE 1.x is that all the sketch code files from the root of the sketch folder are opened when you load the sketch and are not closable. That is done according to the following file extensions:

  • .ino
  • .pde
  • .cpp
  • .c
  • .h
  • .hh
  • .hpp
  • .S

The most important is the .ino files. The reason is that the Arduino build system has the somewhat non-obvious behavior of concatenating all the .ino files of the sketch together in a specific order before compiling. This allows the sketch developer to split larger programs up into manageable parts without having to dive into the confusing subject of translation units.

By loading all the .ino files when opening a sketch and avoiding their closure, the IDE communicates to the user intuitively that all the files are being compiled and also which order they will be concatenated in.

Since they are more likely to be used by advanced users, it probably isn't so essential to avoid the closure of the code files with other extensions, but they do all become part of the sketch program so I think it is reasonable. The src subfolder offers the sketch developer a solution if there are sketch files that don't need to be prominently visible to the user (e.g., the hundreds of files of the Marlin 3D printer firmware sketch).

When it comes to the non-code "additional" file extensions (.adoc, .json, .md) we are in uncharted territory because it has never before been possible to open these file types in the Arduino IDE. It would probably be worth considering whether these should be made closable, but that is not in scope for this PR.

@AlbyIanna AlbyIanna merged commit c072326 into main Apr 19, 2022
@AlbyIanna AlbyIanna deleted the msujew/enable-close branch April 19, 2022 10:00
@kittaakos
Copy link
Contributor

Follow up: #977

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
Projects
None yet
4 participants