@@ -206,6 +206,34 @@ def get_config_suggestions(_params: any) -> dict[str, any]:
206206 formatter_suggestions , default_formatter = get_suggestions (CommonSections .formatter_cmds )
207207 get_valid_subdirs .cache_clear ()
208208
209+ # Provide sensible fallbacks when no subdirectories are found
210+ # Only suggest directories that actually exist in the workspace
211+ if not module_root_suggestions :
212+ cwd = Path .cwd ()
213+ common_module_dirs = ["src" , "lib" , "app" ]
214+ module_root_suggestions = ["." ] # Always include current directory
215+
216+ # Add common patterns only if they exist
217+ for dir_name in common_module_dirs :
218+ if (cwd / dir_name ).is_dir ():
219+ module_root_suggestions .append (dir_name )
220+
221+ default_module_root = "."
222+
223+ if not tests_root_suggestions :
224+ cwd = Path .cwd ()
225+ common_test_dirs = ["tests" , "test" , "__tests__" ]
226+ tests_root_suggestions = []
227+
228+ # Add common test directories only if they exist
229+ for dir_name in common_test_dirs :
230+ if (cwd / dir_name ).is_dir ():
231+ tests_root_suggestions .append (dir_name )
232+
233+ # Always include current directory as fallback
234+ tests_root_suggestions .append ("." )
235+ default_tests_root = tests_root_suggestions [0 ] if tests_root_suggestions else "."
236+
209237 configured_module_root = Path (server .args .module_root ).relative_to (Path .cwd ()) if server .args .module_root else None
210238 configured_tests_root = Path (server .args .tests_root ).relative_to (Path .cwd ()) if server .args .tests_root else None
211239 configured_test_framework = server .args .test_framework if server .args .test_framework else None
0 commit comments