Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai bdf91d67ca fix(editor): clicking the author hint again closes the blame annotations
The Code Vision author hint ran Annotate with Git Blame only while the
annotations were hidden, so a second click left them open and closing them
took the gutter's context menu. The hint now runs the action every time, which
toggles the annotations like the Annotate with Git Blame action itself.
2026-11-15 03:03:20 +08:00
2 змінених файлів з 22 додано та 5 видалено

No files matched your search

+17
Переглянути файл
@@ -8,6 +8,7 @@ const ipc = vi.hoisted(() => ({
docOutline: vi.fn(),
lspReferences: vi.fn(),
cancelRequest: vi.fn<(id: number) => Promise<void>>(async () => {}),
vcsBlame: vi.fn(),
}));
vi.mock("@/platform/ipc", async (orig) => {
const real = await orig<typeof import("@/platform/ipc")>();
@@ -102,6 +103,22 @@ describe("usages lens targets", () => {
});
});
describe("author hint", () => {
it("toggles the blame annotations on every click", async () => {
ipc.vcsBlame.mockResolvedValue(ok([{ commit: "c1", author: "Ann", timeMs: 1, summary: "init" }]));
useProject.setState({
settings: { editor: { inlay: { codeVisionUsages: false, codeVisionAuthor: true } } } as never,
});
const view = editor();
await settle();
const author = view.state.facet(codeLenses).find((l) => l.kind === "author")!;
expect(author.title).toContain("Ann");
author.run!(view, new MouseEvent("click"));
author.run!(view, new MouseEvent("click"));
expect(executeAction.mock.calls).toEqual([["vcs.annotate"], ["vcs.annotate"]]);
});
});
describe("background usage counts", () => {
it("uses the server's existing scope and leaves full searches to the explicit action", async () => {
const view = editor();
+5 -5
Переглянути файл
@@ -15,7 +15,7 @@ import { EditorSelection, MapMode, StateEffect, StateField, type Extension, type
import { EditorView, ViewPlugin, type ViewUpdate } from "@codemirror/view";
import { codeLenses, onEditorEvent, shownAgain, type CodeLens } from "@/editor/api";
import { onNavigationProvidersChanged } from "@/editor/navigationProviders";
import { executeAction, getAction } from "@/platform/actions";
import { executeAction } from "@/platform/actions";
import { commands, nextRequestId, onIdeEvent, type OutlineItem, type RequestId, type SymbolKind } from "@/platform/ipc";
import { useProject } from "@/platform/project";
import { debounce, docOf, isUnavailable, lspRequest } from "./lsp";
@@ -112,10 +112,10 @@ const lensField = StateField.define<CodeLens[]>({
const usagesEnabled = () => editorPrefs().inlay.codeVisionUsages;
const authorEnabled = () => editorPrefs().inlay.codeVisionAuthor;
/** The author hint opens the file's blame annotations, and leaves them open when shown. */
function showAnnotations(view: EditorView) {
/** The author hint runs Annotate with Git Blame: it shows the file's annotations, or closes them when shown. */
function toggleAnnotations(view: EditorView) {
view.focus();
if (!getAction("vcs.annotate")?.toggled?.()) void executeAction("vcs.annotate");
void executeAction("vcs.annotate");
}
function openUsages(view: EditorView, offset: number) {
@@ -309,7 +309,7 @@ class UsagesLensPlugin {
icon: "user",
order: 20,
kind: "author",
run: showAnnotations,
run: toggleAnnotations,
});
const n = usages ? this.cache.get(key(t)) : undefined;
if (n !== undefined) {