git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-gui: use a tristate to control the case mode in the searchbar

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Oct 20, 2011, 19:27 UTC
Message-ID
<9193677f1fef348d5b081653840e8a829ddd3e50.1319138692.git.bert.wesarg@googlemail.com>
In-Reply-To
<CAKPyHN0KCwDu2-JXAEk4wAvfOqE3jHY63aG6R9YSOoLoKwWGgQ@mail.gmail.com>

The config is now called gui.search.case and can have the three values: no/yes/smart. yes is the default.

It also resets the case detection in smart mode, when the entry field was cleared by the use.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 lib/search.tcl |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/lib/search.tcl b/lib/search.tcl
index 04a316b..ef1e555 100644
--- a/lib/search.tcl
+++ b/lib/search.tcl
@@ -26,11 +26,20 @@ constructor new {i_w i_text args} {
 	set ctext  $i_text
 
 	set default_regexpsearch [is_config_true gui.search.regexp]
-	set smartcase [is_config_true gui.search.smartcase]
-	if {$smartcase} {
+	switch -- [get_config gui.search.case] {
+	no {
 		set default_casesensitive 0
-	} else {
+		set smartcase 0
+	}
+	smart {
+		set default_casesensitive 0
+		set smartcase 1
+	}
+	yes -
+	default {
 		set default_casesensitive 1
+		set smartcase 0
+	}
 	}
 
 	set history [list]
@@ -157,12 +166,10 @@ method _incrsearch {} {
 	if {[catch {$ctext index anchor}]} {
 		$ctext mark set anchor [_get_new_anchor $this]
 	}
-	if {$smartcase} {
-		if {[regexp {[[:upper:]]} $searchstring]} {
+	if {$searchstring ne {}} {
+		if {$smartcase && [regexp {[[:upper:]]} $searchstring]} {
 			set casesensitive 1
 		}
-	}
-	if {$searchstring ne {}} {
 		set here [_do_search $this anchor mlen]
 		if {$here ne {}} {
 			$ctext see $here
@@ -175,6 +182,9 @@ method _incrsearch {} {
 			#$w.ent configure -background lightpink
 			$w.ent state pressed
 		}
+	} elseif {$smartcase} {
+		# clearing the field resets the smart case detection
+		set casesensitive 0
 	}
 }
 
-- 
1.7.7.759.gfc8c6
Previous: Bert WesargNext: Pat Thoyts
Message 2 of 3 in “Re: git-gui: still smartcase (and pull into git.git)”
  1. Bert WesargOct 19, 2011
  2. git-gui: use a tristate to control the case mode in the searchbarBert Wesarg, Oct 20, 2011
  3. Pat ThoytsOct 21, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.