@@ -194,12 +194,16 @@ package body LSP.Raw_Clients is
194194 begin
195195 loop
196196 declare
197- Raw : Ada.Streams.Stream_Element_Array (1 .. 1024 );
198- Last : Ada.Streams.Stream_Element_Count;
199- Text : String (1 .. 1024 ) with Import, Address => Raw'Address;
197+ Raw : Ada.Streams.Stream_Element_Array (1 .. 1024 );
198+ Last : Ada.Streams.Stream_Element_Count;
199+ Text : String (1 .. 1024 ) with Import, Address => Raw'Address;
200+ Success : Boolean := True;
201+
200202 begin
201- Self.Client.Server.Read_Standard_Error (Raw, Last);
202- exit when Last in 0 ;
203+ Self.Client.Server.Read_Standard_Error (Raw, Last, Success);
204+
205+ exit when Last < Raw'First or not Success;
206+
203207 Self.Client.On_Standard_Error_Message (Text (1 .. Natural (Last)));
204208 end ;
205209 end loop ;
@@ -220,18 +224,21 @@ package body LSP.Raw_Clients is
220224 begin
221225 while Rest_Length > 0 loop
222226 declare
223- Size : constant Positive := Positive'Min (Rest_Length, 1024 );
227+ Size : constant Positive := Positive'Min (Rest_Length, 1024 );
224228 -- Restrict output to reasonable size to avoid stack overflow
225- Slice : constant String := Ada.Strings.Unbounded.Slice
229+ Slice : constant String := Ada.Strings.Unbounded.Slice
226230 (Client.To_Write, Client.Written + 1 , Client.Written + Size);
227- Raw : constant Ada.Streams.Stream_Element_Array
231+ Raw : constant Ada.Streams.Stream_Element_Array
228232 (1 .. Ada.Streams.Stream_Element_Count (Size))
229233 with Import, Address => Slice'Address;
230- Last : Natural;
234+ Last : Natural;
235+ Success : Boolean := True;
231236
232237 begin
233238 Client.Server.Write_Standard_Input
234- (Raw, Ada.Streams.Stream_Element_Count (Last));
239+ (Raw, Ada.Streams.Stream_Element_Count (Last), Success);
240+
241+ -- ??? IO failure is not handled, should it?
235242
236243 Client.Written := Client.Written + Last;
237244 Rest_Length := Rest_Length - Last;
@@ -319,15 +326,17 @@ package body LSP.Raw_Clients is
319326 begin
320327 loop
321328 declare
322- Raw : Ada.Streams.Stream_Element_Array (1 .. 1024 );
323- Last : Ada.Streams.Stream_Element_Count;
324- Text : String (1 .. Raw'Length)
329+ Raw : Ada.Streams.Stream_Element_Array (1 .. 1024 );
330+ Last : Ada.Streams.Stream_Element_Count;
331+ Text : String (1 .. Raw'Length)
325332 with Import, Address => Raw'Address;
326- Start : Natural;
333+ Success : Boolean := True;
334+ Start : Natural;
335+
327336 begin
328- Client.Server.Read_Standard_Output (Raw, Last);
337+ Client.Server.Read_Standard_Output (Raw, Last, Success );
329338
330- exit when Last in 0 ;
339+ exit when Last < Raw'First or not Success ;
331340
332341 Append (Client.Buffer, Text (1 .. Positive (Last)));
333342
0 commit comments