When you open a file in a new tab in the IDE, you are unable to close that tab, ever. File, Close closes the entire project, not just the tab you are on.
That sounds like it is working as intended. The IDE will show a tab for each file in the sketch directory so you cannot close it
I have opened tabs on files that are not in the sketch directory, by right-clicking on include statements and choosing "Go to definition". Incredibly handy, but no way to close the window that opens.
When such a tab opens to show you the definition the tab should have the usual 'X' on it to close the tab
2 Likes
I discovered the X appears when I select the tab. I had looked at tabs that I hadn't selected and didn't see the X. (The tab I did have selected was a file that was part of the project itself and so it didn't have an X, and it never occurred to me that by selecting a different tab of a non-project file, an X might appear).
Thanks.
1 Like
It also appears when you hover the mouse pointer over the tab even when it is not selected. VS Code (which the design of Arduino IDE somewhat parallels due to using a related framework) has the same behavior.
Hello,
I made the mistake of ctrl+alt+click on a method. it opened a new tab with a duplicate of the existing tab. I cannot close it, even when I restart the app. There is no 'x' on the tab when i select it. see image. CANBus.h is already open in the left set of tabs. Please advise!
Hi @aggrav8d . Thanks for your report. I'll provide instructions you can follow to close these split editor panels:
Press the Ctrl +Shift +P keyboard shortcut (Command +Shift +P for macOS users) to open the "Command Palette".
A menu will appear on the editor toolbar:
Select the "View: Reset Workbench Layout " command from the menu.
ⓘ You can scroll down through the list of commands to find it or type the name in the field.
3 Likes
You are welcome.
I submitted a formal bug report to the Arduino IDE developers on your behalf:
opened 04:01AM - 14 Sep 23 UTC
topic: code
type: imperfection
### Describe the problem
#### Sketch tab management
The unit of the Arduin… o sketch project is a folder. Even though many of the common sketches consist of only a single file, the folder may contain [multiple sketch code files](https://arduino.github.io/arduino-cli/dev/sketch-specification/#additional-code-files). All the source files present in that folder are compiled to a single program.
In order to intuitively communicate the nature of the sketch to the user and avoid confusion that might be caused by code from files not visible to the user still being compiled, each Arduino IDE window contains a single sketch, with all primary code files of the sketch open as tabs. These tabs are not closeable as would be the case if Arduino IDE was a general purpose editor instead of a tool specifically designed for development of Arduino sketches.
#### Split editor feature
The [**Eclipse Theia** IDE framework](https://theia-ide.org/) Arduino IDE is built on supports the ["split editor" feature](https://code.visualstudio.com/docs/getstarted/userinterface#_side-by-side-editing), where multiple panels can be created in the editor view so that content can be viewed side-by-side while editing. This includes having the same file open in two tabs.
#### Problems with split editor in Arduino IDE
Arduino IDE gained a split editor capability by chance rather than design through an update of the Theia dependency. The users discovered this new feature, but also discovered that it did not work correctly: the system for preventing primary sketch code file tabs from being closed did not allow the redundant tabs created by the split editor feature to be closed (https://github.com/arduino/arduino-ide/issues/552). Since it did not work correctly and had not been planned, Arduino IDE project managers decided the split editor feature should be disabled (https://github.com/arduino/arduino-ide/pull/940) until resources were available to implement it in a fully functional state (https://github.com/arduino/arduino-ide/issues/909).
🐛 Despite the efforts to disable the feature, the editor is still split when the "**editor.action.revealDefinitionAside**" command is executed. If the definition is in a root sketch file, it will not be possible to then unsplit the editor using the primary Arduino IDE interface.
### To reproduce
1. Create the following sketch:
```cpp
void foo() {}
void setup() {
foo();
}
void loop() {}
```
1. Select any board with language server support.
1. Hold <kbd>**Ctrl**</kbd>+<kbd>**Alt**</kbd> while clicking the `foo` call on line 3 of the sketch.
A split editor pane opens.
1. Try to find a way to unsplit the editor via the Arduino IDE primary interface.
🐛 It is not possible to unsplit the editor.
### Expected behavior
Opening primary sketch code files as tabs of a split editor panel is only possible once the split editor feature is in a fully functional state.
### Arduino IDE version
2.2.1
### Operating system
Windows
### Operating system version
11
### Additional context
In addition to the <kbd>**Ctrl**</kbd>+<kbd>**Alt**</kbd>+click trigger for **editor.action.revealDefinitionAside** command used in the demo above, it also has a default keyboard shortcut <kbd>**Ctrl**</kbd>+<kbd>**K**</kbd> <kbd>**Ctrl**</kbd>+<kbd>**F12**</kbd>, which should also be disabled by default in order to prevent the users from accidentally putting the IDE into the broken split editor state via that path.
Since `keymaps.json` is a supplemental file and thus closeable, the IDE's behavior of opening this file in a split editor is not a problem in itself. It is actually a fairly reasonable default behavior since the user might like to view the `keymaps.json` editor alongside the "**Keyboard Shortcuts**" GUI view. But the average user is unlikely to open `keymaps.json`, so it wouldn't be a significant loss if the behavior was changed to opening the file without splitting the editor panel.
#### Related
- https://github.com/arduino/arduino-ide/issues/1850
---
Originally reported at https://forum.arduino.cc/t/cant-close-tab/1143314
#### Workaround
The IDE editor can be recovered from its split state by performing the following instructions:
1. Press the <kbd>**Ctrl**</kbd>+<kbd>**Shift**</kbd>+<kbd>**P**</kbd> keyboard shortcut (<kbd>**Command**</kbd>+<kbd>**Shift**</kbd>+<kbd>**P**</kbd> for macOS users) to open the "**Command Palette**".
1. Select the "**View: Reset Workbench Layout**" command from the menu.
### Issue checklist
- [X] I searched for previous reports in [the issue tracker](https://github.com/arduino/arduino-ide/issues?q=)
- [X] I verified the problem still occurs when using the latest [nightly build](https://www.arduino.cc/en/software#nightly-builds)
- [X] My report contains all necessary details
Thanks for bringing this to our attention.
1 Like
system
Closed
March 12, 2024, 4:02am
12
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.