Skip to content
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

feature request: undo accepted text #235

Open
thenbe opened this issue Nov 12, 2023 · 2 comments
Open

feature request: undo accepted text #235

thenbe opened this issue Nov 12, 2023 · 2 comments

Comments

@thenbe
Copy link

thenbe commented Nov 12, 2023

Current behavior:

  1. Type 123
  2. Copilot suggests 456
  3. You accept suggestion
  4. You press undo
  5. Observe that entire line is deleted

Desired behavior:

  1. Type 123
  2. Copilot suggests 456
  3. You accept suggestion
  4. You press undo
  5. Observe that only 456 is deleted. You are still left with the original text you manually typed: 123

Workaround attempts

I tried this after disabling the default accept keymap, but the it acts in a weird manner. Instead of undoing the suggestion, it only moves the cursor without removing any text.

map("i", "<M-f>", function()
	-- 1. preserve undo point
	vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<c-g>u", true, false, true), "t", false)
	-- 2. then accept suggestion
	require("copilot.suggestion").accept()
end)

This one doesn't work either. Here, pressing undo removes the entire line.

map("i", "<M-f>", function()
	-- 1. simulate exiting then re-entering insert mode to trigger undopoint
	vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>a", true, false, true), "t", false)
	-- 2. then accept suggestion
	require("copilot.suggestion").accept()
end)
@MunifTanjim
Copy link
Collaborator

This is also probably a regression from neovim/neovim#24901 🤔

What is your Neovim version?

@thenbe
Copy link
Author

thenbe commented Nov 16, 2023

I'm on nightly.

NVIM v0.10.0-dev-d2983dc
Build type: Release
LuaJIT 2.1.1693350652

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

2 participants