Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/util/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ export function matchString(str: string, categories: Category[] | null): Categor
const regexes: [Category, RegExp][] = categories
.filter(c => c.rule.type == 'regex')
.map(c => {
const re = RegExp(c.rule.regex, c.rule.ignore_case ? 'i' : '');
// using 'm' flag to make `$` and `^` in rules work
const re = RegExp(c.rule.regex, (c.rule.ignore_case ? 'i' : '') + 'm');
return [c, re];
});

Expand All @@ -227,6 +228,7 @@ export function matchString(str: string, categories: Category[] | null): Categor
return null;
}

// this is used only in tests
export function classifyEvents(events: IEvent[], categories: Category[]): IEvent[] {
// Compile regexes
const regexes: [Category, RegExp][] = categories
Expand Down
8 changes: 4 additions & 4 deletions src/util/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ export function getTitleAttr(bucket: { type?: string }, e: IEvent) {

export function getCategoryColorFromEvent(bucket: IBucket, e: IEvent) {
if (bucket.type == 'currentwindow') {
// NOTE: this will not work/break category rules which reference `$` or `^`
return getCategoryColorFromString(e.data.app + ' ' + e.data.title);
// using linebreak and "m" regex flag to make `$` and `^` work
return getCategoryColorFromString(e.data.app + '\n' + e.data.title);
} else if (bucket.type == 'web.tab.current') {
// NOTE: same as above
return getCategoryColorFromString(e.data.title + ' ' + e.data.url);
// same as above
return getCategoryColorFromString(e.data.title + '\n' + e.data.url);
} else if (bucket.type == 'afkstatus') {
return getColorFromString(e.data.status);
} else if (bucket.type?.startsWith('app.editor')) {
Expand Down