@@ -279,6 +279,73 @@ item, plus the length (in UTF-16 codepoints) of the completion that was accepted
279279Note that the ` acceptedLength ` includes everything from the start of ` insertText ` to the end of the accepted text. It is
280280* not* the length of the accepted text itself.
281281
282+ ## Next Edit Suggestions
283+
284+ ` textDocument/copilotInlineEdit ` is a custom method used to retrieve "next edit"
285+ suggestions which are inline completions that may include deletions or
286+ modifications to existing text and may not be positioned at the cursor. These
287+ are similar to inline completions and the API shape is similar as well. But it
288+ is a separate method to allow opting into the feature and distinguishing between
289+ the two kinds of suggestions.
290+
291+ The request parameters are similar to
292+ [ ` TextDocumentPositionParams ` ] ( https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification/#textDocumentPositionParams )
293+ but with a ` textDocument.version ` field required as in as
294+ [ ` VersionedTextDocumentIdentifier ` ] ( https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification/#versionedTextDocumentIdentifier ) :
295+
296+ ``` json
297+ {
298+ "textDocument" : {
299+ "uri" : " file:///path/to/file" ,
300+ "version" : 0
301+ },
302+ "position" : {"line" : 1 , "character" : 2 }
303+ }
304+ ```
305+
306+ The result is an object containing an ` edits ` array:
307+
308+ ``` json
309+ {
310+ "edits" : [
311+ {
312+ "text" : " an edit suggestion" ,
313+ "textDocument" : {
314+ "uri" : " file:///path/to/file" ,
315+ "version" : 0
316+ },
317+ "range" : {
318+ "start" : {"line" : 1 , "character" : 0 },
319+ "end" : {"line" : 1 , "character" : 5 }
320+ },
321+ "command" : {
322+ "title" : " Accept inline edit" ,
323+ "command" : " github.copilot.didAcceptCompletionItem" ,
324+ "arguments" : [" some-id" ]
325+ }
326+ }
327+ ]
328+ }
329+ ```
330+
331+ The ` command ` field, per the LSP spec, is called via
332+ [ ` workspace/executeCommand ` ] ( https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_executeCommand )
333+ * after* the user accepts the edit. Copilot uses this for acceptance telemetry.
334+
335+ The LSP spec does not provide an event for showing the edit, so a custom
336+ ` textDocument/didShowInlineEdit ` is used. Call it with an ` item ` parameter
337+ containing the item shown from the ` edits ` array (note only the first argument is required):
338+
339+ ``` json
340+ {
341+ "item" : {
342+ "command" : {
343+ "arguments" : [" some-id" ]
344+ }
345+ }
346+ }
347+ ```
348+
282349## Panel Completions
283350
284351Panel completions are used for "Open Copilot" style completions. They are similar to inline completions, but are shown
0 commit comments