sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
4k stars 109 forks source link

[Feature Request]Diffview for commit which modified current line #307

Closed sakelkar closed 1 year ago

sakelkar commented 1 year ago

Hi,

Thanks for the great plugin.

Will you please consider, augmenting DiffviewFileHistory or DiffviewOpen to show diffs from commit that modified current line under the current file?

Many times getting the full context of the commit when current line was modified is very very useful. Helps to get the context very quickly. Typically when one is working on hot fixes and not a big feature.

Thanks Sameer

sindrets commented 1 year ago

https://github.com/sindrets/diffview.nvim/blob/d539ef98e4809a38de3d9ea53697fd2f5ad337a6/doc/diffview.txt#L151-L153

sakelkar commented 1 year ago

I had tried that option and sure it traces the given line. I used :DiffviewFileHistory -L<Line1>,<Line1>:<filename> and it seems to work as said.

But I am looking to cycle through other files changes (if any applicable) which were part of that commit when current line changed last time. Since your plugin, is actually centered around cycling through files in a given commit, I thought something like this will also be useful.

Apologies if I am missing something which is already present.

Thanks, Sameer

sindrets commented 1 year ago

I used :DiffviewFileHistory -L<Line1>,<Line1>:<filename> and it seems to work as said.

If you have the buffer open for the file you want to trace, it's much easier to use vim ranges than the -L flag. Just visually select the lines you want to trace and then:

:'<,'>DiffviewFileHistory

The -L flag is only needed if you want to trace multiple ranges in one or more files, or you want to use the -L:{funcname}:{file} regex variant.


But I am looking to cycle through other files changes (if any applicable) which were part of that commit when current line changed last time.

Once you have traced the line history for your given range just put the cursor on whatever commit you wish to inspect and press <C-A-d> in order to :DiffviewOpen the full change set for that specific commit.

sakelkar commented 1 year ago

Works. Thanks _/\_ :)