From 14a3b463a5c91bc98fce84699929c77e06c3e1e4 Mon Sep 17 00:00:00 2001 From: Johannes Date: Tue, 16 May 2023 21:26:19 +0200 Subject: [PATCH] bring back finishing inline chat when typing outside of whole range --- .../browser/interactiveEditorController.ts | 17 +++++++++++++++-- .../browser/interactiveEditorSession.ts | 5 ++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorController.ts b/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorController.ts index c63d73daf522e..ab190cd2484a3 100644 --- a/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorController.ts +++ b/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorController.ts @@ -260,8 +260,21 @@ export class InteractiveEditorController implements IEditorContribution { })); this._sessionStore.add(this._editor.onDidChangeModelContent(e => { - if (!this._ignoreModelContentChanged) { - this._activeSession!.recordExternalEditOccurred(); + if (this._ignoreModelContentChanged) { + return; + } + + const wholeRange = this._activeSession!.wholeRange; + let editIsOutsideOfWholeRange = false; + for (const { range } of e.changes) { + editIsOutsideOfWholeRange = !Range.areIntersectingOrTouching(range, wholeRange); + } + + this._activeSession!.recordExternalEditOccurred(editIsOutsideOfWholeRange); + + if (editIsOutsideOfWholeRange) { + this._logService.trace('[IE] text changed outside of whole range, FINISH session'); + this._finishExistingSession(); } })); diff --git a/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorSession.ts b/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorSession.ts index a058908781183..29ad8ef93e390 100644 --- a/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorSession.ts +++ b/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorSession.ts @@ -37,6 +37,7 @@ type TelemetryData = { rounds: string; undos: string; edits: boolean; + finishedByEdit: boolean; startTime: string; endTime: string; editMode: string; @@ -49,6 +50,7 @@ type TelemetryDataClassification = { rounds: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Number of request that were made' }; undos: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Requests that have been undone' }; edits: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Did edits happen while the session was active' }; + finishedByEdit: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Did edits cause the session to terminate' }; startTime: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'When the session started' }; endTime: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'When the session ended' }; editMode: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'What edit mode was choosen: live, livePreview, preview' }; @@ -139,8 +141,9 @@ export class Session { return this.textModelN.getValueInRange(new Range(startLine, 1, endLine, Number.MAX_VALUE)); } - recordExternalEditOccurred() { + recordExternalEditOccurred(didFinish: boolean) { this._teldata.edits = true; + this._teldata.finishedByEdit = didFinish; } asTelemetryData(): TelemetryData {