Repository navigation
I close a tab and want it straight back, but I have to find the file again and its undo is gone #343
Description
Opportunity
I close a tab by mistake, or close one and realise a moment later I still need it. Getting it back means remembering which file it was and finding it again in the Explorer or Open (Ctrl+O). This happens several times a day when I'm reading unfamiliar code or reviewing a PR, because that work means opening and closing a lot of tabs. Each time it breaks my train of thought, not just my fingers.
What's changed since this was filed: #502 now remembers where I was in each file, so a file I open again comes back at my cursor and scroll. Finding my place is solved. What's left is:
- Finding the file. No command brings back what I just closed. Back (
Ctrl+G P) only reopens a closed file if a jump there was recorded. It walks back through every position in between to get there, and it does nothing at all once the last tab is closed:GoToHistoryneeds an open tab to work. - Undo. Closing a tab throws away its undo history. VS Code keeps it for a reopened file whose contents haven't changed (its
files.restoreUndoStacksetting, on by default; users notice when an editor doesn't).
Evidence: VS Code (Ctrl+Shift+T, Reopen Closed Editor), JetBrains (Reopen Closed Tab) and every browser treat this as basic. Zed users keep running into its gaps: discussion #38324, #45198, #52695.
Options considered
- Do nothing. Reopening a file puts me back where I was in it #502 already restores your place, and
Ctrl+O's filter finds a file in a few keys. Good: no work. Bad: you still have to remember the file's name, and the undo history is still lost. This is the one gap that sends a VS Code user's fingers toCtrl+Shift+Twith nothing happening. - Make Back reopen closed files properly. Let
Ctrl+G Pwork with no tab open, and have a close count as a jump. Good: no new command. Bad: Back is about cursor positions. To reach a file closed three jumps ago you'd step through every place in between, and it would mix two ideas that VS Code users keep apart. - A "recently closed" picker. A filterable list of the files closed this session, in the style of Open recent folder. Good: gets back any of them, not only the last. Bad: it's one more dialog and one more choice for the most common case, "the one I just closed", and you can already filter
Ctrl+Oby name. - Undo close tab, one press per tab, newest first (chosen). Each press reopens the most recently closed file tab, where it was, with its undo history. Good: the browser and VS Code habit, it costs one key, and pressing it again goes further back. Bad: to reach a file closed long ago you press it many times. Option 3 can follow if that ever matters.
Proposal
A new command, Undo close tab (uct, Ctrl+Shift+T, File menu), reopens the file tab closed most recently in this session:
- Where it was. The file reopens in the group it was closed from (or the first group, if that one has gone) at its old position in the tab strip. It becomes the active tab, and the cursor and scroll come back through Reopening a file puts me back where I was in it #502.
- With its undo history. Undo and redo carry on from where they were, as long as the file on disk still holds what the tab held when it was closed. If it changed in between (another program, or Don't save when closing a dirty tab), the file reopens as it is on disk with fresh history, as any open does.
- Again and again. Each press reopens the next most recent. Close other tabs and Close all tabs add every tab they close, so pressing it repeatedly brings them back one by one.
- Nothing to reopen. If every closed file is already open again, or has been deleted, the command is dimmed in the menu and the palette, like Close tab with no tab open. A deleted file is skipped and the next one is reopened.
The palette finds it by reopen too (the command id is VS Code's workbench.action.reopenClosedEditor).
Mockup
File menu, after the close items. The u is the item's hot key:
┌ File ───────────────────────────────┐
│ ... │
│ Close tab Ctrl+W │
│ Close other tabs │
│ Close all tabs │
│ Undo close tab Ctrl+Shift+T│
│ ... │
└─────────────────────────────────────┘
F1 in the editor, Tabs column:
Tabs
← → Switch tab
Ctrl+PageDown Next tab
Ctrl+PageUp Previous tab
Ctrl+W Close tab
Ctrl+Shift+T Undo close tab
Before and after:
[ Program.cs ][ Parser.cs ][ Lexer.cs ] Ctrl+W on Parser.cs
[ Program.cs ][ Lexer.cs ] Ctrl+Shift+T
[ Program.cs ][ Parser.cs ][ Lexer.cs ] back in its slot, at line 214, Ctrl+Z still works
Scope
In: the command, key, mnemonic, File menu item and F1 row. Reopening a file into its old group and tab position. Keeping each closed file's undo history for this session while its contents on disk haven't changed. Tabs closed by Close tab, Close other tabs, Close all tabs and the tab's own close button.
Out:
- Diff, file-history, review and document tabs. Only file tabs come back.
- Remembering closed tabs across a restart or a folder switch. Switching folders isn't "closing" tabs, and Persist workspace state (last folder, open tabs) #13 already restores those.
- A picker of recently closed files (option 3).
- Keeping undo history for files that are open (it's already kept), or across a restart.
Delivery
One PR.
Decided
All of these were the Lead's calls, accepted by the stakeholder's approval.
- The name is Undo close tab, not VS Code's Reopen closed editor. Every letter of "Reopen closed tab" is already a hot key in the File menu, and "Undo close tab" is what Firefox calls it. The id keeps VS Code's name, so
reopenstill finds it in the palette. Ctrl+Shift+Tis the default key, as in VS Code and browsers. It's free, and it works like the otherCtrl+Shift+letterdefaults, so in Terminal.app it collapses ontoCtrl+T, which is already a chord prefix. Terminal.app isn't a terminal we support for these keys.- Up to 20 closed tabs are remembered. They're forgotten when you switch folders or quit. 20 is plenty for one press at a time, and it caps the undo history kept in memory.
- Undo is kept only when the file on disk matches what the tab last held. This is VS Code's rule. Anything else would let undo apply edits to text it never saw.
Original idea
I close a tab by mistake, or close one and realise a moment later I still needed it, and getting it back means finding the file again (Explorer or quick open) and then finding my place in it again: it usually reopens at line 1, with the scroll, cursor and any undo history gone. When I'm reading unfamiliar code or reviewing a PR I open and close a lot of tabs, so this happens several times a day, and each time it costs me my train of thought, not just the keystrokes.
(Evidence and Why it fits as filed: no command for it; Back is the nearest route; VS Code and JetBrains both have it; Zed users hit its edges; theme 1, Daily-driver gaps.)
Activity
a-team-app commentedon Oct 9, 2026
Recommended: High · theme 1, small · reopening a closed tab where I left off removes a several-times-a-day loss when reading and reviewing
[-]I close a tab and want it straight back, but I have to find the file and my place in it again[/-][+]I close a tab and want it straight back, but I have to find the file again and its undo is gone[/+]a-team-app commentedon Oct 17, 2026
Now in front of you: there was room in Pitched. I checked it against today's main (f0cf5de) and it still holds — nothing reopens a closed tab yet and
Ctrl+Shift+Tis still free — so it's unchanged. No questions; a plain yes and I'll break it down.a-team-app commentedon Oct 20, 2026
Broken down into one task: #578, Undo close tab. No open questions. The four Assumed items (name,
Ctrl+Shift+T, cap of 20, keep undo only when the file on disk is unchanged) are now under Decided. I checked thatCtrl+Shift+Tand the File menu letter u are both still free onmain.a-team-app commentedon Oct 23, 2026
Tried on
main(2410b02): edited and saved a file, closed it,Ctrl+Shift+Tbrought it back in its slot with the cursor where it was, andCtrl+Zstill undid my edit. Closed both tabs, so none was open, and two presses brought both back. After that, Undo close tab in the File menu was dimmed, next to itsCtrl+Shift+T. Matches the pitch, so I'm closing it.