@@ -75,27 +75,30 @@ async def execute_command(ls: LanguageServer, args: list[str]):
7575 )
7676 return
7777 if parsed_args .project_root is None :
78- assert DEFAULT_PROJECT_ROOT is not None , (
79- "Failed to automatically resolve project root!"
80- )
81-
82- parsed_args .project_root = DEFAULT_PROJECT_ROOT
78+ if DEFAULT_PROJECT_ROOT is not None :
79+ parsed_args .project_root = DEFAULT_PROJECT_ROOT
8380 elif DEFAULT_PROJECT_ROOT is None :
8481 DEFAULT_PROJECT_ROOT = str (parsed_args .project_root )
8582
86- parsed_args .project_root = os .path .abspath (str (parsed_args .project_root ))
87- await make_caches (parsed_args .project_root )
88- final_configs = await cached_project_configs [parsed_args .project_root ].merge_from (
89- parsed_args
90- )
91- final_configs .pipe = True
83+ if parsed_args .project_root is not None :
84+ parsed_args .project_root = os .path .abspath (str (parsed_args .project_root ))
85+ await make_caches (parsed_args .project_root )
86+ final_configs = await cached_project_configs [
87+ parsed_args .project_root
88+ ].merge_from (parsed_args )
89+ final_configs .pipe = True
90+ client = await get_client (final_configs )
91+ collection = await get_collection (
92+ client = client ,
93+ configs = final_configs ,
94+ make_if_missing = final_configs .action in {CliAction .vectorise },
95+ )
96+ else :
97+ final_configs = parsed_args
98+ client = await get_client (parsed_args )
99+ collection = None
92100 progress_token = str (uuid .uuid4 ())
93- client = await get_client (final_configs )
94- collection = await get_collection (
95- client = client ,
96- configs = final_configs ,
97- make_if_missing = final_configs .action in {CliAction .vectorise },
98- )
101+
99102 await ls .progress .create_async (progress_token )
100103 match final_configs .action :
101104 case CliAction .query :
@@ -108,9 +111,12 @@ async def execute_command(ls: LanguageServer, args: list[str]):
108111 )
109112 final_results = []
110113 try :
111- final_results .extend (
112- await build_query_results (collection , final_configs )
113- )
114+ if collection is None :
115+ print ("Please specify a project to search in." , file = sys .stderr )
116+ else :
117+ final_results .extend (
118+ await build_query_results (collection , final_configs )
119+ )
114120 finally :
115121 ls .progress .end (
116122 progress_token ,
0 commit comments