Skip to content

Documentation for "Next Edit Suggestions" #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
zackerydev opened this issue Apr 11, 2025 · 5 comments
Open

Documentation for "Next Edit Suggestions" #21

zackerydev opened this issue Apr 11, 2025 · 5 comments

Comments

@zackerydev
Copy link

Poking around in the Language Server source I seem to have found references to endpoints such as: textDocument/handleNextEditRequest. Is documentation for the endpoints centered around "NES" (as VSCode calls it) forthcoming?

As a day-to-day copilot user in various Editors (IntelliJ, Neovim, and VSCode itself) it would be awesome to get the same editing experience across them and that documentation would go a long way in building the OSS tooling required for those editors.

@hsenag
Copy link

hsenag commented Apr 11, 2025

Although there is an endpoint that would call that function, I'm afraid that documentation is likely to be some way off. At this point there's no guarantee the interface won't change.

@zackerydev
Copy link
Author

That's okay! Even if just some pointers it would be helpful for building integrations on top of copilot, perfectly understandable that the API is a work in progress and I don't expect any guarantees of stability.

I can imagine though that since it's GA in VSCode it should be to the point where at least some other editors can begin building on it?

@AntoineGS
Copy link

Seconding this :P I don't mind if it changes down the line but I would be very happy to be able to integrate it in its early stage.
Even some unofficial pointers would be greatly appreciated, as I have spent a good chunk of my weekend trying to figure out the endpoints with currently no result.

@GitMurf
Copy link

GitMurf commented Apr 14, 2025

Couldn't agree more. As a dedicated Neovim user, the only thing that has even tempted me to pursue using an editor like Cursor was the tab completions feature. I do not really care for any of the agentic stuff, so if we could get next edit suggestions in Neovim that would satisfy my itch. Without it, paying for GitHub Copilot subscription will be harder and harder to justify when all we get is "regular autocomplete" in editors like Neovim.

@AntoineGS
Copy link

Thanks to @tris203 most of the logic has now been figured out, however we are struggling with the correct request flow.
The LSP seems to be be continuing its job/task even after the API has returned the completion data, which means that if another request is sent right after the first one returns data, the LSP will yield this error:

Image

Logs that show the flow, the first being the flow that works:

2025-04-25 13:18:40.735 [25] [TRACE]: api request:
"textDocument/copilotInlineEdit"
{
  position = {
    character = 6,
    line = 2
  },
  textDocument = {
    uri = "file:///C:/Gits/copilot-lsp/lua/copilot-lsp/errors.lua",
    version = 8
  }
}
2025-04-25 13:18:41.537 [26] [INFO]: LSP message: [fetchCompletions] request.response: [https://copilot-proxy.githubusercontent.com/chat/completions] took 598.3495999999868 ms
2025-04-25 13:18:41.762 [28] [INFO]: LSP message: [streamChoices] request done: headerRequestId: [dad73948-1b8a-4aab-ad4c-7da5cef0123e] model deployment ID: []
2025-04-25 13:18:41.762 [27] [INFO]: LSP message: [streamChoices] solution 0 returned. finish reason: [stop]

<---- New request ---->

2025-04-25 13:19:09.266 [29] [TRACE]: api request:
"textDocument/copilotInlineEdit"
{
  position = {
    character = 7,
    line = 2
  },
  textDocument = {
    uri = "file:///C:/Gits/copilot-lsp/lua/copilot-lsp/errors.lua",
    version = 9
  }
}
2025-04-25 13:19:10.932 [30] [INFO]: LSP message: [fetchCompletions] request.response: [https://copilot-proxy.githubusercontent.com/chat/completions] took 463.1487999999954 ms
2025-04-25 13:19:10.039 [31] [INFO]: LSP message: [streamChoices] solution 0 returned. finish reason: [stop]
2025-04-25 13:19:10.039 [32] [INFO]: LSP message: [streamChoices] request done: headerRequestId: [538ad036-111e-419d-80b7-13dec874691d] model deployment ID: []

If I do a second request quickly:

2025-04-25 13:20:09.007 [33] [TRACE]: api request:
"textDocument/copilotInlineEdit"
{
  position = {
    character = 8,
    line = 2
  },
  textDocument = {
    uri = "file:///C:/Gits/copilot-lsp/lua/copilot-lsp/errors.lua",
    version = 10
  }
}
2025-04-25 13:20:10.545 [34] [INFO]: LSP message: [fetchCompletions] request.response: [https://copilot-proxy.githubusercontent.com/chat/completions] took 336.46389999997336 ms

<---- New request ---->

2025-04-25 13:20:10.648 [35] [INFO]: LSP message: [streamChoices] request done: headerRequestId: [72fc637f-17a9-40a1-b296-7f1a7a7aa981] model deployment ID: []
2025-04-25 13:20:10.648 [36] [ERROR]: LSP message: [lsp] Request textDocument/copilotInlineEdit: AbortError: The operation was aborted.
    at EventEmitter.abortHandler (C:\snapshot\copilot-client\node_modules\@adobe\helix-fetch\src\fetch\index.js:106:17)
    at EventEmitter.emit (node:events:518:28)
    at G6.dispatchEvent (C:\snapshot\copilot-client\node_modules\@adobe\helix-fetch\src\fetch\abort.js:67:41)
    at G6.fire (C:\snapshot\copilot-client\node_modules\@adobe\helix-fetch\src\fetch\abort.js:72:10)
    at UH.abort (C:\snapshot\copilot-client\node_modules\@adobe\helix-fetch\src\fetch\abort.js:137:39)
    at gI.value (C:\snapshot\copilot-client\lib\src\networking.ts:255:19)
    at zu._deliver (C:\snapshot\copilot-client\lib\src\nextEditSuggestions\vscode-copilot\src\util\vs\base\common\event.ts:1330:22)
    at zu.fire (C:\snapshot\copilot-client\lib\src\nextEditSuggestions\vscode-copilot\src\util\vs\base\common\event.ts:1361:18)
    at CI.cancel (C:\snapshot\copilot-client\lib\src\nextEditSuggestions\vscode-copilot\src\util\vs\base\common\cancellation.ts:77:31)
    at L1.cancel (C:\snapshot\copilot-client\lib\src\nextEditSuggestions\vscode-copilot\src\util\vs\base\common\cancellation.ts:130:25) {
  type: 'aborted',
  _name: 'AbortError'
}
2025-04-25 13:20:12.519 [37] [TRACE]: api request:
"textDocument/copilotInlineEdit"
{
  position = {
    character = 9,
    line = 2
  },
  textDocument = {
    uri = "file:///C:/Gits/copilot-lsp/lua/copilot-lsp/errors.lua",
    version = 11
  }
}
2025-04-25 13:20:12.019 [38] [TRACE]: api request:
"textDocument/copilotInlineEdit"
{
  position = {
    character = 10,
    line = 2
  },
  textDocument = {
    uri = "file:///C:/Gits/copilot-lsp/lua/copilot-lsp/errors.lua",
    version = 12
  }
}

The odd thing is, if I call cancelRequest right after sending the request (for "textDocument/copilotInlineEdit"), the error goes away and somehow the API still returns next edit data 🤷‍♂️

Any pointers would be appreciated :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants