From 9fd1c0f932109cfa84869fa17e65e846a8fd6b64 Mon Sep 17 00:00:00 2001 From: jos Date: Wed, 5 Feb 2020 11:46:23 +0100 Subject: [PATCH] Fix undo/redo buttons in mode `code` not always updating --- HISTORY.md | 5 +++++ src/js/textmode.js | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index cc9863d..d1f8b4c 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,11 @@ https://github.com/josdejong/jsoneditor +## 2020-02-05, version 8.5.2 + +- Fix undo/redo buttons in mode `code` not always updating. + + ## 2020-02-05, version 8.5.1 - Fix broken build. diff --git a/src/js/textmode.js b/src/js/textmode.js index b75b551..667f595 100644 --- a/src/js/textmode.js +++ b/src/js/textmode.js @@ -669,7 +669,7 @@ textmode.destroy = function () { textmode.compact = function () { const json = this.get() const text = JSON.stringify(json) - this._setText(text, false) + this.updateText(text) } /** @@ -678,7 +678,7 @@ textmode.compact = function () { textmode.format = function () { const json = this.get() const text = JSON.stringify(json, null, this.indentation) - this._setText(text, false) + this.updateText(text) } /** @@ -687,7 +687,7 @@ textmode.format = function () { textmode.repair = function () { const text = this.getText() const repairedText = repair(text) - this._setText(repairedText, false) + this.updateText(repairedText) } /** @@ -779,9 +779,12 @@ textmode._setText = function (jsonText, clearHistory) { if (me.aceEditor) { me.aceEditor.session.getUndoManager().reset() } - }, 0) + }) } + + setTimeout(() => this._updateHistoryButtons()) } + // validate JSON schema this._debouncedValidate() }