feat: select next and previous files when staging chunks#2022
feat: select next and previous files when staging chunks#2022Danielku15 wants to merge 2 commits intosourcegit-scm:developfrom
Conversation
|
I don't think it's a good idea to determine the selection after refreshing based on the index of the previously selected data. This is particularly evident when users view in the
|
This is indeed a use-case I wasn't considering correctly. I mainly use the flat list where the index approach worked fine. My main goal was to shift the logic from the UI to the ViewModel layer. Currently a lot of the logic in SourceGit is unfortunately in the UI layer and not handled through pure ViewModel bindings and command approaches.
This is again an unfortunate result of not having a full ViewModel approach where the UI really just presents what is contained in the ViewModels. Seems too much UI logic interferes with my mental-model of working in ViewModels to solve this problem. I will close this PR and go back to the scratchpad to find out how I can make the "next file" information available in the diff editor where we stage chunks. I might be forced to introduce some "coupling" between the diff editor and the WorkingCopy component for that. In best case I can move some more UI things down into the ViewModel level to have the "next file" logic available. 😁 I analyzed the current actual behavior, and my expected behavior as reference for the change. Any feedback appreciated. There would be alternative approaches to the current "go next":
It's mostly a matter of preference regarding the hierarchy. But the "jump to first on staging last" seems a usability flaw worth addressing directly. |
See #2005
Old Behavior: When staging whole files, SourceGit tried to find a next/previous file within the same changed file list which could be selected afterwards. But when users staged/unstaged the individual chunks no selection was done leaving you with an empty view forcing you to select a file manually. This was cumbersome when staging the files chunkwise.
New Behavior: Internally SourceGit remembers the index of the selected file. Whenever the changed file list is updated (due to refresh or staging/unstaging) we use the remembered index to select a new file if the selection is gone. Thanks to this logic, it doesn't matter how the change was done. We select the file at the same spot if the selected item is gone.
Demo:
SourceGit_iPMfXgyfGb.mp4