Commit 027d8a8a authored by Bram Schoenmakers's avatar Bram Schoenmakers

Set priority color as the last step in the colorization

The project/context, tag and URL matching patterns are not aware of any color codes that are already prepended to a word. This affects items that appear at the start of a line.

Given a todo string where a priority color was already added:

\x1b[0mkey:value

Then the match would turn it into something like this:

\x1b[\x1b[1;32m0mkey:value\x1b[0m

So you get an ugly 0m prefix to the key:value text, because ] is a word boundary and 0m are non-whitespace characters that end up as being part of the key.

Report and suggested fix by @mruwek. It became apparent with `ls -F %k`, which puts tags at the start of a line, a not so common case that slipped through when writing the colorization code.
parent 37382021
......@@ -65,9 +65,6 @@ class PrettyPrinterColorFilter(PrettyPrinterFilter):
except KeyError:
pass
# color by priority
p_todo_str = color + p_todo_str
# color projects / contexts
p_todo_str = re.sub(
r'\B(\+|@)(\S*\w)',
......@@ -87,6 +84,9 @@ class PrettyPrinterColorFilter(PrettyPrinterFilter):
p_todo_str)
p_todo_str += NEUTRAL_COLOR
# color by priority
p_todo_str = color + p_todo_str
return p_todo_str
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment