From 976d136abd2747de8df8ce20935b3feacbdc38c2 Mon Sep 17 00:00:00 2001 From: Kent Wang Date: Fri, 18 Sep 2026 08:51:24 +0800 Subject: [PATCH] fix: One line editor can enter new line issue (#10514) * fix one line editor issue * change camel case --- .../ui/components/.client/codemirror/one-line-editor.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/insomnia/src/ui/components/.client/codemirror/one-line-editor.tsx b/packages/insomnia/src/ui/components/.client/codemirror/one-line-editor.tsx index 246bc5e484..a99a862642 100644 --- a/packages/insomnia/src/ui/components/.client/codemirror/one-line-editor.tsx +++ b/packages/insomnia/src/ui/components/.client/codemirror/one-line-editor.tsx @@ -204,14 +204,17 @@ export const OneLineEditor = forwardRef }; codeMirror.current = CodeMirror.fromTextArea(textAreaRef.current, initialOptions); codeMirror.current.on('beforeChange', (_: CodeMirror.Editor, change: CodeMirror.EditorChangeCancellable) => { - const isPaste = change.origin === 'paste' && change.update; - if (isPaste) { + const isMultiLineInsert = change.text && change.text.length > 1; + const isSingleLinePaste = change.origin === 'paste' && change.update && change.text.length === 1; + if (isMultiLineInsert || isSingleLinePaste) { const pastedText = change.text.join('\n'); const hasContent = pastedText.trim(); + // Cancel the change if it's a curl command or has no content if (isCurlCommand(pastedText) || !hasContent) { change.cancel(); return; } + // Replace vault tags id if needed let editorPasteText = change.text.join('').replace(/\n/g, ' '); if (containsExternalVaultTag(editorPasteText)) { editorPasteText = replaceVaultTagIdIfNeeded(editorPasteText);