Skip to content

Refactor: clean up path parameter naming in diff.show_diff #55

@Cannon07

Description

@Cannon07

Motivation

lua/code-preview/diff.lua show_diff(original_path, proposed_path, real_file_path, abs_file_path, action) takes four path-like parameters whose names have drifted. Two are misleading:

  • real_file_path is not the real path — it's the display string used in the winbar (often a cwd-relative path). The name implies it's the canonical identity.
  • abs_file_path is the actual canonical identity (key in active_diffs, passed to the changes registry, used by neo-tree reveal).
  • original_path / proposed_path are paths to temp files (/tmp/claude-diff-{original,proposed}-<pid>) holding the before/after content — not the real file.

A reader (or future-us during issue #47 phase 3) will misuse these. The friction shows up in diff.lua, bin/core-pre-tool.sh, and bin/apply-patch.lua, all of which thread these args through.

Proposed naming

The three concepts:

  • Source paths — the two temp files: original_source_path, proposed_source_path.
  • File path — the canonical absolute path of the real file (identity): file_path.
  • Display path — what's shown in the winbar: display_path.

So: show_diff(original_source_path, proposed_source_path, display_path, file_path, action).

Scope

  • Pure refactor. No behaviour change.
  • Touches lua/code-preview/diff.lua (function signature + internal use), bin/core-pre-tool.sh and bin/apply-patch.lua (call sites, JSON arg keys).
  • Tests under tests/plugin/diff_lifecycle_spec.lua may reference parameter names — update accordingly.

Out of scope

Acceptance

  • All references to real_file_path and abs_file_path removed in favour of display_path and file_path.
  • All references to original_path / proposed_path for temp content files renamed to _source_path.
  • Existing tests pass with no behaviour change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions