@@ -19,37 +19,37 @@ endfunction
19
19
let s: id = 1
20
20
let s: handlers = {}
21
21
22
+ " Note: vim execute callback for every line.
23
+ let s: content_length = 0
24
+ let s: input = ' '
22
25
function ! s: HandleMessage (job, lines , event ) abort
23
26
if a: event == # ' stdout'
24
- let l: content_length = 0
25
- let l: input = ' '
26
-
27
27
while len (a: lines ) > 0
28
28
let l: line = remove (a: lines , 0 )
29
29
30
30
if l: line == # ' '
31
31
continue
32
- elseif l : content_length == 0
33
- let l : content_length = str2nr (substitute (l: line , ' .*Content-Length:' , ' ' , ' ' ))
32
+ elseif s : content_length == 0
33
+ let s : content_length = str2nr (substitute (l: line , ' .*Content-Length:' , ' ' , ' ' ))
34
34
continue
35
35
endif
36
36
37
- let l : input .= strpart (l: line , 0 , l : content_length )
38
- if l : content_length < strlen (l: line )
39
- call insert (a: lines , strpart (l: line , l : content_length ), 0 )
40
- let l : content_length = 0
37
+ let s : input .= strpart (l: line , 0 , s : content_length )
38
+ if s : content_length < strlen (l: line )
39
+ call insert (a: lines , strpart (l: line , s : content_length ), 0 )
40
+ let s : content_length = 0
41
41
else
42
- let l : content_length = l : content_length - strlen (l: line )
42
+ let s : content_length = s : content_length - strlen (l: line )
43
43
endif
44
- if l : content_length > 0
44
+ if s : content_length > 0
45
45
continue
46
46
endif
47
47
48
48
try
49
- let l: message = json_decode (l : input )
50
- let l : input = ' '
49
+ let l: message = json_decode (s : input )
50
+ let s : input = ' '
51
51
catch
52
- let l : input = ' '
52
+ let s : input = ' '
53
53
call s: Debug (string (v: exception ))
54
54
continue
55
55
endtry
0 commit comments