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

Re: [PATCH] gitk: Fix nextfile() and add prevfile()

From
OHOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Date
Sep 27, 2006, 03:32 UTC
Message-ID
<87fyeernlo.fsf@duaron.myhome.or.jp>
In-Reply-To
<17689.49841.913304.878599@cargo.ozlabs.ibm.com>
Paul Mackerras <paulus@samba.org> writes:
Show 11 quoted lines
> OGAWA Hirofumi writes:
>
>> The current nextfile() jumps to last hunk, but I think this is not
>> intention, probably, it's forgetting to add "break;". And this
>> patch also adds prevfile(), it jumps to previous hunk.
>
> I think your prevfile isn't quite right - I don't think it will do the
> right thing if $loc is past the last entry in $difffilestart.  Don't
> you want the "$ctext yview $prev" after the loop?
>
> Paul.
Sure, it's obviously useful in the case of big hunk. Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>


The current nextfile() jumps to last hunk, but I think this is not
intention, probably, it's forgetting to add "break;". And this
patch also adds prevfile(), it jumps to previous hunk.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---

 gitk |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff -puN gitk~gitk-nextfile-fix gitk
--- git/gitk~gitk-nextfile-fix	2006-09-27 12:14:07.000000000 +0900
+++ git-hirofumi/gitk	2006-09-27 12:16:23.000000000 +0900
@@ -4440,12 +4440,27 @@ proc getblobdiffline {bdf ids} {
     }
 }
 
+proc prevfile {} {
+    global difffilestart ctext
+    set prev [lindex $difffilestart 0]
+    set here [$ctext index @0,0]
+    foreach loc $difffilestart {
+	if {[$ctext compare $loc >= $here]} {
+	    $ctext yview $prev
+	    return
+	}
+	set prev $loc
+    }
+    $ctext yview $prev
+}
+
 proc nextfile {} {
     global difffilestart ctext
     set here [$ctext index @0,0]
     foreach loc $difffilestart {
 	if {[$ctext compare $loc > $here]} {
 	    $ctext yview $loc
+	    return
 	}
     }
 }
_
Previous: Paul Mackerras
Message 7 of 7 in “gitk: Fix nextfile() and more”
  1. gitk: Fix nextfile() and moreOGAWA Hirofumi, Sep 25, 2006
  2. Junio C HamanoSep 26, 2006
  3. OGAWA HirofumiSep 26, 2006
  4. gitk: Fix nextfile() and add prevfile()OGAWA Hirofumi, Sep 26, 2006
  5. gitk: add some key-bindOGAWA Hirofumi, Sep 26, 2006
  6. Paul MackerrasSep 27, 2006
  7. OGAWA HirofumiSep 27, 2006

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.