@@ -174,18 +174,6 @@ function! OmniSharp#stdio#Request(command, opts) abort
174174 \ fnamemodify (bufname (bufnr ), ' :p' ))
175175 let send_buffer = get (a: opts , ' SendBuffer' , 1 )
176176 endif
177- let lines = getbufline (bufnr , 1 , ' $' )
178- if has_key (a: opts , ' OverrideBuffer' )
179- let lines [a: opts .OverrideBuffer.LineNr - 1 ] = a: opts .OverrideBuffer.Line
180- let cnum = a: opts .OverrideBuffer.Col
181- endif
182- let tmp = join (lines , ' ' )
183- " Unique string separator which must not exist in the buffer
184- let sep = ' @' . matchstr (reltimestr (reltime ()), ' \v\.@<=\d+' ) . ' @'
185- while stridx (tmp, sep) >= 0
186- let sep = ' @' . matchstr (reltimestr (reltime ()), ' \v\.@<=\d+' ) . ' @'
187- endwhile
188- let buffer = join (lines , sep)
189177
190178 let body = {
191179 \ ' Arguments' : {
@@ -195,10 +183,23 @@ function! OmniSharp#stdio#Request(command, opts) abort
195183 \ }
196184 \}
197185 if send_buffer
198- let body.Arguments .Buffer = buffer
186+ let lines = getbufline (bufnr , 1 , ' $' )
187+ if has_key (a: opts , ' OverrideBuffer' )
188+ let lines [a: opts .OverrideBuffer.LineNr - 1 ] = a: opts .OverrideBuffer.Line
189+ let cnum = a: opts .OverrideBuffer.Col
190+ endif
191+ let tmp = join (lines , ' ' )
192+ " Unique string separator which must not exist in the buffer
193+ let sep = ' @' . matchstr (reltimestr (reltime ()), ' \v\.@<=\d+' ) . ' @'
194+ while stridx (tmp, sep) >= 0
195+ let sep = ' @' . matchstr (reltimestr (reltime ()), ' \v\.@<=\d+' ) . ' @'
196+ endwhile
197+ let body.Arguments .Buffer = join (lines , sep)
198+ else
199+ let sep = ' '
199200 endif
200201
201- call s: Request (job, body, a: command , a: opts , sep)
202+ call s: Request (job, body, a: command , a: opts , sep, bufnr )
202203
203204 if has_key (a: opts , ' ReplayOnLoad' )
204205 let replay_opts = filter (copy (a: opts ), ' v:key !=# "ReplayOnLoad"' )
@@ -209,10 +210,10 @@ function! OmniSharp#stdio#Request(command, opts) abort
209210endfunction
210211
211212function ! OmniSharp#stdio#RequestGlobal (job, command , opts) abort
212- call s: Request (a: job , {}, a: command , a: opts )
213+ call s: Request (a: job , {}, a: command , a: opts, ' ' , -1 )
213214endfunction
214215
215- function ! s: Request (job, body, command , opts, ... ) abort
216+ function ! s: Request (job, body, command , opts, sep, bufnr ) abort
216217 call OmniSharp#log#Log (a: job , ' Request: ' . a: command , 1 )
217218
218219 let a: body [' Command' ] = a: command
@@ -221,14 +222,14 @@ function! s:Request(job, body, command, opts, ...) abort
221222 if has_key (a: opts , ' Parameters' )
222223 call extend (a: body .Arguments , a: opts .Parameters, ' force' )
223224 endif
224- let sep = a: 0 ? a: 1 : ' '
225- if sep !=# ' '
226- let encodedBody = substitute (json_encode (a: body ), sep, ' \\r\\n' , ' g' )
225+ if a: sep !=# ' '
226+ let encodedBody = substitute (json_encode (a: body ), a: sep , ' \\r\\n' , ' g' )
227227 else
228228 let encodedBody = json_encode (a: body )
229229 endif
230230
231231 let s: requests [s: nextseq ] = {
232+ \ ' BufNum' : a: bufnr ,
232233 \ ' Command' : a: command ,
233234 \ ' Seq' : s: nextseq ,
234235 \ ' StartTime' : reltime ()
0 commit comments