zed icon indicating copy to clipboard operation
zed copied to clipboard

See diff between renamed/moved files

Open katie-z-geer opened this issue 1 month ago • 6 comments

When a file is renamed or moved to a new directory, the Git panel in Zed shows a file deleted and a file added. In VSCode when the same flow happens, once you stage the changes, it is able to determine that the file was just renamed or moved, and show you the actual diff for that file (either no changes or some changes if the file was also edited). I can provide screenshots to the VSCode functionality if needed, but I think most people will be familiar with what I am talking about. Please let me know if more info is needed, thanks!

Originally posted by @secondl1ght in https://github.com/zed-industries/zed/discussions/27044

katie-z-geer avatar Nov 19 '25 18:11 katie-z-geer

Hey could I take a crack at this?

PhysicsACE avatar Nov 19 '25 18:11 PhysicsACE

I think this can easily be fixed by dropping --no-renames from the porcelain status invocation so the git crate now surfaces StatusCode::Renamed entries to the Git panel. Reference here https://github.com/xipeng-jin/zed/blob/27cb01f4af113abfcafe2812a796afd658a28c9e/crates/git/src/repository.rs#L2048.

But the only thing should note here is this fix will keep their existing design boundaries intact which means the git panel will still render the new renamed file as a new added file with the "+" green icon under "Tracked" header. But the difference is we only show one row rather than two (deleted/added) which is expected. But I think we can have an alternative design for renaming scenarios. Thank you

xipeng-jin avatar Nov 19 '25 20:11 xipeng-jin

Hi! I am almost there. I already detect renamed/moved file, now need to choose custom icon showing it was moved, or leave "+" for now? Please assign me to it.

flashus avatar Nov 21 '25 09:11 flashus

Image
Is this layout ok or I need to change something?

flashus avatar Nov 21 '25 10:11 flashus

Does the diff only show changes in the file? So if it was renamed/moved there is no diff, but if edits were also made then those changes show up?

secondl1ght avatar Nov 21 '25 17:11 secondl1ght

@secondl1ght Great question! I forgot to check this case initially, now work on it.

flashus avatar Nov 23 '25 00:11 flashus

@secondl1ght Fixed it.

flashus avatar Nov 24 '25 07:11 flashus

@ddoemonn and @flashus : I'm not sure if your two pr are similar in subject matter, I'm talking about #43077 and #43246.

Angelk90 avatar Nov 26 '25 18:11 Angelk90

@Angelk90 yeah, it seems very similar, but I guess we need guidance from the team here about the expectations and direction.

ddoemonn avatar Nov 26 '25 18:11 ddoemonn

IMO since one of @ddoemonn's related PRs (#42352) has already been reviewed by Zed team member @cole-miller and included in a release, it makes sense to update his new PR #43077 to include the same functionality he did for git mv, for renaming/moving files using the Zed project panel. This would close out this issue and be a big improvement, most users are likely using the Zed UI for this action instead of the terminal. This would also bring us closer to feature parity with VSCode.

secondl1ght avatar Nov 26 '25 19:11 secondl1ght

Seems like duplicate issue.

flashus avatar Nov 26 '25 22:11 flashus

@cole-miller should we close this?

esthertrapadoux avatar Dec 03 '25 14:12 esthertrapadoux

@esthertrapadoux we shouldn't close this unless this functionality gets included in #43077. The normal flow is for a PR to close an issue, but currently there is no PR that addresses this issue.

secondl1ght avatar Dec 03 '25 16:12 secondl1ght