Fix substitution for hiding contexts/projects

When using the -+ or -@ option to hide project or context names in list
output, the color reset sequence was being deleted if the project/context
was at the end of the line.

For example, with the following tasks:

    (B) with priority, ending in a +project
    task that shouldn't be highlighted

Running 'todo.sh -+ list' would hide the "+project" from the first task,
but would also remove the color reset sequence ^[[0m at the end.  The
color from the prioritized task would continue to the next lines.

This commit fixes the problem and adds a test to verify the fix.
This commit is contained in:
Nick Wilson
2011-01-23 15:40:13 -08:00
parent 82c8349499
commit f1d339a537
2 changed files with 20 additions and 2 deletions

View File

@@ -148,4 +148,22 @@ TODO: 4 marked as done.
TODO: 5 of 5 tasks shown TODO: 5 of 5 tasks shown
EOF EOF
# check highlighting with hidden contexts/projects
#
cat > todo.txt <<EOF
(A) +project at the beginning, with priority
(B) with priority, ending in a +project
(C) @context at the beginning, with priority
(Z) with priority, ending in a @context
EOF
test_todo_session 'highlighting with hidden contexts/projects' <<EOF
>>> todo.sh -+ -@ list
1 (A) at the beginning, with priority
2 (B) with priority, ending in a
3 (C) at the beginning, with priority
4 (Z) with priority, ending in a
--
TODO: 4 of 4 tasks shown
EOF
test_done test_done

View File

@@ -360,7 +360,7 @@ do
unset HIDE_CONTEXTS_SUBSTITUTION unset HIDE_CONTEXTS_SUBSTITUTION
else else
## One or odd value -- hide context names ## One or odd value -- hide context names
export HIDE_CONTEXTS_SUBSTITUTION='[[:space:]]@[^[:space:]]\{1,\}' export HIDE_CONTEXTS_SUBSTITUTION='[[:space:]]@[[:graph:]]\{1,\}'
fi fi
;; ;;
'+' ) '+' )
@@ -376,7 +376,7 @@ do
unset HIDE_PROJECTS_SUBSTITUTION unset HIDE_PROJECTS_SUBSTITUTION
else else
## One or odd value -- hide project names ## One or odd value -- hide project names
export HIDE_PROJECTS_SUBSTITUTION='[[:space:]][+][^[:space:]]\{1,\}' export HIDE_PROJECTS_SUBSTITUTION='[[:space:]][+][[:graph:]]\{1,\}'
fi fi
;; ;;
a ) a )