diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index 99ac56f2b..83377d7ba 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -885,9 +885,15 @@ function setWorldInfoSettings(settings, data) { } function registerWorldInfoSlashCommands() { - function reloadEditor(file) { + /** + * Reloads the editor with the specified world info file + * @param {string} file - The file to load in the editor + * @param {boolean} [loadIfNotSelected=false] - Indicates whether to load the file even if it's not currently selected + */ + function reloadEditor(file, loadIfNotSelected = false) { + const currentIndex = $('#world_editor_select').val(); const selectedIndex = world_names.indexOf(file); - if (selectedIndex !== -1) { + if (selectedIndex !== -1 && (loadIfNotSelected || currentIndex === selectedIndex)) { $('#world_editor_select').val(selectedIndex).trigger('change'); } }