Skip to content

Commit

Permalink
fix: minimize documentation indentation on hover
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Bricon <fbricon@gmail.com>
  • Loading branch information
fbricon committed Nov 28, 2023
1 parent 7cf2a4a commit 2d222d1
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/DocumentationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ export class DocumentationProvider {
if (!pom) {
return undefined;
}
const name = (pom?.project?.name)? pom?.project?.name : pom?.project?.artifactId;
const name = (pom?.project?.name)? pom.project.name : pom?.project?.artifactId;
let description = `**${name}**`;
if (pom?.project?.description) {
description += `\n\n${pom?.project?.description}`;
description += `\n\n`;
description += this.toMarkdown(pom?.project?.description);
}
const markdown = this.toMarkdown(description);
let doc:MarkdownString|undefined;
if (markdown) {
doc = new MarkdownString(markdown);
if (description) {
doc = new MarkdownString(description);
DOC_CACHE.set(gav, doc);
}
return doc;
Expand Down Expand Up @@ -103,7 +103,17 @@ export class DocumentationProvider {
if (!xml) {
return undefined;
}
return xml;
return this.minimizeIndentation(xml);
}

private minimizeIndentation(inputText: string): string {
//Need to minimize indentation, or else the doc looks like crap
//See https://github.com/stleary/JSON-java/blob/92991770ca9f5e12d687bd9f6147d10e8baedd2e/pom.xml#L10-L21

// Split the input text into lines
const lines = inputText.split('\n');
const result = lines.map(l => l.trim()).join('\n');
return result;
}
}

Expand Down

0 comments on commit 2d222d1

Please sign in to comment.