@@ -205,8 +205,10 @@ const LogsRenderer = ({
205
205
206
206
function createMarkup ( {
207
207
log,
208
- useCurrentSelectionColor = false ,
208
+ currentIndex = - 1 ,
209
209
targetSearchKey = searchKey ,
210
+ searchMatchResults = null ,
211
+ searchIndex = '' ,
210
212
} : CreateMarkupPropsType ) : CreateMarkupReturnType {
211
213
let isSearchKeyPresent = false
212
214
try {
@@ -226,11 +228,12 @@ const LogsRenderer = ({
226
228
// Question: Can we directly set it as true inside the replace function?
227
229
isSearchKeyPresent = isSearchKeyPresent || searchRegex . test ( part )
228
230
acc . push (
229
- part . replace (
230
- searchRegex ,
231
- ( match ) =>
232
- `\x1B[0m\x1B[48;2;${ useCurrentSelectionColor ? '0;102;204' : '197;141;54' } m${ match } \x1B[0m${ index > 0 ? availableEscapeCodes [ index - 1 ] : '' } ` ,
233
- ) ,
231
+ part . replace ( searchRegex , ( match ) => {
232
+ if ( searchIndex ) {
233
+ searchMatchResults ?. push ( searchIndex )
234
+ }
235
+ return `\x1B[0m\x1B[48;2;${ searchMatchResults && currentIndex === searchMatchResults . length - 1 ? '0;102;204' : '197;141;54' } m${ match } \x1B[0m${ index > 0 ? availableEscapeCodes [ index - 1 ] : '' } `
236
+ } ) ,
234
237
)
235
238
} catch {
236
239
acc . push ( part )
@@ -360,16 +363,22 @@ const LogsRenderer = ({
360
363
// Ideally in case of parallel build should receive stage name with logs
361
364
// NOTE: For now would always append log to last stage, can show a loader on stage tiles till processed
362
365
if ( acc . length > 0 ) {
366
+ const lastStage = acc [ acc . length - 1 ]
367
+
368
+ const searchIndex = getLogSearchIndex ( {
369
+ stageIndex : acc . length - 1 ,
370
+ lineNumberInsideStage : lastStage . logs . length ,
371
+ } )
372
+
363
373
// In case targetSearchKey is not present createMarkup will internally fallback to searchKey
364
374
const { __html, isSearchKeyPresent } = createMarkup ( {
365
375
log : streamItem ,
366
- // NOTE: the last matched search result was added to the searchMatchResults list
367
- // therefore if currentSearchIndex matches it's length then paint it blue if searchKey is present
368
- useCurrentSelectionColor : currentIndex === searchMatchResults . length ,
376
+ currentIndex,
377
+ searchMatchResults,
369
378
targetSearchKey,
379
+ searchIndex,
370
380
} )
371
381
372
- const lastStage = acc [ acc . length - 1 ]
373
382
lastStage . logs . push ( __html )
374
383
if ( isSearchKeyPresent ) {
375
384
lastStage . isOpen = getIsStageOpen (
@@ -384,13 +393,6 @@ const LogsRenderer = ({
384
393
}
385
394
386
395
searchKeyStatusMap [ lastStage . stage ] [ lastStage . startTime ] = true
387
-
388
- searchMatchResults . push (
389
- getLogSearchIndex ( {
390
- stageIndex : acc . length - 1 ,
391
- lineNumberInsideStage : lastStage . logs . length - 1 ,
392
- } ) ,
393
- )
394
396
}
395
397
}
396
398
0 commit comments