Sketch opens with two identical tabs. Cannot close the second

Some sketches open as expected, but one always opens with two identical tabs. I cannot close the second tab. If I select "Delete" from the tab-drop-down, it asks if I want to delete the current sketch. If I select "OK" nothing happens.
Screenshot 2021-12-22 210329

What files are in the folder containing the problem sketch ?

I have discovered that this is a split-view (F1->View: Split Editor). But I cannot see a way of un-splitting the view!

If you click on the Explorer icon in the sidebar you will see each of the split windows like this
image
If you hover over one of the filenames the display will change
image
Clicking on the X alongside the filename allows you to close that editor pane

1 Like

The difficulty of closing split editor panels is being tracked by the Arduino IDE developers here:

I'll add that the Explorer is not in the sidebar by default. But you can add it via the command palette ("Toggle Explorer View") or by right clicking a sketch tab and then selecting "Reveal in Editor"

1 Like

Thanks, but I don't remember taking any actions to make the Explorer icon visible. I have just deleted all previous versions of 2.00 from my PC and downloaded the latest nightly build and the Explorer is in the side bar with no intervention from me so I wonder where the setting is being held

Using "Toggle Explorer View" or its shortcut Ctrl+shift+E, opens the Explorer panel rather than making the Explorer icon available. Is that what you meant ?

It is certainly not normal to have Explorer. It is not on the sidebar by default:

and even after you add it, it is removed every time you load a new IDE window:

There are two important folders used to store configuration information for the Arduino IDE 2.x. You should delete both if you want to simulate a fresh installation.

Windows

  • %HOMEPATH%\.arduinoIDE\ (e.g., C:\Users\<user name>\.arduinoIDE\)
  • %APPDATA%\arduino-ide\ (e.g., C:\Users\<user name>\AppData\Roaming\arduino-ide\)

Linux

  • ~/.arduinoIDE/
  • ~/.config/arduino-ide/

macOS

  • ~/.arduinoIDE/
  • ~/Library/Application Support/arduino-ide/

It does both. There isn't a command for adding the icon by itself, but when you activate the Explorer view then you also force the icon into the sidebar. After that, you can use the icon to toggle the view.

Thanks for the details

I have am using Windows and have deleted both of the folders you suggested. Running Arduino IDE.exe from the download of the latest nightly build opens the editor with no Explorer icon present, so that explains where it was being triggered from

Also as you suggested, right clicking on the filename in the editor and selecting "Reveal in Explorer" inserts the Explorer icon in the sidebar and opens the Explorer pane and I assume that I must have done that at some time in the past when trying out 2.00

But of course, closing the Explorer pane does not remove the icon from the sidebar, so it might just as well be there from the beginning

I never really checked for duplicate tabs but just noticed it happening.

I selected a sketch using "File/Open Recent" from an already opened sketch. The selected sketch opened showing a duplicate tab displaying the full file path.

The only file in the sketch folder was the opened .ino sketch

I closed the sketch and opened it again but selecting "File/Open". This time the sketch opened normally in a single tab with only the sketch name displayed.

image

The above is reproducible. This was with RC3.

EDIT: I just noticed something interesting and very welcome. With RC3 all the red squiggles which I always had in all my sketches are gone and the popups work really well.

Willem.

While the split editor @StephenJD encountered is an intentional feature, the duplicate tabs you encountered is a bug that is being tracked by the developers here:

Although I can reliably reproduce the issue as it occurs when opening a file via the "Search" and "Sketchbook" views, I have not managed to reproduce the issue when opening an already opened sketch via "File/Open Recent" unfortunately.

I'm very glad to hear that. The developer of the Arduino Language Server has been doing a lot of work on it recently and I also found that a lot of the issues have been resolved.

I spoke too soon.

If I select right hand click on a function (in the same .ino file) the editor jumps to the function definition, which is a great feature, but at the same time opens a new tab, it also switches to the new tab when displaying the function definition. This would be correct if the definition was in a separate file. However, this new tab cannot be closed as it can be when the definition is in a separate file (for example in a library).

I further noticed if I select "Go to definition" while in the second tab, it does not open any further tabs when displaying the requested definition. This tab now functions as I would have expected the original to function.

Willem.

I'm not familiar with this procedure. Would you mind providing directions I can follow to do it?

Is that on a call to the function?

Is that tab a duplicate of the already opened tab that contains the definition?

Does this occur with any sketch, or are there specific conditions it occurs under. For example, does it occur with this minimal sketch?

void setup() {
  foo();
}
void loop() {}
void foo() {}

I tried it with your minimal foo sketch. it does not reproduce the problem. I then tried to create a slightly larger sketch and could not reproduce it either. Load my problem sketch and it is 100% reproducible.

My sketch is about 2100 lines with quite a few commented out sections. It compiles to 14774 bytes for an 328P using MiniCore. (Uploaded it does exactly what it should.)

I'm not familiar with this procedure. Would you mind providing directions I can follow to do it?

I place the mouse cursor on the function where it is called (it shows the popup), in say Setup, press the right hand mouse button and select "Go to Definition" from the popup menu (first item).

Is that on a call to the function?

Yes.

Is that tab a duplicate of the already opened tab that contains the definition?

An exact duplicate, name and line for line.

I can upload my sketch if you would like to try and reproduce the problem and think it may help.

Added: I just tried with another of my sketches, about 500 lines, and that does not have the same problem. It behaves exactly how I thought it should. I think I have purely, by chance, selected the problem sketch when I checked RC3's behaviour reading this thread.

NB: Windows 10.

Willem

Thanks for the clarification. I am familiar with this operation. It is probably my favorite of the features added to Arduino IDE 2.x.

I think it might be helpful. I'm not the one who will be able to fix the bug, but I try to assist the developers where I can. Being able to reproduce a bug is a very helpful both for fixing the bug and for verifying the fix was effective.

I played around with the problem sketch for a while.

Right hand clicking the duplicate tab's filename and selecting "Reveal in Explorer" opened the explorer showing both tabs. I could close the duplicate from here.

Selecting "Go to Definition" again opened a duplicate tab. I then closed the original tab from the Explorer and the, now single, duplicate tab functioned correctly (no new duplicates).

After closing the IDE and restarting, it opened with the problem sketch as expected, but I could now longer repeat the original problem. Whatever I tried everything now worked as expected.

At this point there is no sense in sending you the sketch since I cannot reproduce the problem and am sure you will not be able to either. I copied the sketch to a new test folder, renaming the sketch the same as the folder name, and it opened with no reproducible problem.

I have not found any new anomalies in RC3, everything work just great. I cannot reproduce the problems found in other threads either (they were on Mac - I am in Windows).

Thanks for helping. If I come across a similar problem I will let you know.

Willem.

Other than for this split editor view closing workaround, do you think the Explorer is really valuable enough to the target user to justify the added complexity (steeper learning curve) to the primary user interface?

As you said yourself recently:

No I don't, but to avoid confusion why leave the Explorer icon on the sidebar once the Explorer pane has been closed ?

Well, even though I don't see a lot of need for the Explorer in the Arduino IDE, some advanced users very much want it (example), and these same users won't be caused any confusion by an extra icon in the sidebar. If they have gone to the trouble to access it via the advanced secondary UI, they likely want it to be persistent (example).

That said, I would like a clean way to hide the icon on demand, as you can do via the sidebar context menu in VS Code.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.