diff --git a/src/client/components/configuration/annotations.ts b/src/client/components/configuration/annotations.ts index cfcd1955b..490887d52 100644 --- a/src/client/components/configuration/annotations.ts +++ b/src/client/components/configuration/annotations.ts @@ -408,6 +408,13 @@ export class Annotations extends LitElement { if (this.annotations) { this.annotations.category = category || this.annotations.category this.requestUpdate() + + /** + * make VS Code display warn message to save document + */ + const ctx = getContext() + postClientMessage(ctx, ClientMessages.onCategoryChange, undefined) + return this.#dispatch({ 'runme.dev/uuid': this.annotations['runme.dev/uuid'], category: this.categories.join(CATEGORY_SEPARATOR), diff --git a/src/constants.ts b/src/constants.ts index 56cf40923..a7ca01979 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -22,6 +22,7 @@ export enum ClientMessages { setState = 'common:setState', getState = 'common:getState', onGetState = 'common:onGetState', + onCategoryChange = 'common:onCategoryChange', cloudApiRequest = 'common:cloudApiRequest', cloudApiResponse = 'common:cloudApiResponse', optionsMessage = 'common:optionsMessage', diff --git a/src/extension/kernel.ts b/src/extension/kernel.ts index 78da74bf2..e54924797 100644 --- a/src/extension/kernel.ts +++ b/src/extension/kernel.ts @@ -381,6 +381,13 @@ export class Kernel implements Disposable { return } await setNotebookCategories(this.context, cell.notebook.uri, new Set(message.output.value)) + } else if (message.type === ClientMessages.onCategoryChange) { + const btnSave = 'Save Now' + window.showWarningMessage('Save changes?', btnSave).then((val) => { + if (val === btnSave) { + commands.executeCommand('workbench.action.files.save') + } + }) } else if (message.type === ClientMessages.cloudApiRequest) { return handleCloudApiMessage({ messaging: this.messaging, diff --git a/src/types.ts b/src/types.ts index 48d676a2f..658126366 100644 --- a/src/types.ts +++ b/src/types.ts @@ -179,6 +179,7 @@ export interface ClientMessagePayload { answer: string | undefined uuid: string } + [ClientMessages.onCategoryChange]: void [ClientMessages.githubWorkflowDispatch]: { inputs: Record repo: string