Skip to content

Commit 7e6672b

Browse files
authored
chat: fix various issues around chat pills (#252356)
We didn't preserve any ongoing `postEdit` changes when pushing a new undo stop, which caused issues. Closes #249829 Also fixes a bug where the diff stats weren't displayed at all, but I cannot seem to find the issue for that.
1 parent d9fc8d3 commit 7e6672b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,14 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
432432

433433
const lastEntry = newLinearHistory.at(-1);
434434
if (requestId && lastEntry?.requestId === requestId) {
435+
// mirror over the saved postEdit modifications
436+
if (lastEntry.postEdit && undoStop) {
437+
const rebaseUri = (uri: URI) => URI.parse(uri.toString().replaceAll(POST_EDIT_STOP_ID, undoStop));
438+
for (const [uri, prev] of lastEntry.postEdit.entries()) {
439+
snapshot.entries.set(uri, { ...prev, snapshotUri: rebaseUri(prev.snapshotUri), resource: rebaseUri(prev.resource) });
440+
}
441+
}
442+
435443
newLinearHistory[newLinearHistory.length - 1] = { ...lastEntry, stops: [...lastEntry.stops, snapshot], postEdit: undefined };
436444
} else {
437445
newLinearHistory.push({ requestId, startIndex: lastEntry ? lastEntry.startIndex + lastEntry.stops.length : 0, stops: [snapshot], postEdit: undefined });
@@ -452,7 +460,6 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
452460
}
453461

454462
private _createSnapshot(requestId: string | undefined, undoStop: string | undefined): IChatEditingSessionStop {
455-
456463
const entries = new ResourceMap<ISnapshotEntry>();
457464
for (const entry of this._entriesObs.get()) {
458465
entries.set(entry.modifiedURI, entry.createSnapshot(requestId, undoStop));

0 commit comments

Comments
 (0)