дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-15 14:15:39 +02:00
Порівняти коміти
1
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
bdf91d67ca |
No files matched your search
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Заблокувати користувача