C3: chunk staging, unstaging and revert from the gutter and the diff viewer

- crates/vcs chunk.rs: chunks of a file (buffer text vs index, HEAD vs
  index), a minimal patch applied with git apply --cached, revert as a
  byte edit; token refusal when buffer, index or HEAD changed; CRLF
  (autocrlf and stored), no final newline, BOM, staged renames, first
  commit; binary and untracked refused. Real-git tests + property test.
- engine: git.chunks, git.stageChunk, git.unstageChunk, git.revertChunk
  (revert edits the buffer under the lock, undoable in the editor);
  cmd::git::start_then; git.lineChanges shares the vcs line diff.
- UI: chunk popup on a gutter marker click (Stage / Unstage / Revert /
  Previous / Next), hollow staged markers, vcs.showChunk, diff viewer
  hint, "partly staged" badge in the Changes window.
- Docs: G8 row, Git parity row evidence, ui-parity, architecture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-11-01 12:50:11 +01:00
parent d8e66a4652
commit 301443db7d
28 changed files with 3159 additions and 101 deletions

View file

@ -36,7 +36,8 @@
* `vcs.showCommit {hash}` (M4.7) shows the Log with that commit selected
* (a click on a blame annotation); `vcs.toggleBlame {path?}` shows or
* hides the blame annotations of a file (default: the active tab's, once
* tabs for buffers just opened are adopted). No
* tabs for buffers just opened are adopted). `vcs.showChunk` (C8 C3)
* opens the chunk popup at the caret line of the editor shown last. No
* default shortcuts.
*
* A slim header bar along the top (M3.9) holds the app menu
@ -60,6 +61,8 @@ import LogToolWindow from "../vcs/log/LogToolWindow.vue";
import { SHOW_HISTORY_COMMAND, SHOW_LOG_COMMAND, useLogStore } from "../vcs/log/log";
import StashDialog from "../vcs/stash/StashDialog.vue";
import { SHOW_COMMIT_COMMAND, TOGGLE_BLAME_COMMAND, setCommitOpener, toggleBlame } from "../editor/blame";
import { SHOW_CHUNK_COMMAND, openChunkPopup } from "../editor/chunkPopup";
import { activeView } from "../editor/nav/navExtension";
import { useEditorStore } from "../../stores/editor";
import { useProjectStore } from "../../stores/project";
import ProjectToolWindow from "../project/ProjectToolWindow.vue";
@ -261,6 +264,15 @@ onMounted(() => {
},
enabled: () => project.root !== null,
}),
commands.provide(SHOW_CHUNK_COMMAND, {
run: async () => {
const view = activeView();
if (view) {
await openChunkPopup(view, view.state.doc.lineAt(view.state.selection.main.head).number - 1);
}
},
enabled: () => project.root !== null && activeView() !== null,
}),
commands.provide("view.toggleStructure", {
run: () => {
toggleLeft("structure");