Skip to content

Conversation

bassamsdata
Copy link
Contributor

Adds history storage for the last 2 NES suggestions with ability to restore and cycle through them.

Direct fix for #36

Changes:

  • Store suggestions in history when displayed (max 2 items)
  • Add restore_suggestion() function to cycle through history
  • Reset history index when new suggestions arrive
  • Clear invalid suggestions when buffer changes
  • Add tests for history functionality
  • Update README

Usage:

  • Call require("copilot-lsp.nes").restore_suggestion() to cycle through previous suggestions
  • Each call shows the next suggestion in history, wrapping around after the last one

Thank you

Screen.Recording.2025-06-02.at.11.38.34.AM.mp4

@tris203
Copy link
Collaborator

tris203 commented Jun 2, 2025

I haven't yet reviewed this properly but I think the data structure could be simplified with a vim.ringbuf

@bassamsdata
Copy link
Contributor Author

I think the data structure could be simplified with a vim.ringbuf

Ah, no matter how much I use Neovim, it still surprises me with things I didn’t know. I’ll check it out.

@bassamsdata
Copy link
Contributor Author

bassamsdata commented Jun 2, 2025

vim.ringbuf() replaced my manual history handling, thanks @tris203 for pointing it out!

@GitMurf
Copy link

GitMurf commented Jun 10, 2025

Looking forward to this! Is there any further testing you need done? or is this pretty much ready to merge?

@tris203
Copy link
Collaborator

tris203 commented Jun 10, 2025

Looking forward to this! Is there any further testing you need done? or is this pretty much ready to merge?

I have been travelling so havent really had time to review it properly.
I will try and get to it in the next week or so

@tris203
Copy link
Collaborator

tris203 commented Jun 17, 2025

My fundemental problem with this behaviour is if you have edited the buffer, then restore the suggestion, the edits can be way off...

I need to think about this more...

@GitMurf
Copy link

GitMurf commented Jun 17, 2025

My fundemental problem with this behaviour is if you have edited the buffer, then restore the suggestion, the edits can be way off...

I need to think about this more...

I haven't looked at how it was implemented here, but when I implemented my own quick hacky solution I cached the original text at time of NES and then invalidated that item if the text was not the same later. So you lose any cache of previous NES items if the file changed in a way that effects the location / text content of the cached NES items.

Thoughts?

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

Successfully merging this pull request may close these issues.

3 participants