From 7f3fc11e96ba646163ecfd339afd13c04066050f Mon Sep 17 00:00:00 2001 From: solvedDev <33347616+solvedDev@users.noreply.github.com> Date: Fri, 22 Feb 2019 18:55:34 +0100 Subject: [PATCH] v0.8.0 pt.19 - update auto-completions upon switching version - fixed undo/redo not marking a tab as unsaved --- .../components/editor_shell/JsonEditor/JsonInput.vue | 8 +++++--- src/renderer/scripts/TabSystem/CommonHistory.js | 2 ++ src/renderer/windows/Settings.js | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/renderer/components/editor_shell/JsonEditor/JsonInput.vue b/src/renderer/components/editor_shell/JsonEditor/JsonInput.vue index 3378961f6..1a3176ecd 100644 --- a/src/renderer/components/editor_shell/JsonEditor/JsonInput.vue +++ b/src/renderer/components/editor_shell/JsonEditor/JsonInput.vue @@ -62,11 +62,14 @@ this.value = TabSystem.getCurrentNavContent(); EventBus.on("updateFileNavigation", this.updateValue); EventBus.on("setWatcherInactive", () => this.watcher_active = false); + } else { + EventBus.on("updateAutoCompletions", () => this.updateAutoCompletions()); } }, destroyed() { if(this.type == "edit") { EventBus.off("updateFileNavigation", this.updateValue); + EventBus.off("updateAutoCompletions", () => this.updateAutoCompletions()); } }, watch: { @@ -167,13 +170,12 @@ } - let current_node = TabSystem.getSelected().content.get(this.file_navigation); let propose; - if(current_node) propose = current_node.propose(this.file_navigation); + if(current) propose = current.propose(this.file_navigation); else propose = []; //PLUGIN HOOK - PluginEnv.trigger("bridge:beforePropose", { propose, node: current_node }); + PluginEnv.trigger("bridge:beforePropose", { propose, node: current }); propose = propose[this.type]; if(propose == undefined || propose.length == 0 || (typeof context == "string" && context != "")) diff --git a/src/renderer/scripts/TabSystem/CommonHistory.js b/src/renderer/scripts/TabSystem/CommonHistory.js index 4a6456902..2d635e762 100644 --- a/src/renderer/scripts/TabSystem/CommonHistory.js +++ b/src/renderer/scripts/TabSystem/CommonHistory.js @@ -37,6 +37,7 @@ export class History { this.redo_arr.unshift(undo.reverse()); undo.commit(); TabSystem.setCurrentFileNav("global"); + TabSystem.setCurrentUnsaved(); return true; } /** @@ -49,6 +50,7 @@ export class History { this.undo_arr.unshift(redo.reverse()); redo.commit(); TabSystem.setCurrentFileNav("global"); + TabSystem.setCurrentUnsaved(); return true; } diff --git a/src/renderer/windows/Settings.js b/src/renderer/windows/Settings.js index e119262e5..4637ffd7e 100644 --- a/src/renderer/windows/Settings.js +++ b/src/renderer/windows/Settings.js @@ -2,6 +2,7 @@ import TabWindow from "../scripts/commonWindows/TabWindow"; import Store from "../store/index"; import SETTINGS from "../store/Settings"; import { MINECRAFT_VERSIONS } from "../scripts/constants"; +import EventBus from "../scripts/EventBus"; class ReactiveSwitch { constructor(parent, watch_key, def) { @@ -36,7 +37,7 @@ class ReactiveInput { } class ReactiveDropdown { - constructor(parent, watch_key, options, def) { + constructor(parent, watch_key, options, def, cb) { this.type = "select"; this.input = parent.data[watch_key]; this.options = options; @@ -48,6 +49,7 @@ class ReactiveDropdown { this.input = val; parent.data[watch_key] = val; parent.save(); + if(typeof cb == "function") cb(val); }; } } @@ -67,7 +69,7 @@ export default class SettingsWindow extends TabWindow { color: "grey", text: "\nTarget Minecraft Version" }, - new ReactiveDropdown(this, "target_version", MINECRAFT_VERSIONS ,{ text: "Choose a version...", key: `settings.editor.tab.target_version.${Math.random()}` }), + new ReactiveDropdown(this, "target_version", MINECRAFT_VERSIONS ,{ text: "Choose a version...", key: `settings.editor.tab.target_version.${Math.random()}` }, () => EventBus.trigger("updateAutoCompletions")), new ReactiveSwitch(this, "use_tabs", { color: "light-green", text: "Use Tabs", key: `settings.editor.tab.tabs.${Math.random()}` }), new ReactiveSwitch(this, "line_wraps", { color: "light-green", text: "Word Wrap", key: `settings.editor.tab.tabs.${Math.random()}` }), new ReactiveSwitch(this, "open_all_nodes", { color: "light-green", text: "Open All Nodes", key: `settings.editor.tab.open_all_nodes.${Math.random()}` }),