Commit 8422217e authored by Bram Schoenmakers's avatar Bram Schoenmakers

Some fixes regarding color sequences in todo items.

This is a revert of commit fbed527f, which resulted in too many items
after a project/context being highlighted.

Instead, don't print a NEUTRAL_COLOR code at the end of the todo, but
only when we finish applying all the color codes. This makes sure that
the regexp to match a project/context also works at the end of a line.

Also removed some logic to remove multiple sequences of NEUTRAL_COLOR at
the end of the line, this is not necessary.
parent 2a03b582
...@@ -56,13 +56,13 @@ class PrettyPrinterColorFilter(PrettyPrinterFilter): ...@@ -56,13 +56,13 @@ class PrettyPrinterColorFilter(PrettyPrinterFilter):
except KeyError: except KeyError:
pass pass
p_todo_str = color + p_todo_str + NEUTRAL_COLOR p_todo_str = color + p_todo_str
if config().highlight_projects_contexts(): if config().highlight_projects_contexts():
p_todo_str = re.sub( p_todo_str = re.sub(
r'\B(\+|@)([^\033]*\w)', r'\B(\+|@)(\S*\w)',
lambda m: ( lambda m: (
context_color if m.group(0)[0] == "@" context_color if m.group(0)[0] == "@"
else project_color)+m.group(0)+color, else project_color) + m.group(0) + color,
p_todo_str) p_todo_str)
# tags # tags
...@@ -77,11 +77,6 @@ class PrettyPrinterColorFilter(PrettyPrinterFilter): ...@@ -77,11 +77,6 @@ class PrettyPrinterColorFilter(PrettyPrinterFilter):
p_todo_str += NEUTRAL_COLOR p_todo_str += NEUTRAL_COLOR
# change any group of reduntant multiple NEUTRAL_GROUP occurrence to
# only one
p_todo_str = re.sub(r'(' + re.escape(NEUTRAL_COLOR) + ')+',
NEUTRAL_COLOR, p_todo_str)
return p_todo_str return p_todo_str
class PrettyPrinterIndentFilter(PrettyPrinterFilter): class PrettyPrinterIndentFilter(PrettyPrinterFilter):
......
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