@@ -42,6 +42,11 @@ function! s:StdioGet(mode, Callback) abort
42
42
\ ' ResponseHandler' : function (' s:StdioGetRH' , [a: Callback ]),
43
43
\ ' SavePosition' : 1
44
44
\}
45
+ call s: PrepareParameters (opts, a: mode )
46
+ call OmniSharp#stdio#Request (' /v2/getcodeactions' , opts)
47
+ endfunction
48
+
49
+ function ! s: PrepareParameters (opts, mode ) abort
45
50
if a: mode == # ' visual'
46
51
let start = getpos (" '<" )
47
52
let end = getpos (" '>" )
@@ -63,13 +68,12 @@ function! s:StdioGet(mode, Callback) abort
63
68
\ }
64
69
\ }
65
70
\}
66
- let opts.Parameters = s: codeActionParameters
71
+ let a: opts .Parameters = s: codeActionParameters
67
72
else
68
73
if exists (' s:codeActionParameters' )
69
74
unlet s: codeActionParameters
70
75
endif
71
76
endif
72
- call OmniSharp#stdio#Request (' /v2/getcodeactions' , opts)
73
77
endfunction
74
78
75
79
function ! s: StdioGetRH (Callback, response) abort
@@ -156,16 +160,35 @@ function! s:CBGetCodeActions(mode, actions) abort
156
160
endfunction
157
161
158
162
163
+ function ! OmniSharp#actions#codeactions#Repeat (mode ) abort
164
+ if ! g: OmniSharp_server_stdio
165
+ echomsg ' This functionality is only available with the stdio server'
166
+ return
167
+ endif
168
+ if ! exists (' s:lastCodeActionIdentifier' )
169
+ echomsg ' There is no last code action to repeat'
170
+ return
171
+ endif
172
+ call s: PrepareParameters ({}, a: mode )
173
+ let RH = function (' OmniSharp#buffer#PerformChanges' , [{}])
174
+ call s: RunCodeAction (s: lastCodeActionIdentifier , 1 , RH)
175
+ endfunction
176
+
159
177
function ! OmniSharp#actions#codeactions#Run (action, ... ) abort
160
178
let RH = function (' OmniSharp#buffer#PerformChanges' , [a: 0 ? a: 1 : {}])
179
+ let s: lastCodeActionIdentifier = a: action .Identifier
180
+ call s: RunCodeAction (a: action .Identifier , 0 , RH)
181
+ endfunction
182
+
183
+ function ! s: RunCodeAction (identifier , repeating, ResponseHandler) abort
161
184
let opts = {
162
- \ ' ResponseHandler' : RH ,
185
+ \ ' ResponseHandler' : a: ResponseHandler ,
163
186
\ ' Parameters' : {
164
- \ ' Identifier' : a: action . Identifier ,
187
+ \ ' Identifier' : a: identifier ,
165
188
\ ' WantsTextChanges' : 1 ,
166
189
\ ' WantsAllCodeActionOperations' : 1
167
190
\ },
168
- \ ' UsePreviousPosition' : 1
191
+ \ ' UsePreviousPosition' : ! a: repeating
169
192
\}
170
193
if exists (' s:codeActionParameters' )
171
194
call extend (opts.Parameters, s: codeActionParameters , ' force' )
0 commit comments