@@ -146,6 +146,7 @@ export class GitTreeCompareProvider implements TreeDataProvider<Element>, Dispos
146146 private repository : Repository | undefined ;
147147 private baseRef : string ;
148148 private viewAsList = false ;
149+ private hideCheckedFiles = false ;
149150 private searchFilter : string | undefined ;
150151
151152 // Static state of repository
@@ -368,6 +369,9 @@ export class GitTreeCompareProvider implements TreeDataProvider<Element>, Dispos
368369 } ) ;
369370 }
370371 }
372+ if ( this . hideCheckedFiles ) {
373+ this . _onDidChangeTreeData . fire ( ) ;
374+ }
371375 }
372376
373377 private handleActiveEditorChange ( editor : TextEditor | undefined ) {
@@ -889,6 +893,10 @@ export class GitTreeCompareProvider implements TreeDataProvider<Element>, Dispos
889893 const oldSortOrder = this . sortOrder ;
890894 const oldShowDiffStats = this . showDiffStats ;
891895 this . readConfig ( ) ;
896+ if ( oldshowCheckboxes && ! this . showCheckboxes && this . hideCheckedFiles ) {
897+ this . hideCheckedFiles = false ;
898+ commands . executeCommand ( 'setContext' , NAMESPACE + '.hideCheckedFiles' , false ) ;
899+ }
892900 if ( oldTreeRootIsRepo != this . treeRootIsRepo ||
893901 oldInclude != this . includeFilesOutsideWorkspaceFolderRoot ||
894902 oldOpenChangesOnSelect != this . openChangesOnSelect ||
@@ -950,8 +958,24 @@ export class GitTreeCompareProvider implements TreeDataProvider<Element>, Dispos
950958 relativePath . toLowerCase ( ) . includes ( searchLower ) ;
951959 }
952960
961+ private isFileCheckboxChecked ( dstAbsPath : string ) : boolean {
962+ const stateInfo = this . checkboxStates . get ( dstAbsPath ) ;
963+ return stateInfo ?. state === TreeItemCheckboxState . Checked ;
964+ }
965+
966+ /** Whether this file row should appear in the tree (search + optional hide-checked). */
967+ private fileVisibleInTree ( dstAbsPath : string , relPathBase : string ) : boolean {
968+ if ( ! this . matchesFilter ( dstAbsPath , relPathBase ) ) {
969+ return false ;
970+ }
971+ if ( this . hideCheckedFiles && this . isFileCheckboxChecked ( dstAbsPath ) ) {
972+ return false ;
973+ }
974+ return true ;
975+ }
976+
953977 private folderHasMatchingFiles ( folder : string , useFilesOutsideTreeRoot : boolean ) : boolean {
954- if ( ! this . searchFilter ) {
978+ if ( ! this . searchFilter && ! this . hideCheckedFiles ) {
955979 return true ;
956980 }
957981 const files = useFilesOutsideTreeRoot ? this . filesOutsideTreeRoot : this . filesInsideTreeRoot ;
@@ -960,7 +984,7 @@ export class GitTreeCompareProvider implements TreeDataProvider<Element>, Dispos
960984 for ( const [ folderPath , fileEntries ] of files . entries ( ) ) {
961985 if ( folderPath === folder || folderPath . startsWith ( folder + path . sep ) ) {
962986 for ( const file of fileEntries ) {
963- if ( this . matchesFilter ( file . dstAbsPath , relPathBase ) ) {
987+ if ( this . fileVisibleInTree ( file . dstAbsPath , relPathBase ) ) {
964988 return true ;
965989 }
966990 }
@@ -987,7 +1011,7 @@ export class GitTreeCompareProvider implements TreeDataProvider<Element>, Dispos
9871011 for ( const folder2 of folders ) {
9881012 const fileEntries = files . get ( folder2 ) ! ;
9891013 for ( const file of fileEntries ) {
990- if ( this . matchesFilter ( file . dstAbsPath , relPathBase ) ) {
1014+ if ( this . fileVisibleInTree ( file . dstAbsPath , relPathBase ) ) {
9911015 const dstRelPath = path . relative ( relPathBase , file . dstAbsPath ) ;
9921016 entries . push ( new FileElement ( file . srcAbsPath , file . dstAbsPath , dstRelPath , file . status , file . isSubmodule , file . stats ) ) ;
9931017 }
@@ -1050,7 +1074,7 @@ export class GitTreeCompareProvider implements TreeDataProvider<Element>, Dispos
10501074 // there are no files within treeRoot, therefore, this is guarded
10511075 if ( fileEntries ) {
10521076 for ( const file of fileEntries ) {
1053- if ( this . matchesFilter ( file . dstAbsPath , relPathBase ) ) {
1077+ if ( this . fileVisibleInTree ( file . dstAbsPath , relPathBase ) ) {
10541078 const dstRelPath = path . relative ( relPathBase , file . dstAbsPath ) ;
10551079 entries . push ( new FileElement ( file . srcAbsPath , file . dstAbsPath , dstRelPath , file . status , file . isSubmodule , file . stats ) ) ;
10561080 }
@@ -1628,6 +1652,16 @@ export class GitTreeCompareProvider implements TreeDataProvider<Element>, Dispos
16281652 this . viewAsList = viewAsList ;
16291653 commands . executeCommand ( 'setContext' , NAMESPACE + '.viewAsList' , viewAsList ) ;
16301654 this . log ( 'Refreshing tree' ) ;
1655+ this . _onDidChangeTreeData . fire ( ) ;
1656+ }
1657+
1658+ setHideCheckedFiles ( hide : boolean ) {
1659+ if ( hide === this . hideCheckedFiles ) {
1660+ return ;
1661+ }
1662+ this . hideCheckedFiles = hide ;
1663+ commands . executeCommand ( 'setContext' , NAMESPACE + '.hideCheckedFiles' , hide ) ;
1664+ this . log ( 'Refreshing tree' ) ;
16311665 this . fireTreeDataChange ( ) ;
16321666 }
16331667
0 commit comments