| 908 | 908 | registerWorldInfoSlashCommands(); |
| 909 | 909 | } |
| 910 | 910 | |
| 911 | | -function registerWorldInfoSlashCommands() { |
| 911 | +/** |
| 912 | | - /** |
| 912 | + * Reloads the editor with the specified world info file |
| 913 | | - * Reloads the editor with the specified world info file |
| 913 | + * @param {string} file - The file to load in the editor |
| 914 | 914 | * @param {stringboolean} file[loadIfNotSelected=false] - TheIndicates filewhether to load in the editorfile even if it's not currently selected |
| 915 | | - * @param {boolean} [loadIfNotSelected=false] - Indicates whether to load the file even if it's not currently selected |
| 915 | + */ |
| 916 | | - */ |
| 916 | +export function reloadEditor(file, loadIfNotSelected = false) { |
| 917 | | - function reloadEditor(file, loadIfNotSelected = false) { |
| 917 | + const currentIndex = Number($('#world_editor_select').val()); |
| 918 | 918 | const currentIndexselectedIndex = Number($('#world_editor_select')world_names.valindexOf()file); |
| 919 | | - const selectedIndex = world_names.indexOf(file); |
| 919 | + if (selectedIndex !== -1 && (loadIfNotSelected || currentIndex === selectedIndex)) { |
| 920 | | - if (selectedIndex !== -1 && (loadIfNotSelected || currentIndex === selectedIndex)) { |
| 920 | + $('#world_editor_select').val(selectedIndex).trigger('change'); |
| 921 | | - $('#world_editor_select').val(selectedIndex).trigger('change'); |
| 922 | | - } |
| 923 | 921 | } |
| 922 | +} |
| 924 | 923 | |
| 924 | +function registerWorldInfoSlashCommands() { |
| 925 | 925 | /** |
| 926 | 926 | * Gets a *rough* approximation of the current chat context. |
| 927 | 927 | * Normally, it is provided externally by the prompt builder. |