Skip to content

Commit cf44701

Browse files
fix
1 parent 43432c4 commit cf44701

6 files changed

Lines changed: 24 additions & 8 deletions

File tree

packages/core/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ export declare class DiffFile {
192192
highlighterName: string;
193193
highlighterType: string;
194194
composeByDiff: boolean;
195+
composeByRange: boolean;
195196
hasSomeLineCollapsed: boolean;
196197
hasExpandSplitAll: {
197198
state: boolean;
@@ -263,6 +264,7 @@ export declare class DiffFile {
263264
highlighterName: string;
264265
highlighterType: string;
265266
composeByDiff: boolean;
267+
composeByRange: boolean;
266268
hasSomeLineCollapsed: boolean;
267269
hasExpandSplitAll: {
268270
state: boolean;

packages/core/src/diff-file.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ export class DiffFile {
126126

127127
#composeByDiff: boolean = false;
128128

129+
#composeByRange: boolean = false;
130+
129131
#composeByMerge: boolean = false;
130132

131133
#composeByFullMerge: boolean = false;
@@ -1169,10 +1171,11 @@ export class DiffFile {
11691171
};
11701172

11711173
onSplitHunkExpand = (dir: "up" | "down" | "all" | "up-all" | "down-all", index: number, needTrigger = true) => {
1174+
if (this.getExpandEnabled()) return;
1175+
11721176
const current = this.#splitHunksLines?.[index];
1173-
if (!current || !current.splitInfo) return;
11741177

1175-
if (this.#composeByDiff) return;
1178+
if (!current || !current.splitInfo) return;
11761179

11771180
if (dir === "all") {
11781181
for (let i = current.splitInfo.startHiddenIndex; i < current.splitInfo.endHiddenIndex; i++) {
@@ -1303,7 +1306,7 @@ export class DiffFile {
13031306

13041307
// TODO! support rollback?
13051308
onUnifiedHunkExpand = (dir: "up" | "down" | "all" | "up-all" | "down-all", index: number, needTrigger = true) => {
1306-
if (this.#composeByDiff) return;
1309+
if (this.getExpandEnabled()) return;
13071310

13081311
const current = this.#unifiedHunksLines?.[index];
13091312

@@ -1405,7 +1408,7 @@ export class DiffFile {
14051408
};
14061409

14071410
onAllExpand = (mode: "split" | "unified") => {
1408-
if (this.#composeByDiff) return;
1411+
if (this.getExpandEnabled()) return;
14091412

14101413
if (mode === "split") {
14111414
Object.keys(this.#splitHunksLines || {}).forEach((key) => {
@@ -1431,7 +1434,7 @@ export class DiffFile {
14311434
}
14321435

14331436
onAllCollapse = (mode: "split" | "unified") => {
1434-
if (this.#composeByDiff) return;
1437+
if (this.getExpandEnabled()) return;
14351438

14361439
if (mode === "split") {
14371440
Object.values(this.#splitLeftLines || {}).forEach((item) => {
@@ -1552,7 +1555,7 @@ export class DiffFile {
15521555

15531556
getUpdateCount = () => this.#updateCount;
15541557

1555-
getExpandEnabled = () => !this.#composeByDiff;
1558+
getExpandEnabled = () => !this.#composeByDiff && !this.#composeByRange;
15561559

15571560
getBundle = () => {
15581561
// common
@@ -1576,6 +1579,7 @@ export class DiffFile {
15761579
const additionLength = this.additionLength;
15771580
const deletionLength = this.deletionLength;
15781581
const composeByDiff = this.#composeByDiff;
1582+
const composeByRange = this.#composeByRange;
15791583
const highlighterName = this.#highlighterName;
15801584
const highlighterType = this.#highlighterType;
15811585
const hasSomeLineCollapsed = this.hasSomeLineCollapsed;
@@ -1623,6 +1627,7 @@ export class DiffFile {
16231627
highlighterName,
16241628
highlighterType,
16251629
composeByDiff,
1630+
composeByRange,
16261631
hasSomeLineCollapsed,
16271632
hasExpandSplitAll,
16281633
hasExpandUnifiedAll,
@@ -1641,6 +1646,7 @@ export class DiffFile {
16411646
this.#hasBuildSplit = data.hasBuildSplit;
16421647
this.#hasBuildUnified = data.hasBuildUnified;
16431648
this.#composeByDiff = data.composeByDiff;
1649+
this.#composeByRange = data.composeByRange;
16441650
this.#highlighterName = data.highlighterName;
16451651
this.#highlighterType = data.highlighterType;
16461652

@@ -1741,8 +1747,8 @@ export class DiffFile {
17411747
const contextDiffFile = DiffFile.createInstance(
17421748
{},
17431749
{
1744-
...this.getBundle(),
1745-
composeByDiff: true,
1750+
...this._getFullBundle(),
1751+
composeByRange: true,
17461752
splitHunkLines: {},
17471753
splitLeftLines: l,
17481754
splitRightLines: r,

packages/file/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export declare class DiffFile {
190190
highlighterName: string;
191191
highlighterType: string;
192192
composeByDiff: boolean;
193+
composeByRange: boolean;
193194
hasSomeLineCollapsed: boolean;
194195
hasExpandSplitAll: {
195196
state: boolean;
@@ -261,6 +262,7 @@ export declare class DiffFile {
261262
highlighterName: string;
262263
highlighterType: string;
263264
composeByDiff: boolean;
265+
composeByRange: boolean;
264266
hasSomeLineCollapsed: boolean;
265267
hasExpandSplitAll: {
266268
state: boolean;

packages/react/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export declare class DiffFile {
190190
highlighterName: string;
191191
highlighterType: string;
192192
composeByDiff: boolean;
193+
composeByRange: boolean;
193194
hasSomeLineCollapsed: boolean;
194195
hasExpandSplitAll: {
195196
state: boolean;
@@ -261,6 +262,7 @@ export declare class DiffFile {
261262
highlighterName: string;
262263
highlighterType: string;
263264
composeByDiff: boolean;
265+
composeByRange: boolean;
264266
hasSomeLineCollapsed: boolean;
265267
hasExpandSplitAll: {
266268
state: boolean;

packages/solid/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export declare class DiffFile {
190190
highlighterName: string;
191191
highlighterType: string;
192192
composeByDiff: boolean;
193+
composeByRange: boolean;
193194
hasSomeLineCollapsed: boolean;
194195
hasExpandSplitAll: {
195196
state: boolean;
@@ -261,6 +262,7 @@ export declare class DiffFile {
261262
highlighterName: string;
262263
highlighterType: string;
263264
composeByDiff: boolean;
265+
composeByRange: boolean;
264266
hasSomeLineCollapsed: boolean;
265267
hasExpandSplitAll: {
266268
state: boolean;

packages/vue/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export declare class DiffFile {
190190
highlighterName: string;
191191
highlighterType: string;
192192
composeByDiff: boolean;
193+
composeByRange: boolean;
193194
hasSomeLineCollapsed: boolean;
194195
hasExpandSplitAll: {
195196
state: boolean;
@@ -261,6 +262,7 @@ export declare class DiffFile {
261262
highlighterName: string;
262263
highlighterType: string;
263264
composeByDiff: boolean;
265+
composeByRange: boolean;
264266
hasSomeLineCollapsed: boolean;
265267
hasExpandSplitAll: {
266268
state: boolean;

0 commit comments

Comments
 (0)