Fix log search filtering to match against plain text instead of ANSI escape codes
Move styles array outside the parse loop in ansiToHtml so styles accumulate across sequences, and use stripAnsi when filtering live logs so search matches visible text.
This commit is contained in:
parent
a824d62058
commit
1e4d66cbe4
|
|
@ -34,6 +34,7 @@ export function ansiToHtml(text: string): string {
|
||||||
let result = ''
|
let result = ''
|
||||||
let last = 0
|
let last = 0
|
||||||
let open = false
|
let open = false
|
||||||
|
const styles: string[] = []
|
||||||
let match: RegExpExecArray | null
|
let match: RegExpExecArray | null
|
||||||
|
|
||||||
while ((match = ESC.exec(text)) !== null) {
|
while ((match = ESC.exec(text)) !== null) {
|
||||||
|
|
@ -41,7 +42,6 @@ export function ansiToHtml(text: string): string {
|
||||||
last = match.index + match[0].length
|
last = match.index + match[0].length
|
||||||
|
|
||||||
const codes = match[1] ? match[1].split(';').map(Number) : [0]
|
const codes = match[1] ? match[1].split(';').map(Number) : [0]
|
||||||
const styles: string[] = []
|
|
||||||
|
|
||||||
for (const code of codes) {
|
for (const code of codes) {
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { define } from '@because/forge'
|
import { define } from '@because/forge'
|
||||||
import type { App, LogLine as LogLineType } from '../../shared/types'
|
import type { App, LogLine as LogLineType } from '../../shared/types'
|
||||||
import { ansiToHtml } from '../ansi'
|
import { ansiToHtml, stripAnsi } from '../ansi'
|
||||||
import { getLogDates, getLogsForDate } from '../api'
|
import { getLogDates, getLogsForDate } from '../api'
|
||||||
import { isNarrow } from '../state'
|
import { isNarrow } from '../state'
|
||||||
import { LogLine, LogsContainer, LogsHeader, LogTime, Section, SectionTitle } from '../styles'
|
import { LogLine, LogsContainer, LogsHeader, LogTime, Section, SectionTitle } from '../styles'
|
||||||
|
|
@ -92,7 +92,7 @@ function LogsContent() {
|
||||||
|
|
||||||
const state = getState(currentApp.name)
|
const state = getState(currentApp.name)
|
||||||
const isLive = state.selectedDate === 'live'
|
const isLive = state.selectedDate === 'live'
|
||||||
const filteredLiveLogs = filterLogs(currentApp.logs ?? [], state.searchFilter, l => l.text)
|
const filteredLiveLogs = filterLogs(currentApp.logs ?? [], state.searchFilter, l => stripAnsi(l.text))
|
||||||
const filteredHistoricalLogs = filterLogs(state.historicalLogs, state.searchFilter, l => l)
|
const filteredHistoricalLogs = filterLogs(state.historicalLogs, state.searchFilter, l => l)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user