Skip to content

feat(diff-mode): implement interactive diff/compare#1

Merged
Blankeos merged 1 commit intomainfrom
compare-tool
Mar 26, 2026
Merged

feat(diff-mode): implement interactive diff/compare#1
Blankeos merged 1 commit intomainfrom
compare-tool

Conversation

@Blankeos
Copy link
Copy Markdown
Owner

mode for refs

Add a new diff/compare mode (W key) allowing users to select two refs
(branches, tags, commits) and explore side-by-side file diffs.

Features:

  • Searchable combobox dropdowns for ref selection (A and B)
  • File list view with tree/flat toggle (backtick key)
  • Side-by-side diff exploration with full navigation controls
  • Keyboard shortcuts: Tab (cycle), 1-4 (jump panel), Ctrl+S (swap),
    {/} (hunks), [/] (toggle view), g/G (top/bottom)
  • Mouse support for clicking, scrolling, and text selection in diff

Implementation:

  • New git commands: diff_refs_files() and diff_refs_file()
  • Complete state management (DiffModeState) with dropdown search
  • Controller for key and mouse event handling
  • Presentation layer with dedicated rendering
image

mode for refs

Add a new diff/compare mode (W key) allowing users to
select two refs
(branches, tags, commits) and explore side-by-side file
diffs.

Features:
- Searchable combobox dropdowns for ref selection (A
and B)
- File list view with tree/flat toggle (backtick key)
- Side-by-side diff exploration with full navigation
controls
- Keyboard shortcuts: Tab (cycle), 1-4 (jump panel),
Ctrl+S (swap),
  {/} (hunks), [/] (toggle view), g/G (top/bottom)
- Mouse support for clicking, scrolling, and text
selection in diff

Implementation:
- New git commands: diff_refs_files() and
diff_refs_file()
- Complete state management (DiffModeState) with
dropdown search
- Controller for key and mouse event handling
- Presentation layer with dedicated rendering
@Blankeos Blankeos merged commit c9d8aaa into main Mar 26, 2026
5 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

πŸ’‘ Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e957ea911

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with πŸ‘.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/git/diff.rs
Comment on lines +220 to +223
let mut parts = line.splitn(2, '\t');
let status_str = parts.next().unwrap_or("");
let name = parts.next().unwrap_or("").to_string();
if name.is_empty() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Parse rename/copy entries from --name-status correctly

diff_refs_files splits each status line with splitn(2, '\t'), but git diff --name-status emits three fields for renames/copies (for example, R100\told.txt\tnew.txt). That makes name become old\tnew, which is not a valid path for diff_refs_file, so selecting renamed/copied files in compare mode yields an empty/error diff instead of the file content.

Useful? React with πŸ‘Β / πŸ‘Ž.

Comment on lines +194 to +196
let (ref_value, display) = if let Some(candidate) = self.search_results.get(self.search_selected) {
(candidate.ref_value.clone(), candidate.display.clone())
} else if !query.is_empty() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Allow raw ref input when dropdown has non-matching items

confirm_selection always prefers search_results[search_selected] over the typed query, but search_refs populates the dropdown with all refs (not filtered). In normal repos this means search_results is almost always non-empty, so typing a raw ref like HEAD~20 or a commit outside the 200 cached commits can select an unrelated candidate (often the first branch) instead of the user-entered ref.

Useful? React with πŸ‘Β / πŸ‘Ž.

Some(selected)
};

let Some(idx) = file_idx else { return };
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clear diff panel when tree selection is a directory node

When tree view is enabled, selecting a directory produces file_index == None, and maybe_request_diff returns immediately without resetting diff_view. This leaves the previous file's diff visible while a directory is highlighted, which is inconsistent with other tree-based panels that clear diff content on non-file selections.

Useful? React with πŸ‘Β / πŸ‘Ž.

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.

1 participant