feat: move less used codelens into a single "more" codelens (#1315)

* feat: move less used codelens into a single "more" codelens

* dev: update snapshot
This commit is contained in:
Myriad-Dreamin 2025-02-18 20:16:48 +08:00 committed by GitHub
parent f4f3e24cb1
commit deb1425e74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 80 additions and 63 deletions

View file

@ -33,9 +33,8 @@ impl SemanticRequest for CodeLensRequest {
res.push(doc_lens("Profile", vec!["profile".into()]));
res.push(doc_lens("Preview", vec!["preview".into()]));
res.push(doc_lens("Preview in ..", vec!["preview-in".into()]));
res.push(doc_lens("Export PDF", vec!["export-pdf".into()]));
res.push(doc_lens("Export as ..", vec!["export-as".into()]));
res.push(doc_lens("More ..", vec!["more".into()]));
Some(res)
}

View file

@ -529,6 +529,8 @@ async function commandRunCodeLens(...args: string[]): Promise<void> {
if (args.length === 0) {
return;
}
// res.push(doc_lens("Preview in ..", vec!["preview-in".into()]));
// res.push(doc_lens("Export as ..", vec!["export-as".into()]));
switch (args[0]) {
case "profile": {
@ -539,7 +541,29 @@ async function commandRunCodeLens(...args: string[]): Promise<void> {
void vscode.commands.executeCommand(`typst-preview.preview`);
return;
}
case "preview-in": {
case "export-pdf": {
await commandShow("Pdf");
return;
}
case "more": {
return codeLensMore();
}
default: {
console.error("unknown code lens command", args[0]);
}
}
async function codeLensMore(): Promise<void> {
const kPreviewIn = "Preview in .." as const;
const kExportAs = "Export as .." as const;
const moreCodeLens = [kPreviewIn, kExportAs] as const;
const moreAction = (await vscode.window.showQuickPick(moreCodeLens, {
title: "More Actions",
})) as (typeof moreCodeLens)[number] | undefined;
switch (moreAction) {
case kPreviewIn: {
// prompt for enum (doc, slide) with default
const mode = await vscode.window.showQuickPick(["doc", "slide"], {
title: "Preview Mode",
@ -561,11 +585,7 @@ async function commandRunCodeLens(...args: string[]): Promise<void> {
void vscode.commands.executeCommand(`typst-preview.${command}`);
return;
}
case "export-pdf": {
await commandShow("Pdf");
return;
}
case "export-as": {
case kExportAs: {
enum FastKind {
PDF = "PDF",
SVG = "SVG (First Page)",
@ -603,8 +623,6 @@ async function commandRunCodeLens(...args: string[]): Promise<void> {
return;
}
default: {
console.error("unknown code lens command", args[0]);
}
}
}

View file

@ -374,7 +374,7 @@ fn e2e() {
});
let hash = replay_log(&tinymist_binary, &root.join("neovim"));
insta::assert_snapshot!(hash, @"siphash128_13:cd193b47cc7db3edf339eb048f34f4e2");
insta::assert_snapshot!(hash, @"siphash128_13:10cac959ce095e74fb67e37b7aa16b7");
}
{
@ -385,7 +385,7 @@ fn e2e() {
});
let hash = replay_log(&tinymist_binary, &root.join("vscode"));
insta::assert_snapshot!(hash, @"siphash128_13:e9f262b45e59ec0c1f282f36103c419");
insta::assert_snapshot!(hash, @"siphash128_13:2d215826585b3025e2f84937f4e92821");
}
}