From 7403d7c5129d70e9b8a7bdfde492dadb3ede8260 Mon Sep 17 00:00:00 2001 From: Geert Hesselink Date: Wed, 21 Jun 2023 12:18:53 +0200 Subject: [PATCH 1/5] adjust for border syntax check --- ui/src/SyntaxResult.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/src/SyntaxResult.js b/ui/src/SyntaxResult.js index 7b6317f0..6a82fe1b 100644 --- a/ui/src/SyntaxResult.js +++ b/ui/src/SyntaxResult.js @@ -41,7 +41,10 @@ export default function SyntaxResult({ content, status }) { ".MuiTreeItem-content.Mui-expanded .subcaption" : { visibility: "visible" }, "table": { borderCollapse: 'collapse', fontSize: '80%' }, "td, th": { padding: '0.2em 0.5em', verticalAlign: 'top' }, - ".pre": { whiteSpace: 'pre', display: 'block' }, + ".pre": { + whiteSpace: 'pre-wrap', + wordBreak: 'break-word', + }, ".mono": { fontFamily: 'monospace, monospace', marginTop: '0.3em' } }} > From 4ac66219b269e4f60f670ee5b3430d220b32bae9 Mon Sep 17 00:00:00 2001 From: Geert Hesselink Date: Wed, 21 Jun 2023 18:45:14 +0200 Subject: [PATCH 2/5] modify error indicator sign --- ui/src/SyntaxResult.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ui/src/SyntaxResult.js b/ui/src/SyntaxResult.js index 6a82fe1b..3486fb96 100644 --- a/ui/src/SyntaxResult.js +++ b/ui/src/SyntaxResult.js @@ -14,7 +14,7 @@ export default function SyntaxResult({ content, status }) { const handleChangePage = (_, newPage) => { setPage(newPage); - }; + }; useEffect(() => { setRows(content.slice(page * 10, page * 10 + 10)) @@ -51,6 +51,10 @@ export default function SyntaxResult({ content, status }) { { rows.length ? rows.map(item => { + const msg_parts = item.msg.split('\n') + const whitespaces = msg_parts[4].match(/\s*/)[0].length; + const modifiedStr = `${msg_parts[3].substring(0, whitespaces)}${msg_parts[3][whitespaces]}${msg_parts[3].substring(whitespaces + 1)}`; + return } defaultExpandIcon={}> {(item.error_type || 'syntax_error').replace('_', ' ')}}> @@ -64,7 +68,8 @@ export default function SyntaxResult({ content, status }) { {item.column} {item.msg.split('\n').slice(0, -2).join('\n')} - {item.msg.split('\n').slice(-2).join('\n')} +
{} + From 4116dfad91895dfb5d8a46c6612a5abfeac96b8b Mon Sep 17 00:00:00 2001 From: Geert Hesselink Date: Wed, 21 Jun 2023 19:01:28 +0200 Subject: [PATCH 3/5] reverse selection & clearer variables --- ui/src/SyntaxResult.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/src/SyntaxResult.js b/ui/src/SyntaxResult.js index 3486fb96..1e446a58 100644 --- a/ui/src/SyntaxResult.js +++ b/ui/src/SyntaxResult.js @@ -52,8 +52,9 @@ export default function SyntaxResult({ content, status }) { { rows.length ? rows.map(item => { const msg_parts = item.msg.split('\n') - const whitespaces = msg_parts[4].match(/\s*/)[0].length; - const modifiedStr = `${msg_parts[3].substring(0, whitespaces)}${msg_parts[3][whitespaces]}${msg_parts[3].substring(whitespaces + 1)}`; + const whitespaces = msg_parts[msg_parts.length -1].match(/\s*/)[0].length; + const error_instance = msg_parts[msg_parts.length - 2] + const modifiedStr = `${error_instance.substring(0, whitespaces)}${error_instance[whitespaces]}${error_instance.substring(whitespaces + 1)}`; return } defaultExpandIcon={}> From 2634fe16d23e3a951f6fc8c8fac0d38559cd3858 Mon Sep 17 00:00:00 2001 From: Geert Hesselink Date: Thu, 29 Jun 2023 13:39:41 +0200 Subject: [PATCH 4/5] change regex, use react fragment --- ui/src/SyntaxResult.js | 45 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/ui/src/SyntaxResult.js b/ui/src/SyntaxResult.js index 1e446a58..e3f8d4ad 100644 --- a/ui/src/SyntaxResult.js +++ b/ui/src/SyntaxResult.js @@ -20,6 +20,28 @@ export default function SyntaxResult({ content, status }) { setRows(content.slice(page * 10, page * 10 + 10)) }, [page, content]); + function renderMessage(error_instance, numWhitespace, numHighlight) { + const beforeHighlight = error_instance.substring(0, numWhitespace); + const highlightedChar = error_instance.substring(numWhitespace, numWhitespace + numHighlight); + const afterHighlight = error_instance.substring(numWhitespace + numHighlight); + return ( + + {beforeHighlight} + + {highlightedChar} + + {afterHighlight} + + ); + }; + return ( { rows.length ? rows.map(item => { - const msg_parts = item.msg.split('\n') - const whitespaces = msg_parts[msg_parts.length -1].match(/\s*/)[0].length; - const error_instance = msg_parts[msg_parts.length - 2] - const modifiedStr = `${error_instance.substring(0, whitespaces)}${error_instance[whitespaces]}${error_instance.substring(whitespaces + 1)}`; + const msg_parts = item.msg.split('\n'); + const [_, numWhitespace, numHighlight] = msg_parts[msg_parts.length -1].match(/(\s*)(\^+)/).map(s => s.length); + const error_instance = msg_parts[msg_parts.length - 2]; + + const errorMessage = renderMessage( + error_instance, + numWhitespace, + numHighlight + ); + + + // const beforeHighlight = error_instance.substring(0, numWhitespace); + // const highlightedChar = error_instance.substring(numWhitespace, numWhitespace + numHighlight); + // const afterHighlight = error_instance.substring(numWhitespace + numHighlight); + + + // debugger; return } defaultExpandIcon={}> @@ -70,7 +105,7 @@ export default function SyntaxResult({ content, status }) { {item.msg.split('\n').slice(0, -2).join('\n')}
{} - + {errorMessage} From 17c11d5e590f2a2ddd6c1a53975de78e8345280b Mon Sep 17 00:00:00 2001 From: Geert Hesselink Date: Thu, 29 Jun 2023 13:41:44 +0200 Subject: [PATCH 5/5] remove unused code --- ui/src/SyntaxResult.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ui/src/SyntaxResult.js b/ui/src/SyntaxResult.js index e3f8d4ad..f937f4e2 100644 --- a/ui/src/SyntaxResult.js +++ b/ui/src/SyntaxResult.js @@ -84,13 +84,6 @@ export default function SyntaxResult({ content, status }) { ); - // const beforeHighlight = error_instance.substring(0, numWhitespace); - // const highlightedChar = error_instance.substring(numWhitespace, numWhitespace + numHighlight); - // const afterHighlight = error_instance.substring(numWhitespace + numHighlight); - - - // debugger; - return } defaultExpandIcon={}> {(item.error_type || 'syntax_error').replace('_', ' ')}}>