@@ -60,6 +60,7 @@ with LSP.Messages.Client_Requests;
6060with LSP.Messages.Server_Notifications ;
6161with LSP.Servers.FS_Watch ;
6262with LSP.Types ; use LSP.Types;
63+ with LSP.Generic_Cancel_Check ;
6364
6465with Langkit_Support.Slocs ;
6566with Langkit_Support.Text ;
@@ -3740,23 +3741,13 @@ package body LSP.Ada_Handlers is
37403741 Name : Libadalang.Analysis.Defining_Name;
37413742 Stop : in out Boolean);
37423743
3743- function Has_Been_Canceled return Boolean;
3744-
3745- procedure Write_Symbols is
3746- new LSP.Ada_Completions.Write_Symbols (Has_Been_Canceled);
3747-
3748- Count : Cancel_Countdown := 0 ;
37493744 Names : LSP.Ada_Completions.Completion_Maps.Map;
37503745
3751- -- ---------------------
3752- -- Has_Been_Canceled --
3753- -- ---------------------
3746+ package Canceled is new LSP.Generic_Cancel_Check (Request, 127 );
37543747
3755- function Has_Been_Canceled return Boolean is
3756- begin
3757- Count := Count - 1 ;
3758- return Count = 0 and then Request.Canceled;
3759- end Has_Been_Canceled ;
3748+ procedure Write_Symbols is
3749+ new LSP.Ada_Completions.Generic_Write_Symbols
3750+ (Canceled.Has_Been_Canceled);
37603751
37613752 -- ------------------------
37623753 -- On_Inaccessible_Name --
@@ -3778,8 +3769,9 @@ package body LSP.Ada_Handlers is
37783769 Is_Visible => False,
37793770 Use_Snippets => False,
37803771 Pos => <>));
3781- Stop := Has_Been_Canceled;
37823772 end if ;
3773+
3774+ Stop := Canceled.Has_Been_Canceled;
37833775 end On_Inaccessible_Name ;
37843776
37853777 Pattern : constant Search_Pattern'Class := Build
@@ -3802,7 +3794,9 @@ package body LSP.Ada_Handlers is
38023794 Only_Public => False,
38033795 Callback => On_Inaccessible_Name'Access );
38043796
3805- exit when Request.Canceled;
3797+ if Canceled.Has_Been_Canceled then
3798+ return Response;
3799+ end if ;
38063800 end loop ;
38073801
38083802 for Doc of Self.Open_Documents loop
@@ -3815,8 +3809,13 @@ package body LSP.Ada_Handlers is
38153809 Pattern,
38163810 Ada.Containers.Count_Type'Last,
38173811 False,
3812+ Canceled.Has_Been_Canceled'Access ,
38183813 Names);
38193814 end ;
3815+
3816+ if Canceled.Has_Been_Canceled then
3817+ return Response;
3818+ end if ;
38203819 end loop ;
38213820
38223821 Write_Symbols (Names, Response.result);
0 commit comments