Diff mode: highlight unsaved mutations in oil buffers #37
Labels
No labels
autorelease: pending
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
upstream/digest
upstream/pr
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
barrettruth/canola.nvim#37
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?
Problem
Oil buffers give no visual feedback about pending mutations before
:w. After editing lines — renaming a file, adding new entries, or deleting lines — there is no indication of what will happen when the buffer is saved. Users must mentally track their edits or save to find out.Consolidates
Feature: pending mutation highlights
Run
parser.parse()onCursorHoldandTextChanged(debounced or gated toCursorHoldonly to avoid per-keystroke overhead), cache the resulting diff, then apply decorations vianvim_set_decoration_providerso highlights update on every redraw without touching buffer content.Three states to indicate:
CanolaPendingMove.CanolaPendingCreate.CanolaPendingDelete, showing the entry name struck through or dimmed.Highlight groups (all off by default until the feature is enabled):
CanolaPendingMoveDiffChangeCanolaPendingCreateDiffAddCanolaPendingDeleteDiffDeletePerformance
parser.parse()walks the buffer line-by-line and is already fast, but running it on everyTextChangedevent (every inserted character) is likely too much. The plan:CursorHold(fires afterupdatetimems of inactivity). This covers the common case with no latency visible to the user.TextChangedpath that only re-parses the current line (not the full buffer) and updates just that line's extmark. Full re-diff deferred toCursorHold.Config
Off by default. Opt in via:
This is a new UX paradigm (the buffer is no longer just a text file) so it should not be on by default.
Follow-on: mark and diff (stevearc/oil.nvim#659)
The upstream issue asks for a netrw-style workflow: mark several files in the oil buffer, then open them in a vimdiff split. This is a separate feature from pending mutation highlights, but fits naturally alongside it (both involve annotating entries in the buffer). Scope:
mark_entryaction that toggles a mark on the entry under the cursor, shown via a sign or virtual text glyph.diff_markedaction that opens all marked entries in vimdiff splits.This can be designed and implemented independently once the highlight infrastructure from the main feature is in place.
Complexity
Non-trivial. The decoration provider approach must co-exist with the existing semantic highlight provider planned in #129. Parser changes needed to expose per-line diff state for incremental updates. Ghost lines for deleted entries require careful extmark placement to stay stable as surrounding lines shift.
Closing — the confirmation dialog already shows every pending mutation before execution. Diff mode would duplicate this with significant complexity (ghost line extmarks, decoration provider interaction) for marginal practical value. Navigation is 90%+ of file manager usage; the mutation editing path already has adequate feedback.