108
*/
109
export function filterDebugEventsByText(events: readonly IChatDebugEvent[], filterText: string): readonly IChatDebugEvent[] {
111
>
const afterTimestamp = parseTimeToken(filterText, 'after');
112
>
113
>
// Strip timestamp tokens before splitting into text search terms
114
>
const textOnly = stripTimestampTokens(filterText);
115
>
const terms = textOnly.split(/\s*,\s*/).filter(t => t.length > 0);
116
>
const includeTerms = terms.filter(t => !t.startsWith('!')).map(t => t.trim());
117
>
const excludeTerms = terms.filter(t => t.startsWith('!')).map(t => t.slice(1).trim()).filter(t => t.length > 0);
118
>
119
>
return events.filter(e => {
120
>
// Timestamp bounds
121
>
const time = e.created.getTime();
122
>
if (beforeTimestamp !== undefined && time > beforeTimestamp) {
123
return false;
124
}
126
return false;
127
}
129
>
if (excludeTerms.some(term => debugEventMatchesText(e, term))) {
130
return false;
131
}
133
return includeTerms.some(term => debugEventMatchesText(e, term));
134
}
135
return true;
137
>
}
138
139
export interface DebugEventFilterOptions {