diff --git a/src/handlers/editorFileTab.js b/src/handlers/editorFileTab.js index ef39f4ac7..ffbf9f629 100644 --- a/src/handlers/editorFileTab.js +++ b/src/handlers/editorFileTab.js @@ -80,8 +80,8 @@ let dragSessionId = 0; const MIN_SCROLL_SPEED = 2; const MAX_SCROLL_SPEED = 14; -const REORDER_DURATION = 0.28; -const RELEASE_DURATION = 0.25; +const REORDER_DURATION_SECONDS = 0.28; +const RELEASE_DURATION_SECONDS = 0.25; const SPRING_EASING = [0.2, 1, 0.4, 1]; /** @type {WeakMap} */ @@ -266,7 +266,7 @@ function finishDrag(shouldSettleClone) { { duration: document.body.classList.contains("no-animation") ? 0 - : RELEASE_DURATION, + : RELEASE_DURATION_SECONDS, ease: SPRING_EASING, }, ) @@ -667,7 +667,7 @@ function animateTabReorder($parent, previousRects) { { duration: document.body.classList.contains("no-animation") ? 0 - : REORDER_DURATION, + : REORDER_DURATION_SECONDS, ease: SPRING_EASING, }, ); diff --git a/src/lib/editorManager.js b/src/lib/editorManager.js index ed3737b0a..55cbcbce0 100644 --- a/src/lib/editorManager.js +++ b/src/lib/editorManager.js @@ -2679,17 +2679,26 @@ async function EditorManager($header, $body) { const previousEditor = editor; const previousContainer = $container; const previousTouchSelectionController = touchSelectionController; + const restoreContext = () => { + editor = previousEditor; + $container = previousContainer; + touchSelectionController = previousTouchSelectionController; + }; editor = pane.editor; $container = pane.editorContainer || $container; touchSelectionController = pane.touchSelectionController || null; try { - return callback(); - } finally { - editor = previousEditor; - $container = previousContainer; - touchSelectionController = previousTouchSelectionController; + const result = callback(); + if (result && typeof result.then === "function") { + return Promise.resolve(result).finally(restoreContext); + } + restoreContext(); + return result; + } catch (error) { + restoreContext(); + throw error; } }