@@ -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,19 @@ 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+ plainText : "" ,
1210+ startHiddenIndex : current . splitInfo . endHiddenIndex ,
1211+ } ;
1212+ } else if ( dir === "up" ) {
12011213 if ( current . isLast ) {
12021214 if ( __DEV__ ) {
12031215 console . error ( "the last hunk can not expand up!" ) ;
@@ -1226,6 +1238,28 @@ export class DiffFile {
12261238
12271239 delete this . #splitHunksLines?. [ index ] ;
12281240
1241+ this . #splitHunksLines! [ current . splitInfo . endHiddenIndex ] = current ;
1242+ } else if ( dir === "up-all" ) {
1243+ if ( current . isLast ) {
1244+ if ( __DEV__ ) {
1245+ console . error ( "the last hunk can not expand up!" ) ;
1246+ }
1247+ return ;
1248+ }
1249+ for ( let i = current . splitInfo . startHiddenIndex ; i < current . splitInfo . endHiddenIndex ; i ++ ) {
1250+ const leftLine = this . #splitLeftLines[ i ] ;
1251+ const rightLine = this . #splitRightLines[ i ] ;
1252+ if ( leftLine ?. isHidden ) leftLine . isHidden = false ;
1253+ if ( rightLine ?. isHidden ) rightLine . isHidden = false ;
1254+ }
1255+ current . splitInfo = {
1256+ ...current . splitInfo ,
1257+ plainText : "" ,
1258+ endHiddenIndex : current . splitInfo . startHiddenIndex ,
1259+ } ;
1260+
1261+ delete this . #splitHunksLines?. [ index ] ;
1262+
12291263 this . #splitHunksLines! [ current . splitInfo . endHiddenIndex ] = current ;
12301264 }
12311265
@@ -1259,7 +1293,7 @@ export class DiffFile {
12591293 } ;
12601294
12611295 // TODO! support rollback?
1262- onUnifiedHunkExpand = ( dir : "up" | "down" | "all" , index : number , needTrigger = true ) => {
1296+ onUnifiedHunkExpand = ( dir : "up" | "down" | "all" | "up-all" | "down-all" , index : number , needTrigger = true ) => {
12631297 if ( this . #composeByDiff) return ;
12641298
12651299 const current = this . #unifiedHunksLines?. [ index ] ;
@@ -1296,7 +1330,17 @@ export class DiffFile {
12961330 plainText : `@@ -${ current . unifiedInfo . oldStartIndex } ,${ current . unifiedInfo . oldLength } +${ current . unifiedInfo . newStartIndex } ,${ current . unifiedInfo . newLength } ` ,
12971331 } ;
12981332 }
1299- } else {
1333+ } else if ( dir === "down-all" ) {
1334+ for ( let i = current . unifiedInfo . startHiddenIndex ; i < current . unifiedInfo . endHiddenIndex ; i ++ ) {
1335+ const unifiedLine = this . #unifiedLines[ i ] ;
1336+ if ( unifiedLine ?. isHidden ) unifiedLine . isHidden = false ;
1337+ }
1338+ current . unifiedInfo = {
1339+ ...current . unifiedInfo ,
1340+ plainText : "" ,
1341+ startHiddenIndex : current . unifiedInfo . endHiddenIndex ,
1342+ } ;
1343+ } else if ( dir === "up" ) {
13001344 if ( current . isLast ) {
13011345 if ( __DEV__ ) {
13021346 console . error ( "the last hunk can not expand up!" ) ;
@@ -1323,6 +1367,26 @@ export class DiffFile {
13231367
13241368 delete this . #unifiedHunksLines?. [ index ] ;
13251369
1370+ this . #unifiedHunksLines! [ current . unifiedInfo . endHiddenIndex ] = current ;
1371+ } else if ( dir === "up-all" ) {
1372+ if ( current . isLast ) {
1373+ if ( __DEV__ ) {
1374+ console . error ( "the last hunk can not expand up!" ) ;
1375+ }
1376+ return ;
1377+ }
1378+ for ( let i = current . unifiedInfo . startHiddenIndex ; i < current . unifiedInfo . endHiddenIndex ; i ++ ) {
1379+ const unifiedLine = this . #unifiedLines[ i ] ;
1380+ if ( unifiedLine ?. isHidden ) unifiedLine . isHidden = false ;
1381+ }
1382+ current . unifiedInfo = {
1383+ ...current . unifiedInfo ,
1384+ plainText : "" ,
1385+ endHiddenIndex : current . unifiedInfo . startHiddenIndex ,
1386+ } ;
1387+
1388+ delete this . #unifiedHunksLines?. [ index ] ;
1389+
13261390 this . #unifiedHunksLines! [ current . unifiedInfo . endHiddenIndex ] = current ;
13271391 }
13281392
0 commit comments