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

[PATCH 2/4] git-gui: add smart case search mode in searchbar

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Oct 14, 2011, 08:14 UTC
Message-ID
<9350c86dc58e6345b237de5af186718d97fdd19b.1318579823.git.bert.wesarg@googlemail.com>
In-Reply-To
<94b050c4cf7ae8df8d79112e13613244ebff4037.1318579823.git.bert.wesarg@googlemail.com>

Setting config gui.search.smartcase to true, the search mode in the searchbar (from the blame view) is by default case-insensitive. But entering an upper case letter into the search field activates the case- sensitive search mode.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 lib/search.tcl |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/lib/search.tcl b/lib/search.tcl
index ef3486f..461c66d 100644
--- a/lib/search.tcl
+++ b/lib/search.tcl
@@ -7,7 +7,8 @@ field w
 field ctext
 
 field searchstring   {}
-field casesensitive  1
+field casesensitive
+field default_casesensitive
 field searchdirn     -forwards
 
 field smarktop
@@ -18,6 +19,12 @@ constructor new {i_w i_text args} {
 	set w      $i_w
 	set ctext  $i_text
 
+	if {[is_config_true gui.search.smartcase]} {
+		set default_casesensitive 0
+	} else {
+		set default_casesensitive 1
+	}
+
 	${NS}::frame  $w
 	${NS}::label  $w.l       -text [mc Find:]
 	entry  $w.ent -textvariable ${__this}::searchstring -background lightgreen
@@ -45,6 +52,7 @@ constructor new {i_w i_text args} {
 method show {} {
 	if {![visible $this]} {
 		grid $w
+		set casesensitive $default_casesensitive
 	}
 	focus -force $w.ent
 }
@@ -125,6 +133,9 @@ method _incrsearch {} {
 	if {[catch {$ctext index anchor}]} {
 		$ctext mark set anchor [_get_new_anchor $this]
 	}
+	if {[regexp {[[:upper:]]} $searchstring]} {
+		set casesensitive 1
+	}
 	if {$searchstring ne {}} {
 		set here [_do_search $this anchor mlen]
 		if {$here ne {}} {
-- 
1.7.6.789.gb4599
Previous: Bert WesargNext: Bert Wesarg
Message 2 of 11 in “git-gui: handle config booleans without value”
  1. 1/4 git-gui: handle config booleans without valueBert Wesarg, Oct 14, 2011
  2. 2/4 git-gui: add smart case search mode in searchbarBert Wesarg, Oct 14, 2011
  3. 3/4 git-gui: add regexp search mode to the searchbarBert Wesarg, Oct 14, 2011
  4. 4/4 git-gui: add search history to searchbarBert Wesarg, Oct 14, 2011
  5. Andrew ArdillOct 16, 2011
  6. Bert WesargOct 17, 2011
  7. Pat ThoytsOct 17, 2011
  8. Andrew ArdillOct 18, 2011
  9. Pat ThoytsOct 17, 2011
  10. Bert WesargOct 18, 2011
  11. Pat ThoytsOct 18, 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.