Xcode's new-tab vs. reuse-tab behavior is still infuriating and baffling.

Is there any way to stop Xcode from randomly re-using a tab when you click on a file in the project treeview?

I never, never, NEVER want the file in the current tab replaced. If the clicked-on file is not already open in a tab, I want a new one. Every time. But in Xcode, you sometimes get a new tab, and sometimes don't. I can't find any pattern to this absurd behavior.

Even double-clicking doesn't produce a new tab, even though the Navigation settings say, "Double-click: Opens tab in focused editor."

WTH is this thing doing, and how do we stop it?

This is Xcode 16.4.

I have Xcode 16.4 and exactly the same settings as you. Here's how it works:

No files open:

I've just single-clicked my payees file - this opens it in a new tab, but note that the tab's filename is in italics (I call this a temporary tab). This denotes that if you single-click or double-click any other file in the project tree, this one will be replaced. You can keep this file open in this tab by double-clicking the tab itself.

Now, I've single-clicked the payload file. Because the payees file wasn't in a permanent tab the payload file replaced it:

And here I've now double-clicked the lookups file. It opened in a new tab, and it replaced the payload tab because it was a temporary tab.

Now I've double-clicked the notes file. It opened a new permanent tab of its own.

And lastly, I've single-clicked the DataModel file, so it's in a temporary tab.

So, the rules are:

  • If the current tab has an italicised title, single-clicking will replace that tab with the clicked file. Single-click another file and it will replace it again. Think of this tab as a preview tab where you can just click to view a file but not have hundreds of tabs open just when you're trying to find a file.
  • If the current tab's title is plain, single-clicking a new file opens a new tab in temporary mode.
  • If the current tab's title is plain, doublie-clicking opens a new tab in permanent mode.

Xcode 26 adds a new option (I think it’s new, I don’t have Xcode 16 anymore to check) that lets you indicate that a tab is pinned automatically which is exactly what the OP is looking for. But sadly Xcode 26 has a rotten regression that was fixed in an early beta and broken again in a later beta - as you open more tabs, the tab widths (all of them) get smaller and smaller so you can’t tell what file is in each. Horrible change.

I do recall that in Xcode 16, a tab automatically becomes pinned if the file is edited, or at least that was an option I had been using. That could explain the behavior the OP is seeing. Tabs get replaced if the tab had an unedited file in it. A new tab would be opened if the current tab had an edited file in it.

Thanks guys. @RickMaddy has answered the obvious question that arises from the rules that @darkpaw has generously provided: If I never double-clicked, how did I end up with five tabs?

Apparently I edited in the other four.

Xcode's new-tab vs. reuse-tab behavior is still infuriating and baffling.
 
 
Q