From 6af75bcd73557bc16861134eade01642f0101584 Mon Sep 17 00:00:00 2001 From: sagarambilpure Date: Thu, 30 Jul 2026 17:12:46 +0100 Subject: [PATCH] fix(shortcuts): reopen closed tab with Ctrl+Shift+T, works from editor focus Remap the reopen-closed-tab shortcut from Ctrl+Alt+T to Ctrl+Shift+T to match browsers and VS Code. Handle it before the text-field guard so it fires even while the Monaco editor (a hidden textarea) or any input has focus, matching browser behaviour. Update README shortcut table. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9c1e60d9-54fb-4eab-be6e-0d52b018f487 --- README.md | 2 +- src/renderer.js | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e0b9d45..8222218 100644 --- a/README.md +++ b/README.md @@ -588,7 +588,7 @@ Note++ ships with `electron-updater` wired to the GitHub releases provider — s | `Ctrl+O` | Open file | | `Ctrl+S` / `Ctrl+Shift+S` | Save / Save All | | `Ctrl+W` | Close tab | -| `Ctrl+Alt+T` | Reopen last closed tab | +| `Ctrl+Shift+T` | Reopen last closed tab | | `Ctrl+P` | Quick Open | | `Ctrl+Shift+P` | Command Palette | | `Ctrl+Shift+G` | Toggle Source Control | diff --git a/src/renderer.js b/src/renderer.js index d727ae0..2560e48 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -1503,7 +1503,7 @@ require(['vs/editor/editor.main'], () => { editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyMod.Alt | monaco.KeyCode.PageDown, () => editor.trigger('keyboard', 'cursorColumnSelectPageDown', null)); - // Ctrl+Alt+T (reopen closed tab) and Ctrl± / Ctrl0 (zoom) are wired + // Ctrl+Shift+T (reopen closed tab) and Ctrl± / Ctrl0 (zoom) are wired // as document-level shortcuts in setupGlobalShortcuts() so they fire // from whiteboard/drawio/game tabs too — Monaco's addCommand only // fires while the editor has focus. @@ -2670,7 +2670,7 @@ function initTabDrag(e, tabId, tabEl) { e.preventDefault(); } -// ── Reopen-closed-tab stack (Ctrl+Alt+T) ──────────────────────────────── +// ── Reopen-closed-tab stack (Ctrl+Shift+T) ────────────────────────────── // LIFO of snapshots taken at the moment a tab is confirmed to close // (after the "Save?" prompt, before splice). Reopen restores editor, // whiteboard, and drawio tabs — never compare views (they're transient) @@ -9475,21 +9475,25 @@ function setupAiPrefsPage() { // from double-firing. function setupGlobalShortcuts() { document.addEventListener('keydown', (e) => { - // Skip when the user is typing in a form field — don't want to steal - // Ctrl+- inside a numeric input, for example. - const t = e.target; - if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) return; - if (!e.ctrlKey && !e.metaKey) return; const k = e.key; - // Ctrl+Alt+T → reopen the most recently closed tab. - if (e.altKey && !e.shiftKey && (k === 't' || k === 'T')) { + // Reopen the most recently closed tab — Ctrl+Shift+T (matches browsers / + // VS Code). Handled *before* the text-field guard below so it fires even + // while the Monaco editor (a hidden