From a7d18433c56d6183ec4ed85e145bb8ea29c8a95e Mon Sep 17 00:00:00 2001 From: Aiday Marlen Kyzy Date: Thu, 20 Jul 2023 17:58:54 +0200 Subject: [PATCH] adding the code --- .../inlineChat/browser/inlineChatController.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts b/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts index a598d18cdf3..382bea3bed5 100644 --- a/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts +++ b/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts @@ -727,6 +727,10 @@ export class InlineChatController implements IEditorContribution { } } + private static isEditOrMarkdownResponse(response: EditResponse | MarkdownResponse | EmptyResponse | ErrorResponse | undefined): response is EditResponse | MarkdownResponse { + return response instanceof EditResponse || response instanceof MarkdownResponse; + } + // ---- controller API acceptInput(): void { @@ -783,7 +787,7 @@ export class InlineChatController implements IEditorContribution { } feedbackLast(helpful: boolean) { - if (this._activeSession?.lastExchange?.response instanceof EditResponse || this._activeSession?.lastExchange?.response instanceof MarkdownResponse) { + if (this._activeSession?.lastExchange && InlineChatController.isEditOrMarkdownResponse(this._activeSession.lastExchange.response)) { const kind = helpful ? InlineChatResponseFeedbackKind.Helpful : InlineChatResponseFeedbackKind.Unhelpful; this._activeSession.provider.handleInlineChatResponseFeedback?.(this._activeSession.session, this._activeSession.lastExchange.response.raw, kind); this._ctxLastFeedbackKind.set(helpful ? 'helpful' : 'unhelpful'); @@ -798,20 +802,16 @@ export class InlineChatController implements IEditorContribution { } acceptSession(): void { - if (this._activeSession?.asChangedText() && this._activeSession.lastExchange?.response instanceof EditResponse) { + if (this._activeSession?.lastExchange && InlineChatController.isEditOrMarkdownResponse(this._activeSession.lastExchange.response)) { this._activeSession.provider.handleInlineChatResponseFeedback?.(this._activeSession.session, this._activeSession.lastExchange.response.raw, InlineChatResponseFeedbackKind.Accepted); } this._messages.fire(Message.ACCEPT_SESSION); } cancelSession() { - let result: string | undefined; - if (this._activeSession) { - const changedText = this._activeSession.asChangedText(); - if (changedText && this._activeSession.lastExchange?.response instanceof EditResponse) { - this._activeSession.provider.handleInlineChatResponseFeedback?.(this._activeSession.session, this._activeSession.lastExchange.response.raw, InlineChatResponseFeedbackKind.Undone); - } - result = changedText; + const result = this._activeSession?.asChangedText(); + if (this._activeSession?.lastExchange && InlineChatController.isEditOrMarkdownResponse(this._activeSession.lastExchange.response)) { + this._activeSession.provider.handleInlineChatResponseFeedback?.(this._activeSession.session, this._activeSession.lastExchange.response.raw, InlineChatResponseFeedbackKind.Undone); } this._messages.fire(Message.CANCEL_SESSION); return result;