Skip to content

Commit

Permalink
fix: hover content indentation issue
Browse files Browse the repository at this point in the history
From a previous change, when creating a hover
indentations were replaced with the html entity
non breaking space.

The issue is that the indentation property
is optional and this was not considered in that
change. Due to this the markdown content would
be incorrect.

This change performs the markdown content modification
only when the expected parameters exist.

Signed-off-by: Nikolas Komonen <nkomonen@amazon.com>
  • Loading branch information
nkomonen-amazon committed Mar 13, 2023
1 parent 5f50107 commit 86d0fc5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/languageservice/services/yamlHover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,14 @@ export class YAMLHover {
);

const createHover = (contents: string): Hover => {
const regex = new RegExp(this.indentation, 'g');
if (this.indentation !== undefined) {
const indentationMatchRegex = new RegExp(this.indentation, 'g');
contents = contents.replace(indentationMatchRegex, '&emsp;');
}

const markupContent: MarkupContent = {
kind: MarkupKind.Markdown,
value: contents.replace(regex, '&emsp;'),
value: contents,
};
const result: Hover = {
contents: markupContent,
Expand Down

0 comments on commit 86d0fc5

Please sign in to comment.