Skip to content

Conversation

@markdorison
Copy link
Contributor

Summary

Adds the ability to toggle between side-by-side and unified diff views, addressing #10 and completing the work started in #46.

  • Add --side-by-side/-s and --unified/-u CLI flags
  • Add ui.sideBySide config option (default: true)
  • Add s keybinding to toggle view mode at runtime

Details

The implementation follows the existing iconStyle pattern: config sets the default, CLI flags override per-invocation, and keyboard shortcut toggles at runtime.

Priority order: CLI flag > Config > Default (side-by-side)

This addresses the PR #46 feedback by providing both flags, allowing users who prefer delta's convention to use --unified as their default via shell alias while preserving diffnav's existing behavior.

Usage

# Force unified view
git diff | diffnav --unified
git diff | diffnav -u

# Force side-by-side view
git diff | diffnav --side-by-side
git diff | diffnav -s

# Config file (~/.config/diffnav/config.yml)
ui:
  sideBySide: false  # Start in unified mode

# Toggle at runtime: press 's'

Test plan

  • git diff | diffnav shows side-by-side for modified files (default)
  • git diff | diffnav --unified shows unified view
  • git diff | diffnav -u shorthand works
  • Press s toggles view and re-renders current diff
  • View mode persists when navigating between files
  • New/deleted files always show unified (side-by-side makes no sense for them)
  • Config sideBySide: false starts in unified mode
  • CLI flag overrides config setting

Closes #10

Copy link
Owner

@dlvhdr dlvhdr left a comment

Choose a reason for hiding this comment

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

this is really good! thank you!
just had a minor nit

main.go Outdated
sideBySide = true
}

p := tea.NewProgram(ui.New(input, cfg, sideBySide), tea.WithMouseAllMotion())
Copy link
Owner

Choose a reason for hiding this comment

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

Can we keep NewProgram to recieve only 2 params? Let's just merge the
sideBySide flag into the existing config and override its value if the user
specified the flag explicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

@dlvhdr dlvhdr merged commit 4bfcf87 into dlvhdr:main Jan 14, 2026
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.

Disable side-by-side

2 participants