Skip to content

Commit

Permalink
fix: re-fire tab change event (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain authored Aug 30, 2024
1 parent 474a317 commit 350b440
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 25 deletions.
3 changes: 1 addition & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"semver": "^7.3.2",
"send": "^0.17.1",
"signale": "^1.4.0",
"tslib": "^2.2.0",
"uuid": "^10.0.0"
"tslib": "^2.2.0"
},
"devDependencies": {
"@types/commander": "^2.12.2",
Expand Down
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
2 changes: 0 additions & 2 deletions packages/sumi-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@
"md5": "^2.3.0",
"mobx-react-lite": "^4.0.7",
"tslib": "^2.2.0",
"uuid": "^10.0.0",
"vscode-languageserver-types": "~3.14.0"
},
"devDependencies": {
"@types/fs-extra": "^9.0.4",
"@types/lodash.debounce": "^4.0.6",
"@types/md5": "^2.2.1",
"@types/uuid": "^10",
"vscode": "^1.1.37"
}
}
19 changes: 0 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,6 @@ __metadata:
send: "npm:^0.17.1"
signale: "npm:^1.4.0"
tslib: "npm:^2.2.0"
uuid: "npm:^10.0.0"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -815,7 +814,6 @@ __metadata:
"@types/fs-extra": "npm:^9.0.4"
"@types/lodash.debounce": "npm:^4.0.6"
"@types/md5": "npm:^2.2.1"
"@types/uuid": "npm:^10"
assert: "npm:^2.0.0"
fs-extra-factory: "npm:^0.2.1"
iconv-lite-umd: "npm:^0.6.8"
Expand All @@ -824,7 +822,6 @@ __metadata:
md5: "npm:^2.3.0"
mobx-react-lite: "npm:^4.0.7"
tslib: "npm:^2.2.0"
uuid: "npm:^10.0.0"
vscode: "npm:^1.1.37"
vscode-languageserver-types: "npm:~3.14.0"
languageName: unknown
Expand Down Expand Up @@ -2957,13 +2954,6 @@ __metadata:
languageName: node
linkType: hard

"@types/uuid@npm:^10":
version: 10.0.0
resolution: "@types/uuid@npm:10.0.0"
checksum: 10/e3958f8b0fe551c86c14431f5940c3470127293280830684154b91dc7eb3514aeb79fe3216968833cf79d4d1c67f580f054b5be2cd562bebf4f728913e73e944
languageName: node
linkType: hard

"@types/webpack-dev-server@npm:^3.11.1":
version: 3.11.6
resolution: "@types/webpack-dev-server@npm:3.11.6"
Expand Down Expand Up @@ -16329,15 +16319,6 @@ __metadata:
languageName: node
linkType: hard

"uuid@npm:^10.0.0":
version: 10.0.0
resolution: "uuid@npm:10.0.0"
bin:
uuid: dist/bin/uuid
checksum: 10/35aa60614811a201ff90f8ca5e9ecb7076a75c3821e17f0f5ff72d44e36c2d35fcbc2ceee9c4ac7317f4cc41895da30e74f3885e30313bee48fda6338f250538
languageName: node
linkType: hard

"uuid@npm:^3.3.2":
version: 3.4.0
resolution: "uuid@npm:3.4.0"
Expand Down

0 comments on commit 350b440

Please sign in to comment.