From 17c349973db647cc7b44d6a14d6ec9959ad1f078 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Fri, 13 Jan 2023 13:51:16 +0000 Subject: [PATCH] Fixed file loading bug where the wrong input is set --- src/web/waiters/InputWaiter.mjs | 5 ++++- src/web/workers/InputWorker.mjs | 8 +++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/web/waiters/InputWaiter.mjs b/src/web/waiters/InputWaiter.mjs index 9d827396..3a63321d 100644 --- a/src/web/waiters/InputWaiter.mjs +++ b/src/web/waiters/InputWaiter.mjs @@ -485,7 +485,10 @@ class InputWaiter { async set(inputNum, inputData, silent=false) { return new Promise(function(resolve, reject) { const activeTab = this.manager.tabs.getActiveTab("input"); - if (inputNum !== activeTab) return; + if (inputNum !== activeTab) { + this.changeTab(inputNum, this.app.options.syncTabs); + return; + } // Update current character encoding this.inputChrEnc = inputData.encoding; diff --git a/src/web/workers/InputWorker.mjs b/src/web/workers/InputWorker.mjs index b3ac4e4a..a24c7cd8 100644 --- a/src/web/workers/InputWorker.mjs +++ b/src/web/workers/InputWorker.mjs @@ -434,8 +434,7 @@ self.updateTabHeader = function(inputNum) { * @param {boolean} inputData.silent - If false, the manager statechange event will be fired */ self.setInput = function(inputData) { - const inputNum = inputData.inputNum; - const silent = inputData.silent; + const {inputNum, silent} = inputData; const input = self.getInputObj(inputNum); if (input === undefined || input === null) return; @@ -695,8 +694,7 @@ self.terminateLoaderWorker = function(id) { * @param {number} filesData.activeTab - The active tab in the UI */ self.loadFiles = function(filesData) { - const files = filesData.files; - const activeTab = filesData.activeTab; + const {files, activeTab} = filesData; let lastInputNum = -1; const inputNums = []; for (let i = 0; i < files.length; i++) { @@ -735,7 +733,7 @@ self.loadFiles = function(filesData) { } self.getLoadProgress(); - self.setInput({inputNum: activeTab, silent: true}); + self.setInput({inputNum: lastInputNum, silent: true}); }; /**