git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Haller <stefan@haller-berlin.de>
To: git@vger.kernel.org
Cc: me@yadavpratyush.com
Subject: [PATCH 1/2] git-gui: Delay rescan until idle time
Date: Sun,  1 Nov 2020 18:05:04 +0100	[thread overview]
Message-ID: <20201101170505.71246-2-stefan@haller-berlin.de> (raw)
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


  reply	other threads:[~2020-11-01 17:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-01 17:05 [PATCH 0/2] git-gui: Auto-rescan on activate Stefan Haller
2020-11-01 17:05 ` Stefan Haller [this message]
2020-11-02 15:45   ` [PATCH 1/2] git-gui: Delay rescan until idle time Pratyush Yadav
2020-11-02 19:29     ` Stefan Haller
2020-11-01 17:05 ` [PATCH 2/2] git-gui: Auto-rescan on activate Stefan Haller
2020-11-02 15:48   ` Pratyush Yadav
2020-11-02 19:31     ` Stefan Haller
2020-11-02 13:15 ` [PATCH 0/2] " Pratyush Yadav
2020-11-02 19:24   ` Stefan Haller
2020-11-03 16:16     ` [PATCH v2 0/1] " Stefan Haller
2020-11-03 16:16       ` [PATCH v2 1/1] " Stefan Haller
2020-11-14 19:14         ` Stefan Haller
2020-11-17  7:36           ` Pratyush Yadav
2020-11-17 11:13             ` Stefan Haller
2020-11-17 12:05               ` Pratyush Yadav
2020-11-18  9:17                 ` Stefan Haller
2020-12-17 19:45 ` [PATCH 0/2] " Johannes Sixt
2020-12-17 20:10   ` Pratyush Yadav
2020-12-17 22:21     ` Johannes Sixt
2020-12-18 10:36   ` Stefan Haller
2020-12-18 18:07     ` Johannes Sixt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201101170505.71246-2-stefan@haller-berlin.de \
    --to=stefan@haller-berlin.de \
    --cc=git@vger.kernel.org \
    --cc=me@yadavpratyush.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).