{"thread":{"id":"51848","subject":"git-gui: automatically move focus to staged file before typing commit message?","startedAt":"2019-09-14T12:24:48Z","lastAt":"2019-10-17T18:28:45Z","messageCount":22,"participants":["Birger Skogeng Pedersen","Pratyush Yadav","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"382363","messageId":"CAGr--=KMJmYtVaATFkOPcboAdkLvpZFbWAo4QAE0-uC6RL4Lqg@mail.gmail.com","threadId":"51848","inReplyTo":null,"subject":"git-gui: automatically move focus to staged file before typing commit message?","fromName":"Birger Skogeng Pedersen","fromEmail":"birger.sp@gmail.com","sentAt":"2019-09-14T12:24:34Z","receivedAt":"2019-09-14T12:24:48Z","isPatch":false,"sender":{"key":"birger.sp@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5260237?v=4"},"body":"Hi everyone,\n\n\nI personally prefer to have the changes I am about to commit visible\nin the diff view, while I write my commit message. So usually I do\nthis:\n1. Stage the file(s) I've been working on.\n2. Select a file I just staged, so I can see the changes in the diff widget.\n3. Jump to the \"Commit Message\" widget to type up my commit message.\nBasically, I would like to be able to skip step 2. When the user\nstages the last file in the \"Unstaged Changes\" widget, no file is\nselected and the diff view becomes blank. When this is the case, I\nwould prefer that git-gui automatically selects one of the staged\nfiles and shows it in the diff widget before I type up my commit\nmessage. Naturally, this automatic selection should **only** happen\nwhen the user chooses focus the \"Commit Message\" widget.\n\nI propose:\n(When the user focuses the \"Commit Message\" widget, if no file is\ncurrently selected (i.e. diff widget shows no text))\nautomatically select the first file listed in the \"Staged Changes\"\nwidget so the changes of that file show up in the diff widget.\n\nThoughts?\n\n\nBest regards,\nBirger S Pedersen\n"},{"id":"382377","messageId":"20190914211509.sjy6lh2rlcl32lj5@yadavpratyush.com","threadId":"51848","inReplyTo":"CAGr--=KMJmYtVaATFkOPcboAdkLvpZFbWAo4QAE0-uC6RL4Lqg@mail.gmail.com","subject":"Re: git-gui: automatically move focus to staged file before typing commit message?","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-09-14T21:15:09Z","receivedAt":"2019-09-14T21:15:15Z","isPatch":false,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 14/09/19 02:24PM, Birger Skogeng Pedersen wrote:\n> Hi everyone,\n> \n> \n> I personally prefer to have the changes I am about to commit visible\n> in the diff view, while I write my commit message. So usually I do\n> this:\n> 1. Stage the file(s) I've been working on.\n> 2. Select a file I just staged, so I can see the changes in the diff widget.\n> 3. Jump to the \"Commit Message\" widget to type up my commit message.\n> Basically, I would like to be able to skip step 2. When the user\n> stages the last file in the \"Unstaged Changes\" widget, no file is\n> selected and the diff view becomes blank. When this is the case, I\n> would prefer that git-gui automatically selects one of the staged\n> files and shows it in the diff widget before I type up my commit\n> message. Naturally, this automatic selection should **only** happen\n> when the user chooses focus the \"Commit Message\" widget.\n\nWhy should it only happen when the commit message widget is selected? \nWhat's wrong with directly switching focus when all the files are \nstaged?\n\nWhat I have in mind is once there are no more files to stage, the focus \ndirectly goes to the staged files section, and the first staged file \ngets selected. Then if you want you can type in the commit message. And \nconversely, when unstaging things, once all files are unstaged, the \nfocus goes directly to the unstaged files section.\n \n> I propose:\n> (When the user focuses the \"Commit Message\" widget, if no file is\n> currently selected (i.e. diff widget shows no text))\n> automatically select the first file listed in the \"Staged Changes\"\n> widget so the changes of that file show up in the diff widget.\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"382379","messageId":"0db5470e-5044-d5b3-8f04-f40cfbd8cf44@kdbg.org","threadId":"51848","inReplyTo":"20190914211509.sjy6lh2rlcl32lj5@yadavpratyush.com","subject":"Re: git-gui: automatically move focus to staged file before typing commit message?","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2019-09-14T21:26:42Z","receivedAt":"2019-09-14T21:26:46Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 14.09.19 um 23:15 schrieb Pratyush Yadav:\n> On 14/09/19 02:24PM, Birger Skogeng Pedersen wrote:\n>> When the user\n>> stages the last file in the \"Unstaged Changes\" widget, no file is\n>> selected and the diff view becomes blank. When this is the case, I\n>> would prefer that git-gui automatically selects one of the staged\n>> files and shows it in the diff widget before I type up my commit\n>> message. Naturally, this automatic selection should **only** happen\n>> when the user chooses focus the \"Commit Message\" widget.\n> \n> Why should it only happen when the commit message widget is selected? \n> What's wrong with directly switching focus when all the files are \n> staged?\n\nThat was my reaction, too.\n\n> What I have in mind is once there are no more files to stage, the focus \n> directly goes to the staged files section, and the first staged file \n> gets selected.\n\n... or the last one that was staged. Typically, it is a fixup found\nduring testing that is staged last. Then I like to have a look at the\ncomplete staged changes of that file.\n\n Then if you want you can type in the commit message. And\n> conversely, when unstaging things, once all files are unstaged, the \n> focus goes directly to the unstaged files section.\n\nSame here.\n\n-- Hannes\n"},{"id":"382380","messageId":"20190914212732.plymb3vnz3dv4rmc@yadavpratyush.com","threadId":"51848","inReplyTo":"20190914211509.sjy6lh2rlcl32lj5@yadavpratyush.com","subject":"Re: git-gui: automatically move focus to staged file before typing commit message?","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-09-14T21:27:32Z","receivedAt":"2019-09-14T21:27:37Z","isPatch":false,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 15/09/19 02:45AM, Pratyush Yadav wrote:\n> On 14/09/19 02:24PM, Birger Skogeng Pedersen wrote:\n> > Hi everyone,\n> > \n> > \n> > I personally prefer to have the changes I am about to commit visible\n> > in the diff view, while I write my commit message. So usually I do\n> > this:\n> > 1. Stage the file(s) I've been working on.\n> > 2. Select a file I just staged, so I can see the changes in the diff widget.\n> > 3. Jump to the \"Commit Message\" widget to type up my commit message.\n> > Basically, I would like to be able to skip step 2. When the user\n> > stages the last file in the \"Unstaged Changes\" widget, no file is\n> > selected and the diff view becomes blank. When this is the case, I\n> > would prefer that git-gui automatically selects one of the staged\n> > files and shows it in the diff widget before I type up my commit\n> > message. Naturally, this automatic selection should **only** happen\n> > when the user chooses focus the \"Commit Message\" widget.\n> \n> Why should it only happen when the commit message widget is selected? \n> What's wrong with directly switching focus when all the files are \n> staged?\n\nRe-reading this email, this might have come across as a bit too harsh. \nThat was not my intention. I just want to know why you think it should \nonly happen when focussing on the commit message, and what in your mind \nis the problem with directly switching when no more files are left.\n\n> \n> What I have in mind is once there are no more files to stage, the focus \n> directly goes to the staged files section, and the first staged file \n> gets selected. Then if you want you can type in the commit message. And \n> conversely, when unstaging things, once all files are unstaged, the \n> focus goes directly to the unstaged files section.\n>  \n> > I propose:\n> > (When the user focuses the \"Commit Message\" widget, if no file is\n> > currently selected (i.e. diff widget shows no text))\n> > automatically select the first file listed in the \"Staged Changes\"\n> > widget so the changes of that file show up in the diff widget.\n> \n> -- \n> Regards,\n> Pratyush Yadav\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"382387","messageId":"CAGr--=LmhE9m9V4Dq8Zt0aXqdThzrNnWSnxWawVZiLYTKbL2ig@mail.gmail.com","threadId":"51848","inReplyTo":"20190914212732.plymb3vnz3dv4rmc@yadavpratyush.com","subject":"Re: git-gui: automatically move focus to staged file before typing commit message?","fromName":"Birger Skogeng Pedersen","fromEmail":"birger.sp@gmail.com","sentAt":"2019-09-15T07:55:28Z","receivedAt":"2019-09-15T07:58:30Z","isPatch":false,"sender":{"key":"birger.sp@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5260237?v=4"},"body":"Hi Pratyush,\n\nOn Sat, Sep 14, 2019 at 11:15 PM Pratyush Yadav <me@yadavpratyush.com> wrote:\n> Why should it only happen when the commit message widget is selected?\n> What's wrong with directly switching focus when all the files are\n> staged?\n>\n> What I have in mind is once there are no more files to stage, the focus\n> directly goes to the staged files section, and the first staged file\n> gets selected. Then if you want you can type in the commit message. And\n> conversely, when unstaging things, once all files are unstaged, the\n> focus goes directly to the unstaged files section.\n\nYour questions are fair. My reasoning: I imagine it could be a bit\nfrustrating that the focus automatically goes away from the \"Unstaged\nChanges\" widget, when the user actually isn't done doing changes.\n\nFor instance (as a user);\n- Do some changes\n- Stage the changes (no more unstaged changes in the repo)\n- Realize that you forgot something, jump back to the IDE and make\nsome more changes\n- Jump back again to git-gui, hit refresh\nIn this scenario, I imagine the user would want to have focus kept on\nthe \"Unstaged Changes\" widget. Even if it became empty with files\nbefore.\n\nWhen the user focus the \"Commit Message\" widget, the user is kinda\nstating \"I'm done staging stuff for now\". And when that happens, it\nreally doesn't make sense to show a blank diff any more.\n\nI hope that made sense.\n\nBirger\n"},{"id":"382433","messageId":"20190916180059.aifw5r4c4k5o5hur@yadavpratyush.com","threadId":"51848","inReplyTo":"CAGr--=LmhE9m9V4Dq8Zt0aXqdThzrNnWSnxWawVZiLYTKbL2ig@mail.gmail.com","subject":"Re: git-gui: automatically move focus to staged file before typing commit message?","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-09-16T18:01:00Z","receivedAt":"2019-09-16T18:01:05Z","isPatch":false,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 15/09/19 09:55AM, Birger Skogeng Pedersen wrote:\n> Hi Pratyush,\n> \n> On Sat, Sep 14, 2019 at 11:15 PM Pratyush Yadav <me@yadavpratyush.com> wrote:\n> > Why should it only happen when the commit message widget is selected?\n> > What's wrong with directly switching focus when all the files are\n> > staged?\n> >\n> > What I have in mind is once there are no more files to stage, the focus\n> > directly goes to the staged files section, and the first staged file\n> > gets selected. Then if you want you can type in the commit message. And\n> > conversely, when unstaging things, once all files are unstaged, the\n> > focus goes directly to the unstaged files section.\n> \n> Your questions are fair. My reasoning: I imagine it could be a bit\n> frustrating that the focus automatically goes away from the \"Unstaged\n> Changes\" widget, when the user actually isn't done doing changes.\n\nI suppose a similar argument can be made against your suggestion though. \nWhen a user clicks on the commit message buffer, they did one thing: \nclick on the buffer. They did not click on any diff. So, wouldn't it be \ndisorienting for them if their action of clicking the commit message \nbuffer also switches the diff view?\n\nI'm not arguing in favour or against your suggestion, I just want to \nconsider all angles/viewpoints before going forward.\n \n> For instance (as a user);\n> - Do some changes\n> - Stage the changes (no more unstaged changes in the repo)\n> - Realize that you forgot something, jump back to the IDE and make\n> some more changes\n> - Jump back again to git-gui, hit refresh\n> In this scenario, I imagine the user would want to have focus kept on\n> the \"Unstaged Changes\" widget. Even if it became empty with files\n> before.\n> \n> When the user focus the \"Commit Message\" widget, the user is kinda\n> stating \"I'm done staging stuff for now\". And when that happens, it\n> really doesn't make sense to show a blank diff any more.\n\nMakes sense. But I'm not sure if this would be beneficial to other \ngit-gui users. I'd like to hear about what other people think about this \nchange.\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"383011","messageId":"CAGr--=+SNO7GuHH-dE_ZnrJDCa8tv8EA5LMrVGwsMTRpxhzEZA@mail.gmail.com","threadId":"51848","inReplyTo":"20190916180059.aifw5r4c4k5o5hur@yadavpratyush.com","subject":"Re: git-gui: automatically move focus to staged file before typing commit message?","fromName":"Birger Skogeng Pedersen","fromEmail":"birger.sp@gmail.com","sentAt":"2019-09-26T18:33:40Z","receivedAt":"2019-09-26T18:33:54Z","isPatch":false,"sender":{"key":"birger.sp@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5260237?v=4"},"body":"Honestly I'll need some help to get this one implemented. The only\nimplementation I've got working currently, is to change Alt+4 key bind\nto do the following:\n- Focus the \"Staged Changes\" widget (which will select a path in the\nlist, if it isn't focused already), then\n- Focus the \"Commit Message\" widget\n\n¯\\_(ツ)_/¯\nBirger\n"},{"id":"383018","messageId":"20190926193004.jspiirmb4ejxznjo@yadavpratyush.com","threadId":"51848","inReplyTo":"CAGr--=+SNO7GuHH-dE_ZnrJDCa8tv8EA5LMrVGwsMTRpxhzEZA@mail.gmail.com","subject":"Re: git-gui: automatically move focus to staged file before typing commit message?","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-09-26T19:30:04Z","receivedAt":"2019-09-26T19:30:10Z","isPatch":false,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 26/09/19 08:33PM, Birger Skogeng Pedersen wrote:\n> Honestly I'll need some help to get this one implemented. The only\n> implementation I've got working currently, is to change Alt+4 key bind\n> to do the following:\n> - Focus the \"Staged Changes\" widget (which will select a path in the\n> list, if it isn't focused already), then\n> - Focus the \"Commit Message\" widget\n\nWhy are you changing the Alt+4 binding? This means your feature won't \nwork for people who use the mouse to move around in the UI (which I \nsuppose would be a majority).\n\nDid you try binding a script to the FocusIn event of the commit message \nbuffer? You can do this like:\n  \n  bind $ui_comm <FocusIn> {your_script}\n\nI'm not sure if $ui_comm is the correct widget, but you can experiment a \nbit by printing something in your_script to find out for sure.\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"383035","messageId":"CAGr--=Jiu-haHMX2fc8AB1uGWT1OMw5=M3_CuGWVzrYmO0uq3A@mail.gmail.com","threadId":"51848","inReplyTo":"20190926193004.jspiirmb4ejxznjo@yadavpratyush.com","subject":"Re: git-gui: automatically move focus to staged file before typing commit message?","fromName":"Birger Skogeng Pedersen","fromEmail":"birger.sp@gmail.com","sentAt":"2019-09-26T21:17:46Z","receivedAt":"2019-09-26T21:18:00Z","isPatch":false,"sender":{"key":"birger.sp@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5260237?v=4"},"body":"On Thu, Sep 26, 2019 at 9:30 PM Pratyush Yadav <me@yadavpratyush.com> wrote:\n> Why are you changing the Alt+4 binding?\n\nI couldn't really find an easier way before.\n\n> This means your feature won't\n> work for people who use the mouse to move around in the UI (which I\n> suppose would be a majority).\n\nTrue. I would much prefer that the staged file is selected on commit\nwidget focus, regardless of how the focus was changed (hotkey or\nmouse).\n\n> Did you try binding a script to the FocusIn event of the commit message\n> buffer? You can do this like:\n>\n>   bind $ui_comm <FocusIn> {your_script}\n>\n> I'm not sure if $ui_comm is the correct widget, but you can experiment a\n> bit by printing something in your_script to find out for sure.\n\nAh, that's pretty neat! I'll play around with that. Thanks, Pratyush.\n\nBirger\n"},{"id":"383585","messageId":"CAGr--=KXpt7GzqPpm1BCrsc1jhfaXeCT-XrWKNvq2pLtgAbSwQ@mail.gmail.com","threadId":"51848","inReplyTo":"CAGr--=Jiu-haHMX2fc8AB1uGWT1OMw5=M3_CuGWVzrYmO0uq3A@mail.gmail.com","subject":"Re: git-gui: automatically move focus to staged file before typing commit message?","fromName":"Birger Skogeng Pedersen","fromEmail":"birger.sp@gmail.com","sentAt":"2019-10-07T16:52:31Z","receivedAt":"2019-10-07T16:52:51Z","isPatch":false,"sender":{"key":"birger.sp@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5260237?v=4"},"body":"So I kinda got this working, but only when focusing the commit message widget.\n\nI did not manage to get it working when invoking \"do_add_all\", (e.g.\nwhen pressing CTRL/CMD+i). I added this:\n\nbind $ui_comm <$M1B-Key-i> {do_add_all;select_staged_file;break}\nbind $ui_comm <$M1B-Key-I> {do_add_all;select_staged_file;break}\n\nBut it seems that the \"select_staged_file\" procedure is invoked\n_before_ \"do_add_all\" finishes. So that's not working. All changes\ngets staged, but no staged change is selected.\n\nAnd I'm quite stuck. Do I send the unfinished patch, so maybe I can\nget some advice? Or is it better to just wait until I have the perfect\npatch ready?\n\nBirger\n"},{"id":"383588","messageId":"20191007171145.1259-1-birger.sp@gmail.com","threadId":"51848","inReplyTo":"CAGr--=KXpt7GzqPpm1BCrsc1jhfaXeCT-XrWKNvq2pLtgAbSwQ@mail.gmail.com","subject":"[PATCH 1/2] git-gui: implement proc select_path_in_widget","fromName":"Birger Skogeng Pedersen","fromEmail":"birger.sp@gmail.com","sentAt":"2019-10-07T17:11:44Z","receivedAt":"2019-10-07T17:12:03Z","isPatch":true,"sender":{"key":"birger.sp@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5260237?v=4"},"body":"Signed-off-by: Birger Skogeng Pedersen <birger.sp@gmail.com>\n---\n git-gui.sh | 32 +++++++++++++++++++-------------\n 1 file changed, 19 insertions(+), 13 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex fd476b6..b7f4d1e 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -2669,25 +2669,31 @@ proc show_less_context {} {\n }\n \n proc focus_widget {widget} {\n-\tglobal file_lists last_clicked selected_paths\n-\tglobal file_lists_last_clicked\n+\tglobal file_lists\n \n \tif {[llength $file_lists($widget)] > 0} {\n-\t\tset path $file_lists_last_clicked($widget)\n-\t\tset index [lsearch -sorted -exact $file_lists($widget) $path]\n-\t\tif {$index < 0} {\n-\t\t\tset index 0\n-\t\t\tset path [lindex $file_lists($widget) $index]\n-\t\t}\n-\n+\t\tselect_path_in_widget $widget\n \t\tfocus $widget\n-\t\tset last_clicked [list $widget [expr $index + 1]]\n-\t\tarray unset selected_paths\n-\t\tset selected_paths($path) 1\n-\t\tshow_diff $path $widget\n \t}\n }\n \n+proc select_path_in_widget {widget} {\n+\tglobal file_lists last_clicked selected_paths\n+\tglobal file_lists_last_clicked\n+\n+\tset path $file_lists_last_clicked($widget)\n+\tset index [lsearch -sorted -exact $file_lists($widget) $path]\n+\tif {$index < 0} {\n+\t\tset index 0\n+\t\tset path [lindex $file_lists($widget) $index]\n+\t}\n+\n+\tset last_clicked [list $widget [expr $index + 1]]\n+\tarray unset selected_paths\n+\tset selected_paths($path) 1\n+\tshow_diff $path $widget\n+}\n+\n proc toggle_commit_type {} {\n \tglobal commit_type_is_amend\n \tset commit_type_is_amend [expr !$commit_type_is_amend]\n-- \n2.23.0.windows.1\n\n"},{"id":"383589","messageId":"20191007171145.1259-2-birger.sp@gmail.com","threadId":"51848","inReplyTo":"20191007171145.1259-1-birger.sp@gmail.com","subject":"[PATCH 2/2] git-gui: select staged on ui_comm focus","fromName":"Birger Skogeng Pedersen","fromEmail":"birger.sp@gmail.com","sentAt":"2019-10-07T17:11:45Z","receivedAt":"2019-10-07T17:12:05Z","isPatch":true,"sender":{"key":"birger.sp@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5260237?v=4"},"body":"When the user focuses the Commit Message widget (to write a message), the\ndiff view may be blank.\n\nWith this patch a staged file is automatically selected when the Commit\nMessage widget is focused, if no other file is selected (i.e. diff view\nis blank).\n\nSigned-off-by: Birger Skogeng Pedersen <birger.sp@gmail.com>\n---\n git-gui.sh | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex b7f4d1e..70b846a 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -2700,6 +2700,15 @@ proc toggle_commit_type {} {\n \tdo_select_commit_type\n }\n \n+proc check_diff_selected {} {\n+\tglobal current_diff_path file_lists\n+\t# If no diff path selected, select a staged file\n+\tif {$current_diff_path eq {}\n+\t\t&& [llength $file_lists($::ui_index)] > 0} {\n+\t\tselect_path_in_widget $::ui_index\n+\t}\n+}\n+\n ######################################################################\n ##\n ## ui construction\n@@ -3437,6 +3446,8 @@ pack .vpane.lower.commarea.buffer.header -side top -fill x\n pack .vpane.lower.commarea.buffer.frame -side left -fill y\n pack .vpane.lower.commarea.buffer -side left -fill y\n \n+bind $ui_comm <FocusIn> {check_diff_selected}\n+\n # -- Commit Message Buffer Context Menu\n #\n set ctxm .vpane.lower.commarea.buffer.ctxm\n-- \n2.23.0.windows.1\n\n"},{"id":"383693","messageId":"20191008175938.iqibournnxam4r6d@yadavpratyush.com","threadId":"51848","inReplyTo":"CAGr--=KXpt7GzqPpm1BCrsc1jhfaXeCT-XrWKNvq2pLtgAbSwQ@mail.gmail.com","subject":"Re: git-gui: automatically move focus to staged file before typing commit message?","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-10-08T17:59:38Z","receivedAt":"2019-10-08T17:59:44Z","isPatch":false,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 07/10/19 06:52PM, Birger Skogeng Pedersen wrote:\n> So I kinda got this working, but only when focusing the commit message widget.\n\nIsn't this the point of your feature? You change the view when focusing \nthe commit message widget. I remember you were explicitly against doing \nit as soon as all unstaged files were staged. Did you change your point \nof view on that?\n \n> I did not manage to get it working when invoking \"do_add_all\", (e.g.\n> when pressing CTRL/CMD+i). I added this:\n> \n> bind $ui_comm <$M1B-Key-i> {do_add_all;select_staged_file;break}\n> bind $ui_comm <$M1B-Key-I> {do_add_all;select_staged_file;break}\n> \n> But it seems that the \"select_staged_file\" procedure is invoked\n> _before_ \"do_add_all\" finishes. So that's not working. All changes\n> gets staged, but no staged change is selected.\n\nHmm, that shouldn't happen. select_staged_file should be executed \n_after_ do_add_all, not before. I haven't looked into your patches yet \nthough.\n \n> And I'm quite stuck. Do I send the unfinished patch, so maybe I can\n> get some advice? Or is it better to just wait until I have the perfect\n> patch ready?\n\nIf you are stuck on something, and want to share the WIP feature to get \nhelp/comments, you should mark your patches as \"RFC\" (Request For \nComments). This can be done by passing the option '-rfc' to \n`git-format-patch`. This will make your subject prefix to \"RFC PATCH\" \ninstead of just \"PATCH\".\n\nAnd yes, it is perfectly OK to send incomplete changes as long as you \nmark them as such, and specify what you need help with.\n\nBut I see that you have already sent those patches. I'm not sure when I \ncan find time to tinker around with them, so it might take me a couple \nof days to get to them.\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"383708","messageId":"CAGr--=JM2uTyyymUxHw6vhE9H=bzAO_E_yzrmuOhuuk-td02CA@mail.gmail.com","threadId":"51848","inReplyTo":"20191008175938.iqibournnxam4r6d@yadavpratyush.com","subject":"Re: git-gui: automatically move focus to staged file before typing commit message?","fromName":"Birger Skogeng Pedersen","fromEmail":"birger.sp@gmail.com","sentAt":"2019-10-08T19:46:44Z","receivedAt":"2019-10-08T19:47:00Z","isPatch":false,"sender":{"key":"birger.sp@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5260237?v=4"},"body":"Hi Pratyush,\n\nOn Tue, Oct 8, 2019 at 7:59 PM Pratyush Yadav <me@yadavpratyush.com> wrote:\n> On 07/10/19 06:52PM, Birger Skogeng Pedersen wrote:\n> > So I kinda got this working, but only when focusing the commit message widget.\n>\n> Isn't this the point of your feature? You change the view when focusing\n> the commit message widget. I remember you were explicitly against doing\n> it as soon as all unstaged files were staged. Did you change your point\n> of view on that?\n\nYes, kindof. Sorry for not being more clear about the intent.\nI would prefer that the automatic selection of a staged file happens\nalso when adding files while the Commit Message widget is in focused.\nFor instance, if the user focuses the Commit Message widget and then\nhits CTRL/CMD+i a staged file should be selected (if it isn't\nalready).\n\n> > I did not manage to get it working when invoking \"do_add_all\", (e.g.\n> > when pressing CTRL/CMD+i). I added this:\n> >\n> > bind $ui_comm <$M1B-Key-i> {do_add_all;select_staged_file;break}\n> > bind $ui_comm <$M1B-Key-I> {do_add_all;select_staged_file;break}\n> >\n> > But it seems that the \"select_staged_file\" procedure is invoked\n> > _before_ \"do_add_all\" finishes. So that's not working. All changes\n> > gets staged, but no staged change is selected.\n>\n> Hmm, that shouldn't happen. select_staged_file should be executed\n> _after_ do_add_all, not before. I haven't looked into your patches yet\n> though.\n\nI don't understand why it doesn't work. I'll play around some more with it.\n\n> > And I'm quite stuck. Do I send the unfinished patch, so maybe I can\n> > get some advice? Or is it better to just wait until I have the perfect\n> > patch ready?\n>\n> If you are stuck on something, and want to share the WIP feature to get\n> help/comments, you should mark your patches as \"RFC\" (Request For\n> Comments). This can be done by passing the option '-rfc' to\n> `git-format-patch`. This will make your subject prefix to \"RFC PATCH\"\n> instead of just \"PATCH\".\n\nSorry for not doing that, I'll take not and do that next time.\n\nThanks!\nBirger\n"},{"id":"383999","messageId":"20191013202110.z3gyx7eikackvmzb@yadavpratyush.com","threadId":"51848","inReplyTo":"20191007171145.1259-1-birger.sp@gmail.com","subject":"Re: [PATCH 1/2] git-gui: implement proc select_path_in_widget","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-10-13T20:21:10Z","receivedAt":"2019-10-13T20:21:15Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"Hi Birger,\n\nYour subject is a bit redundant. A reader of this commit can easily see \nthe diff and know that you implemented \"proc select_path_in_widget\". \nWhat's more important is why you implemented it. That is what should go \nin the commit message. So for example in this patch, you can say \nsomething like:\n\n  git-gui: move last clicked path selection logic to a separate function\n\n  This same logic will be used elsewhere in a follow-up commit, so make \n  it re-useable.\n\nThis is what I came up with at first thought. Maybe something even \nbetter and concise can say the same thing.\n\nOn 07/10/19 07:11PM, Birger Skogeng Pedersen wrote:\n> Signed-off-by: Birger Skogeng Pedersen <birger.sp@gmail.com>\n> ---\n>  git-gui.sh | 32 +++++++++++++++++++-------------\n>  1 file changed, 19 insertions(+), 13 deletions(-)\n> \n> diff --git a/git-gui.sh b/git-gui.sh\n> index fd476b6..b7f4d1e 100755\n> --- a/git-gui.sh\n> +++ b/git-gui.sh\n> @@ -2669,25 +2669,31 @@ proc show_less_context {} {\n>  }\n>  \n>  proc focus_widget {widget} {\n> -\tglobal file_lists last_clicked selected_paths\n> -\tglobal file_lists_last_clicked\n> +\tglobal file_lists\n>  \n>  \tif {[llength $file_lists($widget)] > 0} {\n> -\t\tset path $file_lists_last_clicked($widget)\n> -\t\tset index [lsearch -sorted -exact $file_lists($widget) $path]\n> -\t\tif {$index < 0} {\n> -\t\t\tset index 0\n> -\t\t\tset path [lindex $file_lists($widget) $index]\n> -\t\t}\n> -\n> +\t\tselect_path_in_widget $widget\n>  \t\tfocus $widget\n> -\t\tset last_clicked [list $widget [expr $index + 1]]\n> -\t\tarray unset selected_paths\n> -\t\tset selected_paths($path) 1\n> -\t\tshow_diff $path $widget\n\nThere is a change in the order of events here. Earlier, we first \nfocussed the widget, and then ran `show_diff`. Now we first run \n`show_diff` (via `select_path_in_widget`), and then focus the widget. \nThis won't cause any problems, right?\n\n>  \t}\n>  }\n>  \n> +proc select_path_in_widget {widget} {\n> +\tglobal file_lists last_clicked selected_paths\n> +\tglobal file_lists_last_clicked\n> +\n> +\tset path $file_lists_last_clicked($widget)\n> +\tset index [lsearch -sorted -exact $file_lists($widget) $path]\n> +\tif {$index < 0} {\n> +\t\tset index 0\n> +\t\tset path [lindex $file_lists($widget) $index]\n> +\t}\n> +\n> +\tset last_clicked [list $widget [expr $index + 1]]\n> +\tarray unset selected_paths\n> +\tset selected_paths($path) 1\n> +\tshow_diff $path $widget\n> +}\n> +\n>  proc toggle_commit_type {} {\n>  \tglobal commit_type_is_amend\n>  \tset commit_type_is_amend [expr !$commit_type_is_amend]\n\nOther than that, looks good. There isn't much changed here. Just some \ncode moved around.\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"384081","messageId":"CAGr--=K8beYCwRgjFdokyCkjguXTJu8wMoxMAMG_H7CVgmEA=g@mail.gmail.com","threadId":"51848","inReplyTo":"20191013202110.z3gyx7eikackvmzb@yadavpratyush.com","subject":"Re: [PATCH 1/2] git-gui: implement proc select_path_in_widget","fromName":"Birger Skogeng Pedersen","fromEmail":"birger.sp@gmail.com","sentAt":"2019-10-15T10:51:03Z","receivedAt":"2019-10-15T10:54:08Z","isPatch":true,"sender":{"key":"birger.sp@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5260237?v=4"},"body":"Hi Pratyush,\n\nThanks for reviewing. How does this work, do I send a re-roll of the patch(es)?\n\nBirger\n"},{"id":"384204","messageId":"20191016192546.znhulmgxqqsjxy2u@yadavpratyush.com","threadId":"51848","inReplyTo":"20191007171145.1259-2-birger.sp@gmail.com","subject":"Re: [PATCH 2/2] git-gui: select staged on ui_comm focus","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-10-16T19:25:46Z","receivedAt":"2019-10-16T19:25:53Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 07/10/19 07:11PM, Birger Skogeng Pedersen wrote:\n> When the user focuses the Commit Message widget (to write a message), the\n> diff view may be blank.\n> \n> With this patch a staged file is automatically selected when the Commit\n> Message widget is focused, if no other file is selected (i.e. diff view\n> is blank).\n> \n> Signed-off-by: Birger Skogeng Pedersen <birger.sp@gmail.com>\n> ---\n>  git-gui.sh | 11 +++++++++++\n>  1 file changed, 11 insertions(+)\n> \n> diff --git a/git-gui.sh b/git-gui.sh\n> index b7f4d1e..70b846a 100755\n> --- a/git-gui.sh\n> +++ b/git-gui.sh\n> @@ -2700,6 +2700,15 @@ proc toggle_commit_type {} {\n>  \tdo_select_commit_type\n>  }\n>  \n> +proc check_diff_selected {} {\n> +\tglobal current_diff_path file_lists\n> +\t# If no diff path selected, select a staged file\n> +\tif {$current_diff_path eq {}\n> +\t\t&& [llength $file_lists($::ui_index)] > 0} {\n\nNitpick: Please declare ui_index to be global. That way we can just use \n$ui_index instead of the more tedious $::ui_index.\n\n> +\t\tselect_path_in_widget $::ui_index\n> +\t}\n> +}\n> +\n>  ######################################################################\n>  ##\n>  ## ui construction\n> @@ -3437,6 +3446,8 @@ pack .vpane.lower.commarea.buffer.header -side top -fill x\n>  pack .vpane.lower.commarea.buffer.frame -side left -fill y\n>  pack .vpane.lower.commarea.buffer -side left -fill y\n>  \n> +bind $ui_comm <FocusIn> {check_diff_selected}\n> +\n\nThis would mean the diff shows _only_ when you switch focus to the \ncommit message buffer. If the buffer is already in focus, and you stage \nall files via Ctrl-I, the staged diff would not show.\n\nIIRC you were having some trouble with this. A quick suggestion without \nlooking too much into the problem is to try putting the logic inside \n`do_add_all` instead of inside the bind event handler.\n\n>  # -- Commit Message Buffer Context Menu\n>  #\n>  set ctxm .vpane.lower.commarea.buffer.ctxm\n> -- \n> 2.23.0.windows.1\n> \n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"384205","messageId":"20191016192819.5fxbwdediomj7gaz@yadavpratyush.com","threadId":"51848","inReplyTo":"CAGr--=K8beYCwRgjFdokyCkjguXTJu8wMoxMAMG_H7CVgmEA=g@mail.gmail.com","subject":"Re: [PATCH 1/2] git-gui: implement proc select_path_in_widget","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-10-16T19:28:19Z","receivedAt":"2019-10-16T19:28:25Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 15/10/19 12:51PM, Birger Skogeng Pedersen wrote:\n> Hi Pratyush,\n> \n> Thanks for reviewing. How does this work, do I send a re-roll of the patch(es)?\n\nYes, please do.\n\nI mentioned this earlier, and I'll mention this again: I'm not sure \nwhether this feature would be a good thing for the larger population. So \nthis _might_ not end up being accepted depending on how people react to \nthe proposal. I thought I'd let you know to avoid any nasty surprises \nlater.\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"384227","messageId":"CAGr--=Ltx2JPexfVSWRrAdT0zHs0RWaZdS7OZD-TWJv2y7K-PA@mail.gmail.com","threadId":"51848","inReplyTo":"20191016192819.5fxbwdediomj7gaz@yadavpratyush.com","subject":"Re: [PATCH 1/2] git-gui: implement proc select_path_in_widget","fromName":"Birger Skogeng Pedersen","fromEmail":"birger.sp@gmail.com","sentAt":"2019-10-17T05:08:25Z","receivedAt":"2019-10-17T05:11:36Z","isPatch":true,"sender":{"key":"birger.sp@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5260237?v=4"},"body":"Hi Pratyush,\n\nOn Wed, Oct 16, 2019 at 9:28 PM Pratyush Yadav <me@yadavpratyush.com> wrote:\n> I mentioned this earlier, and I'll mention this again: I'm not sure\n> whether this feature would be a good thing for the larger population. So\n> this _might_ not end up being accepted depending on how people react to\n> the proposal. I thought I'd let you know to avoid any nasty surprises\n> later.\n\nCould you please elaborate on why you think the feature might be\nundesired? Why would users not want a staged file to be selected\nautomatically?\n\nFWIW I've also got 2 comments on this in GH[1].\n\n[1] https://github.com/git-for-windows/git/issues/2341\n\nBest regards,\nBirger\n"},{"id":"384228","messageId":"86d8ea9c-f27e-8ab8-c7f6-b3fd1eb3895d@kdbg.org","threadId":"51848","inReplyTo":"CAGr--=Ltx2JPexfVSWRrAdT0zHs0RWaZdS7OZD-TWJv2y7K-PA@mail.gmail.com","subject":"Re: [PATCH 1/2] git-gui: implement proc select_path_in_widget","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2019-10-17T05:33:05Z","receivedAt":"2019-10-17T05:33:09Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 17.10.19 um 07:08 schrieb Birger Skogeng Pedersen:\n> Hi Pratyush,\n> \n> On Wed, Oct 16, 2019 at 9:28 PM Pratyush Yadav <me@yadavpratyush.com> wrote:\n>> I mentioned this earlier, and I'll mention this again: I'm not sure\n>> whether this feature would be a good thing for the larger population. So\n>> this _might_ not end up being accepted depending on how people react to\n>> the proposal. I thought I'd let you know to avoid any nasty surprises\n>> later.\n> \n> Could you please elaborate on why you think the feature might be\n> undesired? Why would users not want a staged file to be selected\n> automatically?\n\nFWIW, I would prefer to experiment with the feature for a few weeks\nbefore it (or a configuration that enables it by default) is baked in.\n\n-- Hannes\n"},{"id":"384242","messageId":"CAGr--=KBSDjmYEprs6tvTTTv-7K-ApziQ4-xvJacMjNx+dKGPw@mail.gmail.com","threadId":"51848","inReplyTo":"86d8ea9c-f27e-8ab8-c7f6-b3fd1eb3895d@kdbg.org","subject":"Re: [PATCH 1/2] git-gui: implement proc select_path_in_widget","fromName":"Birger Skogeng Pedersen","fromEmail":"birger.sp@gmail.com","sentAt":"2019-10-17T06:54:22Z","receivedAt":"2019-10-17T06:59:12Z","isPatch":true,"sender":{"key":"birger.sp@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5260237?v=4"},"body":"Hi Johannes,\n\nOn Thu, Oct 17, 2019 at 7:33 AM Johannes Sixt <j6t@kdbg.org> wrote:\n> FWIW, I would prefer to experiment with the feature for a few weeks\n> before it (or a configuration that enables it by default) is baked in.\n\nYes please do. Obviously I'm glad someone other than me will be\nactually testing it.\n(As I mentioned earlier) I'm all for it when it comes to using a\nconfig setting, rather than having this as default behaviour. I\npropose \"gui.autoFocusStaged\" as a variable name for the setting.\nI'll be doing a re-roll once I get some more spare time.\n\nBirger\n"},{"id":"384284","messageId":"20191017182833.rzk6r6egmvpmjtns@yadavpratyush.com","threadId":"51848","inReplyTo":"CAGr--=Ltx2JPexfVSWRrAdT0zHs0RWaZdS7OZD-TWJv2y7K-PA@mail.gmail.com","subject":"Re: [PATCH 1/2] git-gui: implement proc select_path_in_widget","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-10-17T18:28:34Z","receivedAt":"2019-10-17T18:28:45Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 17/10/19 07:08AM, Birger Skogeng Pedersen wrote:\n> Hi Pratyush,\n> \n> On Wed, Oct 16, 2019 at 9:28 PM Pratyush Yadav <me@yadavpratyush.com> wrote:\n> > I mentioned this earlier, and I'll mention this again: I'm not sure\n> > whether this feature would be a good thing for the larger population. So\n> > this _might_ not end up being accepted depending on how people react to\n> > the proposal. I thought I'd let you know to avoid any nasty surprises\n> > later.\n> \n> Could you please elaborate on why you think the feature might be\n> undesired? Why would users not want a staged file to be selected\n> automatically?\n\nI have similar arguments to what Philip said in the GitHub link you \nsent. I think software should do what the user tells it to do, and \nshould not try to \"second guess\" them. This second guessing can get \nannoying.\n\nSo if I select the commit message buffer, I told the software to select \nit by clicking it. I did not tell it to switch my diff view. This switch \nof view can prove to be disorienting/confusing to a user because they \ndid not select any diff. They selected a text box.\n\nAt the very least, I think we should have a config option, and it should \nbe turned off by default. That said, I'd certainly like to hear what \nother people think on this topic.\n \n> FWIW I've also got 2 comments on this in GH[1].\n> \n> [1] https://github.com/git-for-windows/git/issues/2341\n\n-- \nRegards,\nPratyush Yadav\n"}]}