From 93dc64e06441c602d25e6c73f894d69bcc7ae0b8 Mon Sep 17 00:00:00 2001 From: ZHAO Xudong Date: Sun, 8 Dec 2024 19:42:09 +0800 Subject: [PATCH] #3680 Only apply the first matched keyword highlight for terminal output --- src/client/components/terminal/highlight-addon.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/components/terminal/highlight-addon.js b/src/client/components/terminal/highlight-addon.js index aa0257c4e16..f9139abec90 100644 --- a/src/client/components/terminal/highlight-addon.js +++ b/src/client/components/terminal/highlight-addon.js @@ -37,7 +37,9 @@ export class KeywordHighlighterAddon { if (keyword) { try { const regex = new RegExp(`(${keyword})`, 'gi') - text = text.replace(regex, this.colorize(color)) + if (regex.test(text)) { + return text.replace(regex, this.colorize(color)) + } } catch (e) { window.store.onError(e) }