Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

Commit 4c0de33

Browse files
author
Seray Uzgur
committed
better docs ui
1 parent 27553c0 commit 4c0de33

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/toml/decorations.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ function decoration(
4848
const currentVersion = item.value;
4949
const hasLatest = satisfies(versions[0], currentVersion || "0.0.0");
5050

51-
const hoverMessage = error ? new MarkdownString(`**${error}**`) : new MarkdownString(`### Docs`);
52-
hoverMessage.appendMarkdown(`\n * [Latest](https://docs.rs/crate/${item.key}/${versions[0]})`);
53-
hoverMessage.appendMarkdown(`\n * [Current](https://docs.rs/crate/${item.key}/${currentVersion}) \n\n`);
54-
hoverMessage.appendMarkdown("### Available Versions");
51+
const hoverMessage = error ? new MarkdownString(`**${error}**`) : new MarkdownString(`### Versions`);
5552
hoverMessage.isTrusted = true;
5653

5754
if (versions.length > 0) {
@@ -69,8 +66,10 @@ function decoration(
6966
start,
7067
end,
7168
};
69+
const isCurrent = version === currentVersion;
7270
const encoded = encodeURI(JSON.stringify(replaceData));
73-
const command = `[${version}](command:crates.replaceVersion?${encoded}) [ (docs)](https://docs.rs/crate/${item.key}/${version})`;
71+
const docs = (i === 0 || isCurrent) ? `[ (docs)](https://docs.rs/crate/${item.key}/${version})` : "";
72+
const command = `${isCurrent ? "**" : ""}[${version}](command:crates.replaceVersion?${encoded})${docs}${isCurrent ? "**" : ""}`;
7473
hoverMessage.appendMarkdown("\n * ");
7574
hoverMessage.appendMarkdown(command);
7675
}

0 commit comments

Comments
 (0)