@@ -82,6 +82,7 @@ def get_arg_parser():
8282
8383@server .command ("vectorcode" )
8484async def execute_command (ls : LanguageServer , args : list [str ]):
85+ progress_token = str (uuid .uuid4 ())
8586 try :
8687 global DEFAULT_PROJECT_ROOT
8788 start_time = time .time ()
@@ -119,8 +120,6 @@ async def execute_command(ls: LanguageServer, args: list[str]):
119120 final_configs = parsed_args
120121 logger .info ("Merged final configs: %s" , final_configs )
121122 async with ClientManager ().get_client (final_configs ) as client :
122- progress_token = str (uuid .uuid4 ())
123-
124123 if final_configs .action in {
125124 CliAction .vectorise ,
126125 CliAction .query ,
@@ -155,6 +154,8 @@ async def execute_command(ls: LanguageServer, args: list[str]):
155154 progress_token ,
156155 types .WorkDoneProgressEnd (message = log_message ),
157156 )
157+
158+ progress_token = None
158159 logger .info (log_message )
159160 return final_results
160161 case CliAction .ls :
@@ -174,6 +175,7 @@ async def execute_command(ls: LanguageServer, args: list[str]):
174175 types .WorkDoneProgressEnd (message = "List retrieved." ),
175176 )
176177 logger .info (f"Retrieved { len (projects )} project(s)." )
178+ progress_token = None
177179 return projects
178180 case CliAction .vectorise :
179181 assert collection is not None , (
@@ -241,6 +243,8 @@ async def execute_command(ls: LanguageServer, args: list[str]):
241243 message = f"Vectorised { stats .add + stats .update } files."
242244 ),
243245 )
246+
247+ progress_token = None
244248 return stats .to_dict ()
245249 case CliAction .files :
246250 if collection is None : # pragma: nocover
@@ -249,6 +253,7 @@ async def execute_command(ls: LanguageServer, args: list[str]):
249253 )
250254 match final_configs .files_action :
251255 case FilesAction .ls :
256+ progress_token = None
252257 return await list_collection_files (collection )
253258 case FilesAction .rm :
254259 to_be_removed = list (
@@ -277,6 +282,7 @@ async def execute_command(ls: LanguageServer, args: list[str]):
277282 message = "Removal finished." ,
278283 ),
279284 )
285+ progress_token = None
280286 case _ as c : # pragma: nocover
281287 error_message = f"Unsupported vectorcode subcommand: { str (c )} "
282288 logger .error (
@@ -290,6 +296,14 @@ async def execute_command(ls: LanguageServer, args: list[str]):
290296 else :
291297 # wrap non-pygls errors for error codes.
292298 raise JsonRpcInternalError (message = traceback .format_exc ()) from e
299+ finally :
300+ if progress_token is not None :
301+ ls .progress .end (
302+ progress_token ,
303+ types .WorkDoneProgressEnd (
304+ message = "Removal finished." ,
305+ ),
306+ )
293307
294308
295309async def lsp_start () -> int :
0 commit comments