feat: respect clients that doesn't have a client-side codelens handler

This commit is contained in:
Myriad-Dreamin 2025-11-16 06:04:43 +08:00
parent 62456fda01
commit 3bf3a65734
6 changed files with 34 additions and 2 deletions

View file

@ -66,6 +66,32 @@ impl SemanticRequest for CodeLensRequest {
vec!["more".into()],
);
if !ctx.analysis.support_client_codelens
&& let Some(uri) = path_to_url(&self.path)
.ok()
.and_then(|u| serde_json::to_value(u).ok())
{
res.push(CodeLens {
range: doc_start,
command: Some(Command {
title: if is_html {
tinymist_l10n::t!("tinymist-query.code-action.exportPdf", "Export PDF")
} else {
tinymist_l10n::t!("tinymist-query.code-action.exportHtml", "Export HTML")
}
.to_string(),
command: if is_html {
"tinymist.exportPdf"
} else {
"tinymist.exportHtml"
}
.to_string(),
arguments: Some(vec![uri]),
}),
data: None,
})
}
Some(res)
}
}