@@ -194,12 +194,16 @@ package body LSP.Raw_Clients is
194
194
begin
195
195
loop
196
196
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
+
200
202
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
+
203
207
Self.Client.On_Standard_Error_Message (Text (1 .. Natural (Last)));
204
208
end ;
205
209
end loop ;
@@ -220,18 +224,21 @@ package body LSP.Raw_Clients is
220
224
begin
221
225
while Rest_Length > 0 loop
222
226
declare
223
- Size : constant Positive := Positive'Min (Rest_Length, 1024 );
227
+ Size : constant Positive := Positive'Min (Rest_Length, 1024 );
224
228
-- 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
226
230
(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
228
232
(1 .. Ada.Streams.Stream_Element_Count (Size))
229
233
with Import, Address => Slice'Address;
230
- Last : Natural;
234
+ Last : Natural;
235
+ Success : Boolean := True;
231
236
232
237
begin
233
238
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?
235
242
236
243
Client.Written := Client.Written + Last;
237
244
Rest_Length := Rest_Length - Last;
@@ -319,15 +326,17 @@ package body LSP.Raw_Clients is
319
326
begin
320
327
loop
321
328
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)
325
332
with Import, Address => Raw'Address;
326
- Start : Natural;
333
+ Success : Boolean := True;
334
+ Start : Natural;
335
+
327
336
begin
328
- Client.Server.Read_Standard_Output (Raw, Last);
337
+ Client.Server.Read_Standard_Output (Raw, Last, Success );
329
338
330
- exit when Last in 0 ;
339
+ exit when Last < Raw'First or not Success ;
331
340
332
341
Append (Client.Buffer, Text (1 .. Positive (Last)));
333
342
0 commit comments