From 3da5591385edcc7410fd9163d943294814bac072 Mon Sep 17 00:00:00 2001 From: Makito Date: Tue, 3 Dec 2024 04:09:43 +0800 Subject: [PATCH] feat(completion): support detail from schema (#243) Co-authored-by: Martin Aeschlimann --- src/jsonSchema.ts | 1 + src/services/jsonCompletion.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/jsonSchema.ts b/src/jsonSchema.ts index 5640ba7c..adda0a30 100644 --- a/src/jsonSchema.ts +++ b/src/jsonSchema.ts @@ -85,6 +85,7 @@ export interface JSONSchema { suggestSortText?: string; // VSCode extension allowComments?: boolean; // VSCode extension allowTrailingCommas?: boolean; // VSCode extension + completionDetail?: string; // VSCode extension } export interface JSONSchemaMap { diff --git a/src/services/jsonCompletion.ts b/src/services/jsonCompletion.ts index fe42793f..dfe17b69 100644 --- a/src/services/jsonCompletion.ts +++ b/src/services/jsonCompletion.ts @@ -237,8 +237,11 @@ export class JSONCompletion { insertText: this.getInsertTextForProperty(key, propertySchema, addValue, separatorAfter), insertTextFormat: InsertTextFormat.Snippet, filterText: this.getFilterTextForValue(key), - documentation: this.fromMarkup(propertySchema.markdownDescription) || propertySchema.description || '', + documentation: this.fromMarkup(propertySchema.markdownDescription) || propertySchema.description || '' }; + if (propertySchema.completionDetail !== undefined) { + proposal.detail = propertySchema.completionDetail; + } if (propertySchema.suggestSortText !== undefined) { proposal.sortText = propertySchema.suggestSortText; } @@ -261,8 +264,11 @@ export class JSONCompletion { insertText: this.getInsertTextForProperty(name, undefined, addValue, separatorAfter), insertTextFormat: InsertTextFormat.Snippet, filterText: this.getFilterTextForValue(name), - documentation: enumDescription || this.fromMarkup(schemaPropertyNames.markdownDescription) || schemaPropertyNames.description || '', + documentation: enumDescription || this.fromMarkup(schemaPropertyNames.markdownDescription) || schemaPropertyNames.description || '' }; + if (schemaPropertyNames.completionDetail !== undefined) { + proposal.detail = schemaPropertyNames.completionDetail; + } if (schemaPropertyNames.suggestSortText !== undefined) { proposal.sortText = schemaPropertyNames.suggestSortText; }