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

[PATCH 1/2] git-gui: Delay rescan until idle time

From
Stefan Haller <stefan@haller-berlin.de>
Date
Nov 1, 2020, 17:05 UTC
Message-ID
<20201101170505.71246-2-stefan@haller-berlin.de>
In-Reply-To
<20201101170505.71246-1-stefan@haller-berlin.de>

This is to ensure that a rescan is only performed once, even if it is requested multiple times during one event. We don't need this yet, because we only ever call do_rescan once per event so far; this is going to change with the next commit, when we also call it from FocusIn.

Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
---
 git-gui.sh | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/git-gui.sh b/git-gui.sh
index 867b8ce..8864c14 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -2376,8 +2376,21 @@ proc do_quit {{rc {1}}} {
 	destroy .
 }
 
+# Not to be called directly; use schedule_rescan instead
 proc do_rescan {} {
+	global rescan_id
+
 	rescan ui_ready
+	unset rescan_id
+}
+
+proc schedule_rescan {} {
+	global rescan_id
+
+	if {[info exists rescan_id]} {
+		after cancel $rescan_id
+	}
+	set rescan_id [after idle do_rescan]
 }
 
 proc ui_do_rescan {} {
@@ -3683,7 +3696,7 @@ set ui_diff_applyhunk [$ctxm index last]
 lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state]
 $ctxm add command \
 	-label [mc "Apply/Reverse Line"] \
-	-command {apply_or_revert_range_or_line $cursorX $cursorY 0; do_rescan}
+	-command {apply_or_revert_range_or_line $cursorX $cursorY 0; schedule_rescan}
 set ui_diff_applyline [$ctxm index last]
 lappend diff_actions [list $ctxm entryconf $ui_diff_applyline -state]
 $ctxm add separator
@@ -3694,12 +3707,12 @@ set ui_diff_reverthunk [$ctxm index last]
 lappend diff_actions [list $ctxm entryconf $ui_diff_reverthunk -state]
 $ctxm add command \
 	-label [mc "Revert Line"] \
-	-command {apply_or_revert_range_or_line $cursorX $cursorY 1; do_rescan}
+	-command {apply_or_revert_range_or_line $cursorX $cursorY 1; schedule_rescan}
 set ui_diff_revertline [$ctxm index last]
 lappend diff_actions [list $ctxm entryconf $ui_diff_revertline -state]
 $ctxm add command \
 	-label [mc "Undo Last Revert"] \
-	-command {undo_last_revert; do_rescan}
+	-command {undo_last_revert; schedule_rescan}
 set ui_diff_undorevert [$ctxm index last]
 lappend diff_actions [list $ctxm entryconf $ui_diff_undorevert -state]
 $ctxm add separator
@@ -4171,7 +4184,7 @@ after 1 {
 	if {[is_enabled initialamend]} {
 		force_amend
 	} else {
-		do_rescan
+		schedule_rescan
 	}
 
 	if {[is_enabled nocommitmsg]} {
-- 
2.29.2
Previous: Stefan HallerNext: Pratyush Yadav
Message 5 of 21 in “git-gui: Auto-rescan on activate”
  1. 0/2 git-gui: Auto-rescan on activateStefan Haller, Nov 1, 2020
  2. 2/2 git-gui: Auto-rescan on activateStefan Haller, Nov 1, 2020
  3. Pratyush YadavNov 2, 2020
  4. Stefan HallerNov 2, 2020
  5. 1/2 git-gui: Delay rescan until idle timeStefan Haller, Nov 1, 2020
  6. Pratyush YadavNov 2, 2020
  7. Stefan HallerNov 2, 2020
  8. Pratyush YadavNov 2, 2020
  9. Stefan HallerNov 2, 2020
  10. 0/1 git-gui: Auto-rescan on activateStefan Haller, Nov 3, 2020
  11. 1/1 git-gui: Auto-rescan on activateStefan Haller, Nov 3, 2020
  12. Stefan HallerNov 14, 2020
  13. Pratyush YadavNov 17, 2020
  14. Stefan HallerNov 17, 2020
  15. Pratyush YadavNov 17, 2020
  16. Stefan HallerNov 18, 2020
  17. Johannes SixtDec 17, 2020
  18. Pratyush YadavDec 17, 2020
  19. Johannes SixtDec 17, 2020
  20. Stefan HallerDec 18, 2020
  21. Johannes SixtDec 18, 2020

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.