vgit.nvim icon indicating copy to clipboard operation
vgit.nvim copied to clipboard

ProjectDiffScreen: Better navigation, hunk reset, UX improvements, and file list display bugfixes

Open MaxFangX opened this issue 1 month ago • 0 comments

ProjectDiffScreen UX Improvements, Features, and Fixes

Demo

Video link

In this demo you can see me pressing tab to toggle the cursor between the file list and the diff pane, using the next and prev bindings in the diff pane to move between hunks, use the next and prev bindings in the file list to move between files, and various changes which make it easy to stage a bunch of hunks quickly simply by pressing s in the diff pane. When opening the project diff screen, your curser is put over the first unstaged diff, so you can begin staging quickly; once all hunks in a file have been staged, you automatically jump to the first unstaged diff in the next file. The overall goal is to make it super fast and seamless to stage a bunch of hunks quickly.

Commits

feat(ProjectDiffScreen): Add Tab to toggle focus

Add configurable keymap to switch between file list and diff preview. When switching to diff, cursor jumps to first hunk.

feat(ProjectDiffScreen): Add hunk_alignment setting

Configurable alignment when jumping to hunks: 'top', 'center', 'bottom'. Defaults to 'center' for better context visibility.

feat(ProjectDiffScreen): Prefer unstaged entries

Focus on changes the user hasn't reviewed yet. Typical workflow: stage some hunks, exit to fix something, then re-enter project diff. Cursor should resume at unstaged changes, not staged ones.

fix: Simplify header row positioning logic

Previously, configure_row() set header_win_plot.row to row + 1, and HeaderElement:mount() compensated by subtracting 1. Now the logic is straightforward: header stays at original row, content is pushed down.

feat: Jump to next unstaged file after staging

When staging the last hunk in a file, jump to the next unstaged file rather than staying on the now-staged entry.

feat: Jump to next staged file after unstaging

When unstaging the last hunk in a file, jump to the next staged file rather than staying on the now-unstaged entry.

feat(ProjectDiffScreen): Add reset_hunk command

Allows discarding individual hunks from the diff pane. Default keybinding r, buffer_reset moved to R.

keymap: Add nowait to buffer-local keymaps

Without nowait, single-key bindings like d can feel sluggish if the user has operator-pending mappings. Vim waits for potential follow-up keys (dd, dw, etc.) before executing.

feat(ProjectDiffScreen): Add next/previous nav

Generalized navigation keybinds (default J/K):

  • In diff pane: navigate between hunks across all files
  • In file list: navigate between files (skipping folders)

Both wrap around and jump to first/last hunk when crossing files.

fix(ProjectDiffScreen): Account for tabline offset

When showtabline > 0 (tabline visible), floating windows with relative='editor' are offset by 1 row. This caused the "Staged Changes" header to be hidden behind the app bar. Fix by adjusting row position based on showtabline setting.

Here is a screenshot of what it looks like prior to the fix: Bug

feat(ProjectDiffScreen): Jump to file position on quit

The diff view is a projection of the file's state. Quitting from the diff pane now jumps to the corresponding file position, keeping context stable.

feat: Remember entry type across sessions

Store vgit_last_entry_type buffer variable on quit. When re-opening ProjectDiffScreen, prefer the same entry type (staged/unstaged) for the file.

MaxFangX avatar Dec 11 '25 07:12 MaxFangX