From 5781eae35bd4c1abac9a5ec45a213f7baf7238f9 Mon Sep 17 00:00:00 2001 From: Remi Schnekenburger Date: Tue, 10 Dec 2024 11:39:49 +0100 Subject: [PATCH] Support property Text in DocumentDropOrPasteEditKind fixes #14603 contributed on behalf of STMicroelectronics Signed-off-by: Remi Schnekenburger --- packages/plugin-ext/src/plugin/types-impl.ts | 1 + .../plugin/src/theia.proposed.documentPaste.d.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/packages/plugin-ext/src/plugin/types-impl.ts b/packages/plugin-ext/src/plugin/types-impl.ts index 0e48a1c876e0a..cd03de9778494 100644 --- a/packages/plugin-ext/src/plugin/types-impl.ts +++ b/packages/plugin-ext/src/plugin/types-impl.ts @@ -1647,6 +1647,7 @@ export class DocumentLink { @es5ClassCompat export class DocumentDropOrPasteEditKind { static readonly Empty: DocumentDropOrPasteEditKind = new DocumentDropOrPasteEditKind(''); + static readonly Text: DocumentDropOrPasteEditKind = new DocumentDropOrPasteEditKind('text'); private static sep = '.'; diff --git a/packages/plugin/src/theia.proposed.documentPaste.d.ts b/packages/plugin/src/theia.proposed.documentPaste.d.ts index be606313530bb..c970e3bc07b9d 100644 --- a/packages/plugin/src/theia.proposed.documentPaste.d.ts +++ b/packages/plugin/src/theia.proposed.documentPaste.d.ts @@ -28,6 +28,20 @@ export module '@theia/plugin' { class DocumentDropOrPasteEditKind { static readonly Empty: DocumentDropOrPasteEditKind; + /** + * The root kind for basic text edits. + * + * This kind should be used for edits that insert basic text into the document. A good example of this is + * an edit that pastes the clipboard text while also updating imports in the file based on the pasted text. + * For this we could use a kind such as `text.updateImports.someLanguageId`. + * + * Even though most drop/paste edits ultimately insert text, you should not use {@linkcode Text} as the base kind + * for every edit as this is redundant. Instead a more specific kind that describes the type of content being + * inserted should be used instead For example, if the edit adds a Markdown link, use `markdown.link` since even + * though the content being inserted is text, it's more important to know that the edit inserts Markdown syntax. + */ + static readonly Text: DocumentDropOrPasteEditKind; + private constructor(value: string); /**