git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-gui: Fix accidental staged state toggle when clicking top pixel row
@ 2008-06-20 14:58 Richard Quirk
  2008-06-20 15:26 ` Johannes Sixt
  2008-06-21  3:21 ` Shawn O. Pearce
  0 siblings, 2 replies; 3+ messages in thread
From: Richard Quirk @ 2008-06-20 14:58 UTC (permalink / raw)
  To: git; +Cc: spearce, Richard Quirk

If a text widget is asked the index at x,y with y == 0 or y == 1 it will
always return 1.0 as the nearest index, regardless of the x position.

This means that clicking the top 2 pixels of the Unstaged/Staged Changes
lists caused the state of the file there to be toggled. This patch
checks that the pixel clicked is greater than 1, so there is less chance
of accidentally staging or unstaging changes.

Signed-off-by: Richard Quirk <richard.quirk@gmail.com>
---

To test the unpatched changes, make a change in a git-controlled repo and run
git-gui. Click the Unstaged Changes list away from the first column, but near
(within 1 pixel) to the pink header part. The file underneath is staged, rather
surprisingly. Similarly, for staged files click a pixel or 2 underneath the
green Staged Changes header and the changes are unstaged, even if the first
column is not clicked.

This change looks like a hack - but I'm pretty sure it's a bug in the Tk text
widget that's causing the strange behaviour. I couldn't see any other way to
fix this accidental (un)staging, which seems to get me at least once a day
lately.

 git-gui.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-gui.sh b/git-gui.sh
index 23d7dfe..980dc0b 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -1797,7 +1797,7 @@ proc toggle_or_diff {w x y} {
 	$ui_index tag remove in_sel 0.0 end
 	$ui_workdir tag remove in_sel 0.0 end
 
-	if {$col == 0} {
+	if {$col == 0 && $y > 1} {
 		set i [expr {$lno-1}]
 		set ll [expr {[llength $file_lists($w)]-1}]
 
-- 
1.5.6.9.g26943

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-gui: Fix accidental staged state toggle when clicking top pixel row
  2008-06-20 14:58 [PATCH] git-gui: Fix accidental staged state toggle when clicking top pixel row Richard Quirk
@ 2008-06-20 15:26 ` Johannes Sixt
  2008-06-21  3:21 ` Shawn O. Pearce
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Sixt @ 2008-06-20 15:26 UTC (permalink / raw)
  To: Richard Quirk; +Cc: git, spearce

Richard Quirk schrieb:
> If a text widget is asked the index at x,y with y == 0 or y == 1 it will
> always return 1.0 as the nearest index, regardless of the x position.
> 
> This means that clicking the top 2 pixels of the Unstaged/Staged Changes
> lists caused the state of the file there to be toggled. This patch
> checks that the pixel clicked is greater than 1, so there is less chance
> of accidentally staging or unstaging changes.

Ah, that would explain why it sometimes happened that a file was staged
even though the mouse pointer was no where near the icon!

-- Hannes

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-gui: Fix accidental staged state toggle when clicking top pixel row
  2008-06-20 14:58 [PATCH] git-gui: Fix accidental staged state toggle when clicking top pixel row Richard Quirk
  2008-06-20 15:26 ` Johannes Sixt
@ 2008-06-21  3:21 ` Shawn O. Pearce
  1 sibling, 0 replies; 3+ messages in thread
From: Shawn O. Pearce @ 2008-06-21  3:21 UTC (permalink / raw)
  To: Richard Quirk; +Cc: git

Richard Quirk <richard.quirk@gmail.com> wrote:
> If a text widget is asked the index at x,y with y == 0 or y == 1 it will
> always return 1.0 as the nearest index, regardless of the x position.
> 
> This means that clicking the top 2 pixels of the Unstaged/Staged Changes
> lists caused the state of the file there to be toggled. This patch
> checks that the pixel clicked is greater than 1, so there is less chance
> of accidentally staging or unstaging changes.

Thanks.  Its in my master branch now.

-- 
Shawn.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-06-21  3:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-20 14:58 [PATCH] git-gui: Fix accidental staged state toggle when clicking top pixel row Richard Quirk
2008-06-20 15:26 ` Johannes Sixt
2008-06-21  3:21 ` Shawn O. Pearce

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 NNTP newsgroup(s).