@@ -37,6 +37,7 @@ export const ExtendsFolderTree: IExtension = {
37
37
new TreeNodeModel ( {
38
38
id,
39
39
name : 'molecule' ,
40
+ location : 'molecule' ,
40
41
fileType : FileTypes . RootFolder ,
41
42
} )
42
43
) ;
@@ -74,18 +75,20 @@ export const ExtendsFolderTree: IExtension = {
74
75
75
76
molecule . folderTree . onSelectFile (
76
77
( file : ITreeNodeItemProps , isUpdate ?: boolean ) => {
77
- const { fileType, isEditable } = file ;
78
+ const { fileType, name , isEditable } = file ;
78
79
const isFile = fileType === FileTypes . File ;
79
80
molecule . folderTree . setActive ( file ?. id ) ;
80
81
if ( ! isFile || isEditable ) return ;
82
+ const nameArr = name ?. split ( '.' ) || [ ] ;
83
+ const extName = nameArr [ nameArr . length - 1 ] || '' ;
81
84
const tabData = {
82
85
...file ,
83
86
id : `${ file . id } ` ?. split ( '_' ) ?. [ 0 ] ,
84
87
modified : false ,
85
88
data : {
86
89
value : file . content ,
87
- path : 'desktop/moslecule/editor1' ,
88
- language : 'sql' ,
90
+ path : file . location ,
91
+ language : extName ,
89
92
} ,
90
93
} ;
91
94
@@ -108,19 +111,22 @@ export const ExtendsFolderTree: IExtension = {
108
111
109
112
molecule . folderTree . onUpdateFileName ( ( file : ITreeNodeItemProps ) => {
110
113
const { folderTree } = molecule . folderTree . getState ( ) ;
111
- const { id, name, fileType } = file as any ;
114
+ const { id, name, fileType, location } = file as any ;
112
115
const cloneData : ITreeNodeItemProps [ ] = folderTree ?. data || [ ] ;
113
116
const {
114
117
tree,
115
118
index,
116
119
} = molecule . folderTree . getCurrentRootFolderInfo ( id ) ;
117
120
if ( name ) {
121
+ const newLoc = location . split ( '/' ) ;
122
+ newLoc [ newLoc . length - 1 ] = name ;
118
123
tree . update ( id , {
119
124
...file ,
120
125
icon : molecule . folderTree . getFileIconByExtensionName (
121
126
name ,
122
127
fileType
123
128
) ,
129
+ location : newLoc . join ( '/' ) ,
124
130
isEditable : false ,
125
131
} ) ;
126
132
} else {
0 commit comments