Skip to content

Commit 9fadd3a

Browse files
sync expandAll status
1 parent 54c5c75 commit 9fadd3a

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

packages/core/src/diff-file.ts

+26-8
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ export class DiffFile {
139139

140140
#_theme?: "light" | "dark";
141141

142+
#hasExpandSplitAll = { state: false };
143+
144+
#hasExpandUnifiedAll = { state: false };
145+
142146
_version_ = __VERSION__;
143147

144148
_oldFileName: string = "";
@@ -167,9 +171,9 @@ export class DiffFile {
167171

168172
deletionLength: number = 0;
169173

170-
hasExpandSplitAll: boolean = false;
174+
// hasExpandSplitAll: boolean = false;
171175

172-
hasExpandUnifiedAll: boolean = false;
176+
// hasExpandUnifiedAll: boolean = false;
173177

174178
hasSomeLineCollapsed: boolean = false;
175179

@@ -1194,17 +1198,25 @@ export class DiffFile {
11941198
Object.keys(this.#splitHunksLines || {}).forEach((key) => {
11951199
this.onSplitHunkExpand("all", +key, false);
11961200
});
1197-
this.hasExpandSplitAll = true;
1201+
this.#hasExpandSplitAll.state = true;
11981202
} else {
11991203
Object.keys(this.#unifiedHunksLines || {}).forEach((key) => {
12001204
this.onUnifiedHunkExpand("all", +key, false);
12011205
});
1202-
this.hasExpandUnifiedAll = true;
1206+
this.#hasExpandUnifiedAll.state = true;
12031207
}
12041208

12051209
this.notifyAll();
12061210
};
12071211

1212+
getHasExpandSplitAll() {
1213+
return this.#hasExpandSplitAll.state;
1214+
}
1215+
1216+
getHasExpandUnifiedAll() {
1217+
return this.#hasExpandUnifiedAll.state;
1218+
}
1219+
12081220
onAllCollapse = (mode: "split" | "unified") => {
12091221
if (this.#composeByDiff) return;
12101222

@@ -1241,7 +1253,7 @@ export class DiffFile {
12411253
this.#splitHunksLines![item.splitInfo.endHiddenIndex] = item;
12421254
}
12431255
});
1244-
this.hasExpandSplitAll = false;
1256+
this.#hasExpandSplitAll.state = false;
12451257
} else {
12461258
Object.values(this.#unifiedLines || {}).forEach((item) => {
12471259
if (!item.isHidden && item._isHidden) {
@@ -1270,19 +1282,19 @@ export class DiffFile {
12701282
this.#unifiedHunksLines![item.unifiedInfo.endHiddenIndex] = item;
12711283
}
12721284
});
1273-
this.hasExpandUnifiedAll = false;
1285+
this.#hasExpandUnifiedAll.state = false;
12741286
}
12751287

12761288
this.notifyAll();
12771289
};
12781290

12791291
getOldFileContent = () => {
12801292
return this.#oldFileResult?.raw;
1281-
}
1293+
};
12821294

12831295
getNewFileContent = () => {
12841296
return this.#newFileResult?.raw;
1285-
}
1297+
};
12861298

12871299
getOldSyntaxLine = (lineNumber: number) => {
12881300
return this.#oldFileSyntaxLines?.[lineNumber];
@@ -1343,6 +1355,8 @@ export class DiffFile {
13431355
const highlighterName = this.#highlighterName;
13441356
const highlighterType = this.#highlighterType;
13451357
const hasSomeLineCollapsed = this.hasSomeLineCollapsed;
1358+
const hasExpandSplitAll = this.#hasExpandSplitAll;
1359+
const hasExpandUnifiedAll = this.#hasExpandUnifiedAll;
13461360

13471361
// split
13481362
const splitLeftLines = this.#splitLeftLines;
@@ -1384,6 +1398,8 @@ export class DiffFile {
13841398
highlighterType,
13851399
composeByDiff,
13861400
hasSomeLineCollapsed,
1401+
hasExpandSplitAll,
1402+
hasExpandUnifiedAll,
13871403

13881404
version,
13891405

@@ -1416,6 +1432,8 @@ export class DiffFile {
14161432
this.additionLength = data.additionLength;
14171433
this.deletionLength = data.deletionLength;
14181434
this.hasSomeLineCollapsed = data.hasSomeLineCollapsed;
1435+
this.#hasExpandSplitAll = data.hasExpandSplitAll;
1436+
this.#hasExpandUnifiedAll = data.hasExpandUnifiedAll;
14191437

14201438
this.#splitLeftLines = data.splitLeftLines;
14211439
this.#splitRightLines = data.splitRightLines;

0 commit comments

Comments
 (0)