Skip to content

refactor(diff): clarify path parameter names in show_diff (#55)#89

Open
AzarAI-TOP wants to merge 1 commit into
Cannon07:mainfrom
AzarAI-TOP:refactor/diff-path-param-names
Open

refactor(diff): clarify path parameter names in show_diff (#55)#89
AzarAI-TOP wants to merge 1 commit into
Cannon07:mainfrom
AzarAI-TOP:refactor/diff-path-param-names

Conversation

@AzarAI-TOP

Copy link
Copy Markdown

Closes #55.

What

Renames the path-like parameters threaded through lua/code-preview/diff.lua so their names match what they actually hold:

Old New Meaning
real_file_path display_path the winbar display string (often a cwd-relative path)
abs_file_path file_path the canonical identity — active_diffs key, passed to the changes registry / neo-tree reveal
original_path original_source_path temp file holding the before content
proposed_path proposed_source_path temp file holding the after content

So the signature becomes:

M.show_diff(original_source_path, proposed_source_path, display_path, file_path, action, backend)

Scope

Pure rename, no behaviour change. Touches the four functions that thread these args:
mark_change_and_reveal, build_inline_diff, show_inline_diff, and M.show_diff — plus two now-stale comments in tests/plugin/diff_lifecycle_spec.lua.

A couple of notes vs. the issue description, since the code has moved since it was filed:

  • The show_diff call sites now live in lua/code-preview/pre_tool/init.lua and already pass display_path(...) / file_path positionally, so they need no change.
  • bin/core-pre-tool.sh referenced in the issue no longer exists on main; there are no remaining references to the old names anywhere in the repo (grep clean).

Acceptance criteria

  • 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 (temp content files) renamed to *_source_path
  • Existing tests pass with no behaviour change

Testing

./tests/run_lua.sh — all plugin specs pass: 9 files, 0 failures, 0 errors (incl. diff_lifecycle_spec.lua, 18/18). Neovim v0.12.

The path-like parameters threaded through diff.lua had drifted from what
they actually hold, making them easy to misuse. Rename them to match the
vocabulary in Cannon07#55:

- real_file_path -> display_path          (winbar display string, often cwd-relative)
- abs_file_path  -> file_path             (canonical identity; active_diffs key)
- original_path  -> original_source_path  (temp file holding the before content)
- proposed_path  -> proposed_source_path  (temp file holding the after content)

Pure rename, no behaviour change. Updates the four affected functions
(show_diff, show_inline_diff, build_inline_diff, mark_change_and_reveal)
and two now-stale comments in diff_lifecycle_spec.lua. The show_diff call
sites in pre_tool/init.lua already pass display_path/file_path positionally,
so they need no change. bin/core-pre-tool.sh referenced in the issue no
longer exists on main.

All plugin specs pass (./tests/run_lua.sh): 9 files, 0 failures, 0 errors.

Closes Cannon07#55

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

Refactor: clean up path parameter naming in diff.show_diff

1 participant