Skip to content

Commit 2ffdbd3

Browse files
authored
chore - reduce dependency on IModifiedFileEntry#originalModel (#240500)
1 parent f94b270 commit 2ffdbd3

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorController.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { AccessibilitySignal, IAccessibilitySignalService } from '../../../../..
4242
import { TextEditorSelectionRevealType } from '../../../../../platform/editor/common/editor.js';
4343
import { AccessibleDiffViewer, IAccessibleDiffViewerModel } from '../../../../../editor/browser/widget/diffEditor/components/accessibleDiffViewer.js';
4444
import { LineRange } from '../../../../../editor/common/core/lineRange.js';
45+
import { IModelService } from '../../../../../editor/common/services/model.js';
4546

4647
export const ctxIsGlobalEditingSession = new RawContextKey<boolean>('chat.isGlobalEditingSession', undefined, localize('chat.ctxEditSessionIsGlobal', "The current editor is part of the global edit session"));
4748
export const ctxHasEditorModification = new RawContextKey<boolean>('chat.hasEditorModifications', undefined, localize('chat.hasEditorModifications', "The current editor contains chat modifications"));
@@ -318,7 +319,7 @@ export class ChatEditorController extends Disposable implements IEditorContribut
318319
editorObs.layoutInfo.map((v, r) => v.width),
319320
editorObs.layoutInfo.map((v, r) => v.height),
320321
entry.diffInfo.map(diff => diff.changes.slice()),
321-
new AccessibleDiffViewerModel(entry, _editor),
322+
_instantiationService.createInstance(AccessibleDiffViewerModel, entry, _editor),
322323
));
323324
}));
324325
}
@@ -883,10 +884,14 @@ class AccessibleDiffViewContainer implements IOverlayWidget {
883884
}
884885

885886
class AccessibleDiffViewerModel implements IAccessibleDiffViewerModel {
886-
constructor(private readonly entry: IModifiedFileEntry, private readonly _editor: ICodeEditor) { }
887+
constructor(
888+
private readonly entry: IModifiedFileEntry,
889+
private readonly _editor: ICodeEditor,
890+
@IModelService private readonly _modelService: IModelService,
891+
) { }
887892

888893
getOriginalModel() {
889-
return this.entry?.originalModel;
894+
return this._modelService.getModel(this.entry.originalURI)!;
890895
}
891896

892897
getOriginalOptions() {

src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -575,13 +575,6 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
575575
this._onDidDispose.dispose();
576576
}
577577

578-
getVirtualModel(documentId: string): ITextModel | null {
579-
this._assertNotDisposed();
580-
581-
const entry = this._entriesObs.get().find(e => e.entryId === documentId);
582-
return entry?.originalModel ?? null;
583-
}
584-
585578
acceptStreamingEditsStart(): void {
586579
if (this._state.get() === ChatEditingSessionState.Disposed) {
587580
// we don't throw in this case because there could be a builder still connected to a disposed session

src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ export class ChatEditingTextModelContentProvider implements ITextModelContentPro
3838

3939
const session = this._chatEditingService.getEditingSession(data.chatSessionId);
4040

41-
if (!(session instanceof ChatEditingSession)) {
41+
const entry = session?.entries.get().find(candidate => candidate.entryId === data.documentId);
42+
if (!entry) {
4243
return null;
4344
}
4445

45-
return session.getVirtualModel(data.documentId);
46+
return this._modelService.getModel(entry.originalURI);
4647
}
4748
}
4849

0 commit comments

Comments
 (0)