gdiff: make generated hunk actionability capability-aware #122
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
barrettruth/diffs.nvim#122
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent tracker: #270
Problem
Generated
:Gdiffhunk metadata currently marks more edges actionable than the action layer actually supports.Examples:
rev -> worktreehunks getmutation_target = "worktree"fromDiffSpec.mutation_target().hunks.parse()marks any non-nil mutation target asactionable = true.doanddp.actions.obtain_hunk()refusesindex -> worktreewithrestoring worktree hunks is not supported.actions.put_hunk()refuses read-only or already-index edges where staging does not make sense.This mismatch is confusing. It advertises operations that are not implemented.
Product decision
Generated
diffs://buffers are plugin-owned UI, so they may install default maps without requiring user configuration.But maps should be capability-aware:
index -> worktree: installdpfor stage current hunk/range; do not installdounless restoring worktree becomes supported later.tree -> index: installdofor unstage current hunk/range; do not installdpbecause the hunk is already in the index.tree -> worktree: read-only generated comparison; nodo/dp.tree -> tree: read-only generated comparison; nodo/dp.]c,[c,<CR>,o,q.This should not force users to configure generated-buffer maps. Generated buffers are owned by the plugin.
Relevant existing code
lua/diffs/behavior.luamutation_target()returns"index"whenever right endpoint is index and"worktree"whenever right endpoint is worktree.lua/diffs/hunks.luanormalize_spec()setsactionable = target ~= nil.lua/diffs/commands.luasetup_diff_buf()installsdo,dp, visualdo, and visualdpwheneverdiffs_hunksexists.lua/diffs/actions.luaput_hunk/put_range: supportsindex -> worktreestaging.obtain_hunk/obtain_range: supportstree -> indexunstaging.Implementation guidance
Introduce a capability model instead of overloading
mutation_targetas "actionable".Possible shape:
diffs.behaviorordiffs.hunksreturning:can_stagecan_unstagecan_open_sourceread_onlycommands.setup_diff_buf()andhunks.parse()if a broader API would be premature.Keep the code conservative. Do not add worktree-restore semantics in this issue.
Acceptance criteria
do/dpmaps.Completed by #268. Current hunk metadata uses can_put/can_obtain, actionability is capability-based, generated buffers install only the meaningful do/dp maps, and the behavior is covered in diffspec, hunks, and UX specs.