From fcf42e3233f7d9acec1901fa5df24ba01e3de956 Mon Sep 17 00:00:00 2001 From: Micah Jerome Ellison Date: Sat, 9 May 2020 15:13:16 -0700 Subject: [PATCH] Fix duplicate text in multiple tag search by removing selective coloring on searched tags only #926 (#948) --- features/tagging.feature | 13 ++++++++++++- jrnl/util.py | 9 +-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/features/tagging.feature b/features/tagging.feature index b20c2b3d..22bed636 100644 --- a/features/tagging.feature +++ b/features/tagging.feature @@ -107,4 +107,15 @@ Feature: Tagging 2013-06-10 15:40 I met with @dan. | As alway's he shared his latest @idea on how to rule the world with me. | inst - """ \ No newline at end of file + """ + + Scenario: Searching a journal for multiple tags with -and should display entries with those tags. + Given we use the config "tags.yaml" + When we run "jrnl -and @idea @journal" + Then the output should be + """ + 2013-04-09 15:39 I have an @idea: + | (1) write a command line @journal software + | (2) ??? + | (3) PROFIT! + """ diff --git a/jrnl/util.py b/jrnl/util.py index 0e50065f..8033306b 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -225,14 +225,7 @@ def highlight_tags_with_background_color(entry, text, color, is_title=False): config = entry.journal.config if config["highlight"]: # highlight tags - if entry.journal.search_tags: - text_fragments = [] - for tag in entry.journal.search_tags: - text_fragments.extend( - re.split(re.compile(f"({re.escape(tag)})", re.IGNORECASE), text) - ) - else: - text_fragments = re.split(entry.tag_regex(config["tagsymbols"]), text) + text_fragments = re.split(entry.tag_regex(config["tagsymbols"]), text) # Colorizing tags inside of other blocks of text final_text = ""