{"thread":{"id":"14061","subject":"[PATCH] git-gui: Fix accidental staged state toggle when clicking top pixel row","startedAt":"2008-06-20T14:58:15Z","lastAt":"2008-06-21T03:21:32Z","messageCount":3,"participants":["Richard Quirk","Johannes Sixt","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"80491","messageId":"1213973895-10264-1-git-send-email-richard.quirk@gmail.com","threadId":"14061","inReplyTo":null,"subject":"[PATCH] git-gui: Fix accidental staged state toggle when clicking top pixel row","fromName":"Richard Quirk","fromEmail":"richard.quirk@gmail.com","sentAt":"2008-06-20T14:58:15Z","receivedAt":"2008-06-20T14:58:15Z","isPatch":true,"sender":{"key":"richard.quirk@gmail.com","avatar":null},"body":"If a text widget is asked the index at x,y with y == 0 or y == 1 it will\nalways return 1.0 as the nearest index, regardless of the x position.\n\nThis means that clicking the top 2 pixels of the Unstaged/Staged Changes\nlists caused the state of the file there to be toggled. This patch\nchecks that the pixel clicked is greater than 1, so there is less chance\nof accidentally staging or unstaging changes.\n\nSigned-off-by: Richard Quirk <richard.quirk@gmail.com>\n---\n\nTo test the unpatched changes, make a change in a git-controlled repo and run\ngit-gui. Click the Unstaged Changes list away from the first column, but near\n(within 1 pixel) to the pink header part. The file underneath is staged, rather\nsurprisingly. Similarly, for staged files click a pixel or 2 underneath the\ngreen Staged Changes header and the changes are unstaged, even if the first\ncolumn is not clicked.\n\nThis change looks like a hack - but I'm pretty sure it's a bug in the Tk text\nwidget that's causing the strange behaviour. I couldn't see any other way to\nfix this accidental (un)staging, which seems to get me at least once a day\nlately.\n\n git-gui.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex 23d7dfe..980dc0b 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -1797,7 +1797,7 @@ proc toggle_or_diff {w x y} {\n \t$ui_index tag remove in_sel 0.0 end\n \t$ui_workdir tag remove in_sel 0.0 end\n \n-\tif {$col == 0} {\n+\tif {$col == 0 && $y > 1} {\n \t\tset i [expr {$lno-1}]\n \t\tset ll [expr {[llength $file_lists($w)]-1}]\n \n-- \n1.5.6.9.g26943\n"},{"id":"80492","messageId":"485BCC38.1000403@viscovery.net","threadId":"14061","inReplyTo":"1213973895-10264-1-git-send-email-richard.quirk@gmail.com","subject":"Re: [PATCH] git-gui: Fix accidental staged state toggle when clicking top pixel row","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-06-20T15:26:48Z","receivedAt":"2008-06-20T15:26:48Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Richard Quirk schrieb:\n> If a text widget is asked the index at x,y with y == 0 or y == 1 it will\n> always return 1.0 as the nearest index, regardless of the x position.\n> \n> This means that clicking the top 2 pixels of the Unstaged/Staged Changes\n> lists caused the state of the file there to be toggled. This patch\n> checks that the pixel clicked is greater than 1, so there is less chance\n> of accidentally staging or unstaging changes.\n\nAh, that would explain why it sometimes happened that a file was staged\neven though the mouse pointer was no where near the icon!\n\n-- Hannes\n"},{"id":"80529","messageId":"20080621032132.GW11793@spearce.org","threadId":"14061","inReplyTo":"1213973895-10264-1-git-send-email-richard.quirk@gmail.com","subject":"Re: [PATCH] git-gui: Fix accidental staged state toggle when clicking top pixel row","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-06-21T03:21:32Z","receivedAt":"2008-06-21T03:21:32Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Richard Quirk <richard.quirk@gmail.com> wrote:\n> If a text widget is asked the index at x,y with y == 0 or y == 1 it will\n> always return 1.0 as the nearest index, regardless of the x position.\n> \n> This means that clicking the top 2 pixels of the Unstaged/Staged Changes\n> lists caused the state of the file there to be toggled. This patch\n> checks that the pixel clicked is greater than 1, so there is less chance\n> of accidentally staging or unstaging changes.\n\nThanks.  Its in my master branch now.\n\n-- \nShawn.\n"}]}