Skip to content

Commit

Permalink
fix: re-fire tab change event
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed Aug 27, 2024
1 parent fd0e530 commit 89555a1
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions packages/core/src/core/diff-viewer/internal/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export class DiffViewerContribution implements ClientAppContribution, MenuContri
}

const editor = openResourceResult.group.codeEditor;
const index = openResourceResult.group.resources.indexOf(openResourceResult.resource);

if (oldContent === newContent) {
this.inlineDiffHandler.destroyPreviewer();
Expand Down Expand Up @@ -135,6 +136,16 @@ export class DiffViewerContribution implements ClientAppContribution, MenuContri
previewer.setValue(newContent);

await whenReady;
const diffInfo = this.getDiffInfoForUri(uri);
if (diffInfo) {
// 因为 onTabChange 时机早于应用上 diff 的时机,这里补发一个 onDidTabChange 事件
this._onDidTabChange.fire({
currentIndex: index,
diffNum: diffInfo.unresolved,
newPath: filePath,
});
}

previewer.layout();
previewer.revealFirstDiff();
};
Expand Down Expand Up @@ -226,9 +237,16 @@ export class DiffViewerContribution implements ClientAppContribution, MenuContri
total: 0,
toAddedLines: 0,
};
const resourceDiff = (this.inlineDiffHandler as any)._previewerNodeStore.get(uri.toString()) as
let resourceDiff = (this.inlineDiffHandler as any)._previewerNodeStore.get(uri.toString()) as
| InlineStreamDiffHandler
| null;
| undefined;

if (!resourceDiff) {
const previewer = this.inlineDiffHandler.getPreviewer() as LiveInlineDiffPreviewer;
if (previewer && previewer.isModel(uri.toString())) {
resourceDiff = previewer.getNode();
}
}

if (resourceDiff) {
const snapshot = resourceDiff.createSnapshot();
Expand Down

0 comments on commit 89555a1

Please sign in to comment.