From 99fa15da36ed8cc37640f50bfa718da6fbcd6ac5 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Fri, 23 Sep 2011 15:40:23 +0200 Subject: [PATCH] BUG: Pattern "(X)" anywhere highlighted as prioritized. According to the "Todo.txt Format" specs, "Rule 1: If a priority exists, it ALWAYS appears first." Adapt AWK filtering to match priorities only directly after the task number added by the _list processing, and also matching the required trailing space. --- tests/t1330-ls-highlighting.sh | 16 ++++++++++++++++ todo.sh | 5 ++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/t1330-ls-highlighting.sh b/tests/t1330-ls-highlighting.sh index aa3db44..d5d0f0e 100755 --- a/tests/t1330-ls-highlighting.sh +++ b/tests/t1330-ls-highlighting.sh @@ -166,4 +166,20 @@ test_todo_session 'highlighting with hidden contexts/projects' < todo.txt <>> todo.sh ls +1 (D) some prioritized task +2 not prioritized +3 should not be seen as PRIORITIZE(D) task +-- +TODO: 3 of 3 tasks shown +EOF + test_done diff --git a/todo.sh b/todo.sh index a21356e..04718ca 100755 --- a/todo.sh +++ b/todo.sh @@ -720,11 +720,10 @@ _list() { return color } { - pos = match($0, /\([A-Z]\)/) if (match($0, /^[0-9]+ x /)) { print highlight("COLOR_DONE") $0 highlight("DEFAULT") - } else if (pos > 0) { - clr = highlight("PRI_" substr($0, pos+1, 1)) + } else if (match($0, /^[0-9]+ \([A-Z]\)[[:space:]]/)) { + clr = highlight("PRI_" substr($0, RSTART + RLENGTH - 3, 1)) print ( clr ? clr : highlight("PRI_X") ) $0 highlight("DEFAULT") } else { print } }