From be8fa82a74797b3d8d38e539eb70093a10f2a07d Mon Sep 17 00:00:00 2001 From: Jack Kavanagh Date: Wed, 16 Nov 2022 16:22:58 +0000 Subject: [PATCH] fix nunjucks regression (#5433) --- .../insomnia/src/ui/components/codemirror/code-editor.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/insomnia/src/ui/components/codemirror/code-editor.tsx b/packages/insomnia/src/ui/components/codemirror/code-editor.tsx index 1f66d57be..18267ac1d 100644 --- a/packages/insomnia/src/ui/components/codemirror/code-editor.tsx +++ b/packages/insomnia/src/ui/components/codemirror/code-editor.tsx @@ -191,7 +191,7 @@ export const CodeEditor = forwardRef(({ Tab: (cm: CodeMirror.Editor) => cm.somethingSelected() ? cm.indentSelection('add') : cm.replaceSelection(indentChars, 'end'), }; const { handleRender, handleGetRenderContext } = useGatedNunjucks({ disabled: !enableNunjucks }); - const prettifyXML = (code: string, filter?:string) => { + const prettifyXML = (code: string, filter?: string) => { if (updateFilter && filter) { try { const results = queryXPath(code, filter); @@ -208,7 +208,7 @@ export const CodeEditor = forwardRef(({ return code; } }; - const prettifyJSON = (code: string, filter?:string) => { + const prettifyJSON = (code: string, filter?: string) => { try { let jsonString = code; if (updateFilter && filter) { @@ -305,7 +305,7 @@ export const CodeEditor = forwardRef(({ extraKeys: CodeMirror.normalizeKeyMap(extraKeys), gutters: showGuttersAndLineNumbers ? ['CodeMirror-lint-markers', 'CodeMirror-linenumbers', 'CodeMirror-foldgutter'] : [], foldOptions: { widget: (from: CodeMirror.Position, to: CodeMirror.Position) => widget(codeMirror.current, from, to) }, - mode: normalizeMimeType(mode), + mode: !handleRender ? normalizeMimeType(mode) : { name: 'nunjucks', baseMode: normalizeMimeType(mode) }, environmentAutocomplete: { getVariables: async () => !handleGetRenderContext ? [] : (await handleGetRenderContext())?.keys || [], getTags: async () => !handleGetRenderContext ? [] : (await getTagDefinitions()).map(transformEnums).flat(), @@ -468,7 +468,7 @@ export const CodeEditor = forwardRef(({ useEffect(() => codeMirror.current?.setOption('info', infoOptions), [infoOptions]); useEffect(() => codeMirror.current?.setOption('jump', jumpOptions), [jumpOptions]); useEffect(() => codeMirror.current?.setOption('lint', lintOptions), [lintOptions]); - useEffect(() => codeMirror.current?.setOption('mode', normalizeMimeType(mode)), [mode]); + useEffect(() => codeMirror.current?.setOption('mode', !handleRender ? normalizeMimeType(mode) : { name: 'nunjucks', baseMode: normalizeMimeType(mode) }), [handleRender, mode]); useImperativeHandle(ref, () => ({ setValue: value => codeMirror.current?.setValue(value),