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

[PATCH 1/2] git-gui: implement proc select_path_in_widget

From
Birger Skogeng Pedersen <birger.sp@gmail.com>
Date
Oct 7, 2019, 17:11 UTC
Message-ID
<20191007171145.1259-1-birger.sp@gmail.com>
In-Reply-To
<CAGr--=KXpt7GzqPpm1BCrsc1jhfaXeCT-XrWKNvq2pLtgAbSwQ@mail.gmail.com>
Signed-off-by: Birger Skogeng Pedersen <birger.sp@gmail.com>
---
 git-gui.sh | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/git-gui.sh b/git-gui.sh
index fd476b6..b7f4d1e 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -2669,25 +2669,31 @@ proc show_less_context {} {
 }
 
 proc focus_widget {widget} {
-	global file_lists last_clicked selected_paths
-	global file_lists_last_clicked
+	global file_lists
 
 	if {[llength $file_lists($widget)] > 0} {
-		set path $file_lists_last_clicked($widget)
-		set index [lsearch -sorted -exact $file_lists($widget) $path]
-		if {$index < 0} {
-			set index 0
-			set path [lindex $file_lists($widget) $index]
-		}
-
+		select_path_in_widget $widget
 		focus $widget
-		set last_clicked [list $widget [expr $index + 1]]
-		array unset selected_paths
-		set selected_paths($path) 1
-		show_diff $path $widget
 	}
 }
 
+proc select_path_in_widget {widget} {
+	global file_lists last_clicked selected_paths
+	global file_lists_last_clicked
+
+	set path $file_lists_last_clicked($widget)
+	set index [lsearch -sorted -exact $file_lists($widget) $path]
+	if {$index < 0} {
+		set index 0
+		set path [lindex $file_lists($widget) $index]
+	}
+
+	set last_clicked [list $widget [expr $index + 1]]
+	array unset selected_paths
+	set selected_paths($path) 1
+	show_diff $path $widget
+}
+
 proc toggle_commit_type {} {
 	global commit_type_is_amend
 	set commit_type_is_amend [expr !$commit_type_is_amend]
-- 
2.23.0.windows.1
Previous: Birger Skogeng PedersenNext: Birger Skogeng Pedersen
Message 11 of 22 in “git-gui: automatically move focus to staged file before typing commit message?”
  1. Birger Skogeng PedersenSep 14, 2019
  2. Pratyush YadavSep 14, 2019
  3. Johannes SixtSep 14, 2019
  4. Pratyush YadavSep 14, 2019
  5. Birger Skogeng PedersenSep 15, 2019
  6. Pratyush YadavSep 16, 2019
  7. Birger Skogeng PedersenSep 26, 2019
  8. Pratyush YadavSep 26, 2019
  9. Birger Skogeng PedersenSep 26, 2019
  10. Birger Skogeng PedersenOct 7, 2019
  11. 1/2 git-gui: implement proc select_path_in_widgetBirger Skogeng Pedersen, Oct 7, 2019
  12. 2/2 git-gui: select staged on ui_comm focusBirger Skogeng Pedersen, Oct 7, 2019
  13. Pratyush YadavOct 16, 2019
  14. Pratyush YadavOct 13, 2019
  15. Birger Skogeng PedersenOct 15, 2019
  16. Pratyush YadavOct 16, 2019
  17. Birger Skogeng PedersenOct 17, 2019
  18. Johannes SixtOct 17, 2019
  19. Birger Skogeng PedersenOct 17, 2019
  20. Pratyush YadavOct 17, 2019
  21. Pratyush YadavOct 8, 2019
  22. Birger Skogeng PedersenOct 8, 2019

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.