Skip to content

feat: add --commits cli flag and Ctrl+G dual-diff toggle between files and head - #34

Merged
Blankeos merged 2 commits into
Blankeos:mainfrom
felipecm-br:feat/cli-commits
Oct 6, 2026
Merged

Blankeos merged 2 commits into
Blankeos:mainfrom
felipecm-br:feat/cli-commits

Conversation

@felipecm-br

Copy link
Copy Markdown
Contributor

Overview

This PR introduces a convenient dual-diff toggle shortcut and a CLI startup flag that improves the workflow when navigating between uncommitted local changes and the most recent commit on HEAD.

Key Features

  1. --commits CLI flag:

    • Launches lazygitrs focused directly on the Commits panel at HEAD (selection index 0).
    • Useful for shell aliases (e.g. alias lglog='lazygitrs --commits') or editor integrations specifically aimed at inspecting commit history.
  2. Dual-diff toggle (Ctrl+G):

    • Easily bounce back and forth between working tree changes and HEAD:
      • When in the Files context (or when focused on a working tree diff), pressing Ctrl+G switches immediately to Commits at HEAD.
      • When in Commits, CommitFiles, or Reflog, pressing Ctrl+G switches directly back to Files.
    • Fully customizable via keybinding.universal.toggleWorkingTreeAndHead in config.yml (defaults to "<c-g>").
    • Works consistently whether sidebar or diff pane is focused.
  3. Status Bar Hints & Command Palette:

    • Context-aware status bar hints dynamically show ctrl+g head when in Files and ctrl+g files when in Commits/CommitFiles.
    • Documented in the Command Palette (?) under Universal commands and Diff view commands.

Test Coverage

  • Unit tests for the --commits CLI flag parsing.
  • Unit tests for GUI context switching and selection reset to HEAD.
  • Unit tests for Ctrl+G key event handling both in sidebar and diff-focused modes.
  • Unit tests for status bar hint rendering and keybinding formatting.

Integrate current main and Blankeos#36 filter hints. Preserve active commit filters using a separate HEAD history view when HEAD is outside the loaded list. Select HEAD after startup streaming without overriding navigation, and honor remapped/disabled shortcuts. Add regression coverage for branches, filtering, detached/unborn HEAD, refresh and startup.
@Blankeos

Blankeos commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Fixed and validated in 809417f: select the actual checked-out HEAD by hash (not index zero); preserve filters with a separate HEAD history view when filters/pagination exclude HEAD; honor remapped and disabled shortcuts; resolve integration with #36; and select startup HEAD after history arrives without overriding user navigation. Added regression tests for another branch ahead of HEAD, path/author/branch filters, detached and unborn HEAD, refresh, and startup. All 284 tests pass, cargo fmt --check passes, and the binary builds.

@Blankeos Blankeos left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed updated implementation and validated against current main: 284 tests pass, formatting passes, and binary builds. HEAD/filter semantics and key remapping issues are addressed.

@Blankeos
Blankeos merged commit 4ca533a into Blankeos:main Oct 6, 2026
6 checks passed
@Blankeos

Blankeos commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Dual-diff toggle (Ctrl+G):

Easily bounce back and forth between working tree changes and HEAD:
When in the Files context (or when focused on a working tree diff), pressing Ctrl+G switches immediately to Commits at HEAD.
When in Commits, CommitFiles, or Reflog, pressing Ctrl+G switches directly back to Files.
Fully customizable via keybinding.universal.toggleWorkingTreeAndHead in config.yml (defaults to "").
Works consistently whether sidebar or diff pane is focused.

Hi @felipecm-br I merged this PR, but I kinda went back to this particular change... I noticed this behavior actually isn't in the original lazygit. Also, I don't see how this makes it more convenient than just pressing 2 and 4 separately. It seems to be the same behavior.

Edit: I decided to remove the ctrl-G, we already have ctrl-G for "generating commit message" afterall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants