A3: add untracked files to .gitignore from the Changes context menu

git.ignore appends one anchored, escaped literal pattern per path to the
work tree root's .gitignore, skipping patterns already there. The Changes
window gets a row context menu (right click, Shift+F10, context-menu key)
with Open and Add to .gitignore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-10-31 14:33:42 +01:00
parent ce681871ad
commit 68599fa2ac
14 changed files with 633 additions and 5 deletions

View file

@ -20,6 +20,9 @@
* `vcs.showDiff {path, staged}` when something provides it (the diff
* viewer, M4.3); until then the file opens in the editor (`file.open`),
* unless it was deleted.
* - **Context menu (C7 A3):** a right click on a row, or Shift+F10 / the
* context-menu key on the selected one, opens `ChangesContextMenu.vue`:
* Open, and Add to .gitignore for untracked files.
* - **Commit box:** the message, an Amend checkbox and Commit. Commit
* saves dirty buffers first (`flushDirty`); `Mod+Enter` in the box
* commits too.
@ -35,6 +38,7 @@ import { t } from "../../../i18n";
import { run } from "../../../ipc";
import { baseName } from "../../../stores/editor";
import { useNotificationsStore } from "../../../stores/notifications";
import ChangesContextMenu from "./ChangesContextMenu.vue";
import { SHORT_HASH, useChangesStore, type ChangeRow, type FileState, type GroupId } from "./changes";
const changes = useChangesStore();
@ -46,6 +50,27 @@ const list = ref<HTMLElement | null>(null);
/** The commit message box. */
const messageBox = ref<HTMLTextAreaElement | null>(null);
/** The open context menu: its row and where it shows; null when closed. */
const menu = ref<{ row: ChangeRow; x: number; y: number } | null>(null);
/**
* Opens the context menu of a row.
*
* @param row - the row; it becomes the selection.
* @param x - window x of the menu.
* @param y - window y of the menu.
*/
function openMenu(row: ChangeRow, x: number, y: number): void {
changes.select(row.key);
menu.value = { row, x, y };
}
/** Closes the context menu and gives the focus back to the list. */
function closeMenu(): void {
menu.value = null;
list.value?.focus();
}
/** Rows moved by Page Up and Page Down. */
const PAGE = 10;
@ -259,6 +284,10 @@ function onListKey(event: KeyboardEvent): void {
} else if (event.key === " " && row) {
event.preventDefault();
void changes.toggle(row);
} else if ((event.key === "ContextMenu" || (event.key === "F10" && event.shiftKey)) && row) {
event.preventDefault();
const rect = document.getElementById(optionId(changes.selectedIndex))?.getBoundingClientRect();
openMenu(row, rect ? rect.left + 24 : 0, rect ? rect.bottom : 0);
}
}
@ -399,6 +428,7 @@ watch(
data-test="changes-row"
@click="changes.select(row.key)"
@dblclick="openRow(row)"
@contextmenu.prevent="openMenu(row, $event.clientX, $event.clientY)"
>
<input
type="checkbox"
@ -420,6 +450,14 @@ watch(
</div>
</div>
</div>
<ChangesContextMenu
v-if="menu"
:row="menu.row"
:x="menu.x"
:y="menu.y"
@close="closeMenu"
@open="openRow"
/>
<form
class="changes__commit"
data-test="changes-commit"