git_ui: Allow opening a file with the diff hunks expanded#40616
Conversation
|
Thanks! I like the idea of having the
|
|
@cole-miller Do you think this should be optional? With a user setting? |
|
I don't think it needs to be a setting. |
c31c69b to
8ceaaf0
Compare
8ceaaf0 to
d1865c3
Compare
|
hey @cole-miller i'm not seeing it used anywhere else in the code ? |
|
@FloppyDisco you'll need something like |
d1865c3 to
753b998
Compare
|
uuuuuugh. i should have figured that one out. lol. thanks. it seems to be working!
Screen.Recording.2025-11-13.at.22.17.44.mov |
|
Thanks! |
…ries#40616) So i just discovered `editor::ExpandAllDiffHunks` I have been really missing the ability to look at changes NOT in a multi buffer so i was very pleased to finally figure out that this is already possible in Zed. i have seen alot of discussion/issues requesting this feature so i think it is safe to say i'm not the only one that is not aware it exists. i think the wording in the docs could better communicate what this feature actually is, however, i think an even better way to show users that this feature exists would be to just put it in front of them. In the `GitPanel`: - `menu::Confirm` opens the project diff - `menu::SecondaryConfirm` opens the selected file in a new editor. I think it would be REALLY nice if opening a file with `SecondaryConfirm` opened the file with the diff hunks already expanded and scrolled the editor to the first hunk. ideally i see this being toggle-able in settings something like `GitPanel - Open File with Diffs Expanded` or something. so the user could turn this off if they preferred. I tried creating a new keybinding using the new `actions::Sequence` it was something like: ```json { "context": "GitPanel && ChangesList", "bindings": { "cmd-enter" : [ "actions::Sequence", ["menu:SecondaryConfirm", "editor::ToggleFocus", "editor::ExpandAllDiffHunks", "editor::GoToHunk"]] } } ``` but the action sequence does not work. i think because opening the file is an async task. i have a first attempt here, of just trying to get the diff hunks to expand after opening the file. i tried to copy and paste the logic/structure as best i could from the confirm method in file_finder.rs:1432 it compiles, but it does not work, and i do not have enough experience in rust or in this project to figure out anything further. if anyone was interested in working on this with me i would enjoy learning more and i think this would be a nice way to showcase this tool!
So i just discovered
editor::ExpandAllDiffHunksI have been really missing the ability to look at changes NOT in a multi buffer so i was very pleased to finally figure out that this is already possible in Zed.
i have seen alot of discussion/issues requesting this feature so i think it is safe to say i'm not the only one that is not aware it exists.
i think the wording in the docs could better communicate what this feature actually is, however, i think an even better way to show users that this feature exists would be to just put it in front of them.
In the
GitPanel:menu::Confirmopens the project diffmenu::SecondaryConfirmopens the selected file in a new editor.I think it would be REALLY nice if opening a file with
SecondaryConfirmopened the file with the diff hunks already expanded and scrolled the editor to the first hunk.ideally i see this being toggle-able in settings something like
GitPanel - Open File with Diffs Expandedor something. so the user could turn this off if they preferred.I tried creating a new keybinding using the new
actions::Sequenceit was something like:
{ "context": "GitPanel && ChangesList", "bindings": { "cmd-enter" : [ "actions::Sequence", ["menu:SecondaryConfirm", "editor::ToggleFocus", "editor::ExpandAllDiffHunks", "editor::GoToHunk"]] } }but the action sequence does not work. i think because opening the file is an async task.
i have a first attempt here, of just trying to get the diff hunks to expand after opening the file.
i tried to copy and paste the logic/structure as best i could from the confirm method in file_finder.rs:1432
it compiles, but it does not work, and i do not have enough experience in rust or in this project to figure out anything further.
if anyone was interested in working on this with me i would enjoy learning more and i think this would be a nice way to showcase this tool!