@@ -12,7 +12,7 @@ import { setKubernetesParserOption } from '../parser/isKubernetes';
12
12
import { TextDocument } from 'vscode-languageserver-textdocument' ;
13
13
import { yamlDocumentsCache } from '../parser/yaml-documents' ;
14
14
import { SingleYAMLDocument } from '../parser/yamlParser07' ;
15
- import { IApplicableSchema } from '../parser/jsonParser07' ;
15
+ import { getNodeValue , IApplicableSchema } from '../parser/jsonParser07' ;
16
16
import { JSONSchema } from '../jsonSchema' ;
17
17
import { URI } from 'vscode-uri' ;
18
18
import * as path from 'path' ;
@@ -114,14 +114,17 @@ export class YAMLHover {
114
114
let markdownEnumDescriptions : string [ ] = [ ] ;
115
115
const markdownExamples : string [ ] = [ ] ;
116
116
const markdownEnums : markdownEnum [ ] = [ ] ;
117
-
117
+ let enumIdx : number | undefined = undefined ;
118
118
matchingSchemas . every ( ( s ) => {
119
119
if ( ( s . node === node || ( node . type === 'property' && node . valueNode === s . node ) ) && ! s . inverted && s . schema ) {
120
120
title = title || s . schema . title || s . schema . closestTitle ;
121
121
markdownDescription = markdownDescription || s . schema . markdownDescription || this . toMarkdown ( s . schema . description ) ;
122
122
if ( s . schema . enum ) {
123
+ enumIdx = s . schema . enum . indexOf ( getNodeValue ( node ) ) ;
123
124
if ( s . schema . markdownEnumDescriptions ) {
124
125
markdownEnumDescriptions = s . schema . markdownEnumDescriptions ;
126
+ } else if ( s . schema . enumMarkdown ) {
127
+ markdownEnumDescriptions = s . schema . enumMarkdown ;
125
128
} else if ( s . schema . enumDescriptions ) {
126
129
markdownEnumDescriptions = s . schema . enumDescriptions . map ( this . toMarkdown , this ) ;
127
130
} else {
@@ -174,6 +177,9 @@ export class YAMLHover {
174
177
if ( markdownEnums . length !== 0 ) {
175
178
result = ensureLineBreak ( result ) ;
176
179
result += 'Allowed Values:\n\n' ;
180
+ if ( enumIdx ) {
181
+ markdownEnums . unshift ( markdownEnums . splice ( enumIdx , 1 ) [ 0 ] ) ;
182
+ }
177
183
markdownEnums . forEach ( ( me ) => {
178
184
if ( me . description ) {
179
185
result += `* \`${ toMarkdownCodeBlock ( me . value ) } \`: ${ me . description } \n` ;
0 commit comments