From 2af2ad629d4f15aa53389cc2c12ce39f604f1df7 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sun, 21 Jul 2024 12:58:21 -0500 Subject: [PATCH] Try to account for situations where the URL folding is past the max length for the truncation so the user can see why this is a fold. Remove missed debug messages. --- shared/naturalcrit/codeEditor/codeEditor.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index cc74a6f0a..a96feb723 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -437,9 +437,13 @@ const CodeEditor = createClass({ text = text.replace('{', '').trim(); // Extra data url chomping - console.log(text); - text = text.indexOf('data:') > -1 ? `${text.slice(0, text.indexOf('data:') + 5)} ...` : text; - console.log(text); + // Try to make it pretty... + const startOfData = text.indexOf('data:'); + if(startOfData) { + text = (startOfData > maxLength) ? + `${text.slice(0, text.indexOf(':') + 1)} ... ${text.slice(startOfData, startOfData + 5)} ...` : + `${text.slice(0, text.indexOf('data:') + 5)} ...`; + } if(text.length > maxLength) text = `${text.slice(0, maxLength)}...`;