@@ -95,6 +95,16 @@ export const FileDialog = ({
9595 fileService . contextKey . fileDialogViewVisibleContext . set ( false ) ;
9696 } , [ isReady , dialogService , model , fileName , options ] ) ;
9797
98+ const getDefaultPath = ( model ) => {
99+ let defaultPath = ( model . treeModel . root as Directory ) . uri . codeUri . fsPath ;
100+
101+ if ( fileService . getDefaultFilePath ) {
102+ defaultPath = fileService . getDefaultFilePath ( defaultPath ) ;
103+ }
104+
105+ return defaultPath ;
106+ } ;
107+
98108 const close = useCallback ( ( ) => {
99109 setIsReady ( false ) ;
100110 dialogService . hide ( ) ;
@@ -106,7 +116,9 @@ export const FileDialog = ({
106116 // 确保数据初始化完毕,减少初始化数据过程中多次刷新视图
107117 // 这里需要重新取一下treeModel的值确保为最新的TreeModel
108118 await model . treeModel . ensureReady ;
109- setSelectPath ( ( model . treeModel . root as Directory ) . uri . codeUri . fsPath ) ;
119+ const path = getDefaultPath ( model ) ;
120+
121+ setSelectPath ( path ) ;
110122 setIsReady ( true ) ;
111123 } , [ model , selectPath , isReady ] ) ;
112124
@@ -211,6 +223,14 @@ export const FileDialog = ({
211223 [ model , isReady , selectPath , directoryList ] ,
212224 ) ;
213225
226+ const renderWarningMsg = useCallback ( ( ) => {
227+ if ( fileService . renderWarningMsg ) {
228+ return fileService . renderWarningMsg ( ) ;
229+ } else {
230+ return null ;
231+ }
232+ } , [ fileService . renderWarningMsg ] ) ;
233+
214234 const renderDialogTreeNode = useCallback (
215235 ( props : INodeRendererProps ) => (
216236 < FileTreeDialogNode
@@ -244,6 +264,11 @@ export const FileDialog = ({
244264 }
245265 } , [ isReady , model ] ) ;
246266
267+ const showFilePathSearch = useMemo (
268+ ( ) => ( fileService . showFilePathSearch === false ? false : true ) ,
269+ [ fileService . showFilePathSearch ] ,
270+ ) ;
271+
247272 const renderDirectorySelection = useCallback ( ( ) => {
248273 if ( directoryList . length > 0 ) {
249274 return (
@@ -254,7 +279,7 @@ export const FileDialog = ({
254279 size = 'large'
255280 searchPlaceholder = { selectPath }
256281 value = { selectPath }
257- showSearch = { true }
282+ showSearch = { showFilePathSearch }
258283 >
259284 { directoryList . map ( ( item , idx ) => (
260285 < Option value = { item } key = { `${ idx } - ${ item } ` } >
@@ -291,6 +316,7 @@ export const FileDialog = ({
291316 const DialogContent = useMemo (
292317 ( ) => (
293318 < >
319+ { renderWarningMsg ( ) }
294320 < div className = { styles . file_dialog_directory } > { renderDirectorySelection ( ) } </ div >
295321 < div className = { styles . file_dialog_content } > { renderDialogTree ( ) } </ div >
296322 </ >
0 commit comments