From f2158e03216db7e4937aceabde91d3f8612da2fb Mon Sep 17 00:00:00 2001 From: "n loewen (aider)" Date: Sun, 8 Jun 2025 09:57:10 +0100 Subject: [PATCH] feat: Improve search highlighting to underline all matches on the same line --- gtm | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/gtm b/gtm index eb8024c..b1da9c1 100755 --- a/gtm +++ b/gtm @@ -618,6 +618,11 @@ def draw_right_pane(stdscr, state): # Find all occurrences of the search query in the content (case-insensitive) query = state.search_query.lower() content_lower = display_content.lower() + + # First, draw the entire line with normal attributes + stdscr.addnstr(display_row, content_start, display_content, available_width) + + # Then highlight each match pos = 0 while pos < len(content_lower): match_pos = content_lower.find(query, pos) @@ -625,21 +630,12 @@ def draw_right_pane(stdscr, state): break if match_pos + len(query) <= len(display_content): - # Draw text before match - if match_pos > 0: - stdscr.addnstr(display_row, content_start, display_content[:match_pos], match_pos) - - # Draw the match with highlighting + # Draw just the match with highlighting match_text = display_content[match_pos:match_pos + len(query)] stdscr.addnstr(display_row, content_start + match_pos, match_text, len(query), content_attr) - - # Draw text after match - if match_pos + len(query) < len(display_content): - remaining_text = display_content[match_pos + len(query):] - stdscr.addnstr(display_row, content_start + match_pos + len(query), - remaining_text, len(remaining_text)) - pos = match_pos + 1 + # Move to position after this match to find the next one + pos = match_pos + len(query) display_row += 1 else: