@@ -18,6 +18,7 @@ import DiffFileTreeItem from './DiffFileTreeItem.vue';
18
18
import {doLoadMoreFiles } from ' ../features/repo-diff.js' ;
19
19
import {toggleElem } from ' ../utils/dom.js' ;
20
20
import {DiffTreeStore } from ' ../modules/stores.js' ;
21
+ import {setFileFolding } from ' ../features/file-fold.js' ;
21
22
22
23
const {pageData } = window .config ;
23
24
const LOCAL_STORAGE_KEY = ' diff_file_tree_visible' ;
@@ -104,6 +105,7 @@ export default {
104
105
105
106
this .hashChangeListener = () => {
106
107
this .store .selectedItem = window .location .hash ;
108
+ this .expandSelectedFile ();
107
109
};
108
110
this .hashChangeListener ();
109
111
window .addEventListener (' hashchange' , this .hashChangeListener );
@@ -113,6 +115,14 @@ export default {
113
115
window .removeEventListener (' hashchange' , this .hashChangeListener );
114
116
},
115
117
methods: {
118
+ expandSelectedFile () {
119
+ // expand file if the selected file is folded
120
+ if (this .store .selectedItem ) {
121
+ const box = document .querySelector (this .store .selectedItem );
122
+ const folded = box? .getAttribute (' data-folded' ) === ' true' ;
123
+ if (folded) setFileFolding (box, box .querySelector (' .fold-file' ), false );
124
+ }
125
+ },
116
126
toggleVisibility () {
117
127
this .updateVisibility (! this .fileTreeIsVisible );
118
128
},
0 commit comments