threads / patch / 16343

patchgitk: Highlight found text only for when search type is "containing".

Subject: [PATCH] gitk: Highlight found text only for when search type is "containing".

## tl;dr

2 messages between Nov 15, 2008 and Nov 16, 2008. Diffs are folded; open one to read it.

replies: 1people: 1as markdown or json

Mark Burton· Nov 15, 2008, 23:12 UTC · lore

Highlighting the text in the commit list and comments that match the find string is useful but only really when the search type is "containing".

This patch suppresses the highlighting for the other search types.
Signed-off-by: Mark Burton <markb@ordern.com>
---
 gitk-git/gitk |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
Show changes to gitk-git/gitk +6 −3
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 3353f4a..dea8bc8 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -4302,6 +4302,7 @@ proc askfindhighlight {row id} {
     global nhighlights commitinfo iddrawn
     global findloc
     global markingmatches
+    global gdttype
 
     if {![info exists commitinfo($id)]} {
 	getcommit $id
@@ -4326,7 +4327,7 @@ proc askfindhighlight {row id} {
 		bolden_name $row mainfontbold
 	    }
 	}
-	if {$markingmatches} {
+	if {$markingmatches && $gdttype eq [mc "containing:"]} {
 	    markrowmatches $row $id
 	}
     }
@@ -5565,6 +5566,7 @@ proc drawcmitrow {row} {
     global filehighlight fhighlights findpattern nhighlights
     global hlview vhighlights
     global highlight_related rhighlights
+    global gdttype
 
     if {$row >= $numcommits} return
 
@@ -5595,7 +5597,7 @@ proc drawcmitrow {row} {
 	set iddrawn($id) 1
 	incr nrows_drawn
     }
-    if {$markingmatches} {
+    if {$markingmatches && $gdttype eq [mc "containing:"]} {
 	markrowmatches $row $id
     }
 }
@@ -6227,7 +6229,8 @@ proc findselectline {l} {
     set markingmatches 1
     set findcurline $l
     selectline $l 1
-    if {$findloc == [mc "All fields"] || $findloc == [mc "Comments"]} {
+    if {$gdttype eq [mc "containing:"] &&
+	($findloc == [mc "All fields"] || $findloc == [mc "Comments"])} {
 	# highlight the matches in the comments
 	set f [$ctext get 1.0 $commentend]
 	set matches [findmatches $f]
-- 
1.6.0.4
Mark Burton· Nov 16, 2008, 00:05 UTC · re: Mark Burton · lore

Re: [PATCH] gitk: Highlight found text only for when search type is "containing".

Hi,

The patch got sent without this blurb (not really sure how to send patches to the list with leading blurb).

Anyway, I thought I would try and stop gitk from always highlighting the text in the commit and comment panes that matches the text in the search field. To me, it only makes sense to highlight the text when the search type is "containing". For the other search types (definitely for the touching paths type), I don't really see how having occurrences of the search text highlighted helps.

I don't really understand how gitk operates but the patch does what I want. I'm sure those in the know can improve on it if what it does is useful.

Cheers,
Mark

← back to recent threads