@@ -1159,7 +1159,7 @@ export class DiffFile {
11591159 return this . #splitHunksLines?. [ index ] ;
11601160 } ;
11611161
1162- onSplitHunkExpand = ( dir : "up" | "down" | "all" , index : number , needTrigger = true ) => {
1162+ onSplitHunkExpand = ( dir : "up" | "down" | "all" | "up-all" | "down-all" , index : number , needTrigger = true ) => {
11631163 const current = this . #splitHunksLines?. [ index ] ;
11641164 if ( ! current || ! current . splitInfo ) return ;
11651165
@@ -1197,7 +1197,18 @@ export class DiffFile {
11971197 plainText : `@@ -${ current . splitInfo . oldStartIndex } ,${ current . splitInfo . oldLength } +${ current . splitInfo . newStartIndex } ,${ current . splitInfo . newLength } ` ,
11981198 } ;
11991199 }
1200- } else {
1200+ } else if ( dir === "down-all" ) {
1201+ for ( let i = current . splitInfo . startHiddenIndex ; i < current . splitInfo . endHiddenIndex ; i ++ ) {
1202+ const leftLine = this . #splitLeftLines[ i ] ;
1203+ const rightLine = this . #splitRightLines[ i ] ;
1204+ if ( leftLine ?. isHidden ) leftLine . isHidden = false ;
1205+ if ( rightLine ?. isHidden ) rightLine . isHidden = false ;
1206+ }
1207+ current . splitInfo = {
1208+ ...current . splitInfo ,
1209+ startHiddenIndex : current . splitInfo . endHiddenIndex ,
1210+ } ;
1211+ } else if ( dir === "up" ) {
12011212 if ( current . isLast ) {
12021213 if ( __DEV__ ) {
12031214 console . error ( "the last hunk can not expand up!" ) ;
@@ -1226,6 +1237,27 @@ export class DiffFile {
12261237
12271238 delete this . #splitHunksLines?. [ index ] ;
12281239
1240+ this . #splitHunksLines! [ current . splitInfo . endHiddenIndex ] = current ;
1241+ } else if ( dir === "up-all" ) {
1242+ if ( current . isLast ) {
1243+ if ( __DEV__ ) {
1244+ console . error ( "the last hunk can not expand up!" ) ;
1245+ }
1246+ return ;
1247+ }
1248+ for ( let i = current . splitInfo . startHiddenIndex ; i < current . splitInfo . endHiddenIndex ; i ++ ) {
1249+ const leftLine = this . #splitLeftLines[ i ] ;
1250+ const rightLine = this . #splitRightLines[ i ] ;
1251+ if ( leftLine ?. isHidden ) leftLine . isHidden = false ;
1252+ if ( rightLine ?. isHidden ) rightLine . isHidden = false ;
1253+ }
1254+ current . splitInfo = {
1255+ ...current . splitInfo ,
1256+ endHiddenIndex : current . splitInfo . startHiddenIndex ,
1257+ } ;
1258+
1259+ delete this . #splitHunksLines?. [ index ] ;
1260+
12291261 this . #splitHunksLines! [ current . splitInfo . endHiddenIndex ] = current ;
12301262 }
12311263
@@ -1259,7 +1291,7 @@ export class DiffFile {
12591291 } ;
12601292
12611293 // TODO! support rollback?
1262- onUnifiedHunkExpand = ( dir : "up" | "down" | "all" , index : number , needTrigger = true ) => {
1294+ onUnifiedHunkExpand = ( dir : "up" | "down" | "all" | "up-all" | "down-all" , index : number , needTrigger = true ) => {
12631295 if ( this . #composeByDiff) return ;
12641296
12651297 const current = this . #unifiedHunksLines?. [ index ] ;
@@ -1296,7 +1328,16 @@ export class DiffFile {
12961328 plainText : `@@ -${ current . unifiedInfo . oldStartIndex } ,${ current . unifiedInfo . oldLength } +${ current . unifiedInfo . newStartIndex } ,${ current . unifiedInfo . newLength } ` ,
12971329 } ;
12981330 }
1299- } else {
1331+ } else if ( dir === "down-all" ) {
1332+ for ( let i = current . unifiedInfo . startHiddenIndex ; i < current . unifiedInfo . endHiddenIndex ; i ++ ) {
1333+ const unifiedLine = this . #unifiedLines[ i ] ;
1334+ if ( unifiedLine ?. isHidden ) unifiedLine . isHidden = false ;
1335+ }
1336+ current . unifiedInfo = {
1337+ ...current . unifiedInfo ,
1338+ startHiddenIndex : current . unifiedInfo . endHiddenIndex ,
1339+ } ;
1340+ } else if ( dir === "up" ) {
13001341 if ( current . isLast ) {
13011342 if ( __DEV__ ) {
13021343 console . error ( "the last hunk can not expand up!" ) ;
@@ -1323,6 +1364,25 @@ export class DiffFile {
13231364
13241365 delete this . #unifiedHunksLines?. [ index ] ;
13251366
1367+ this . #unifiedHunksLines! [ current . unifiedInfo . endHiddenIndex ] = current ;
1368+ } else if ( dir === "up-all" ) {
1369+ if ( current . isLast ) {
1370+ if ( __DEV__ ) {
1371+ console . error ( "the last hunk can not expand up!" ) ;
1372+ }
1373+ return ;
1374+ }
1375+ for ( let i = current . unifiedInfo . startHiddenIndex ; i < current . unifiedInfo . endHiddenIndex ; i ++ ) {
1376+ const unifiedLine = this . #unifiedLines[ i ] ;
1377+ if ( unifiedLine ?. isHidden ) unifiedLine . isHidden = false ;
1378+ }
1379+ current . unifiedInfo = {
1380+ ...current . unifiedInfo ,
1381+ endHiddenIndex : current . unifiedInfo . startHiddenIndex ,
1382+ } ;
1383+
1384+ delete this . #unifiedHunksLines?. [ index ] ;
1385+
13261386 this . #unifiedHunksLines! [ current . unifiedInfo . endHiddenIndex ] = current ;
13271387 }
13281388
0 commit comments