From e4c9c81f8234ca01a952db13954968b0e56b46a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20B?= Date: Tue, 5 Mar 2024 19:19:29 +0100 Subject: [PATCH] [BUGFIX] Fix prettify (#23) --- intellij-plugin/gradle.properties | 2 +- ui/src/components/forms/ResponseBodyEditor.tsx | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/intellij-plugin/gradle.properties b/intellij-plugin/gradle.properties index 5d3053d..fd8bade 100644 --- a/intellij-plugin/gradle.properties +++ b/intellij-plugin/gradle.properties @@ -1,7 +1,7 @@ pluginGroup=com.lemick pluginName=hoverfly-ui-intellij-plugin pluginRepositoryUrl=https://github.com/Lemick/hoverfly-ui -pluginVersion=1.1.0 +pluginVersion=1.1.1 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild=222 pluginUntilBuild=233.* diff --git a/ui/src/components/forms/ResponseBodyEditor.tsx b/ui/src/components/forms/ResponseBodyEditor.tsx index 49d4e3e..440a8ae 100644 --- a/ui/src/components/forms/ResponseBodyEditor.tsx +++ b/ui/src/components/forms/ResponseBodyEditor.tsx @@ -1,4 +1,4 @@ -import React, { useMemo, useRef, useState } from 'react'; +import React, { useEffect, useMemo, useRef, useState } from 'react'; import MonacoEditor, { Monaco, OnMount } from '@monaco-editor/react'; import { isJSON } from '@/services/json-service'; import { editor } from 'monaco-editor'; @@ -20,6 +20,12 @@ const ResponseBodyEditor = ({ value = '', onChange }: Props) => { const [editorHeightPx, setEditorHeightPx] = useState(100); const { appliedTheme } = useTheme(); + useEffect(() => { + if (!editorRef.current?.hasTextFocus() && editorRef.current?.getValue() != value) { + editorRef.current?.setValue(value); + } + }, [value]); + const onEditorMount: OnMount = (editor, monaco) => { editorRef.current = editor; monacoRef.current = monaco;