Code doesn't get passed if using the the prompt_actions when using the Telescope integration #288
Replies: 4 comments 1 reply
-
Weirdly the default Nvim behaviour of get visual selection updates after you escape the selection, so I find that if I select and unselect the thing I want to chat about, it'll work. However it'd be great for this to be improved |
Beta Was this translation helpful? Give feedback.
-
We can definitely cancel selection earlier, and we should, I think this is actually a bug and should be an issue not discusson |
Beta Was this translation helpful? Give feedback.
-
If someone finds it to be useful, here is my custom selection = function(source)
local select = require("CopilotChat.select")
-- HACK: We detect the if normal or visual mode is active first,
-- otherwise if left as per LazyVim default, visual_sel will always
-- be checked first, and return the selection between '< and '> marks,
-- even if no visual selection is currently active, thus:
-- - buffer_sel wouldn't be done.
-- - selected text could be wrong if text is added or removed to the
-- original buffer => this could lead to an error!
-- TODO: Report issue to LazyVim repo?
local mode = vim.api.nvim_get_mode().mode
-- vim.notify("Mode: " .. mode)
if mode == "n" then
local buffer_sel = select.buffer(source)
-- vim.notify("Buffer selection: " .. vim.inspect(buffer_sel))
return buffer_sel
elseif mode == "v" then
local visual_sel = select.visual(source)
-- vim.notify("Visual selection: " .. vim.inspect(visual_sel))
return visual_sel
end
end, |
Beta Was this translation helpful? Give feedback.
-
i changed how leaving visual mode works (as we are forcing visual mode leave as workaround beacuse of it), could someone with telescope maybe retry if it works with default config now? Maybe it will |
Beta Was this translation helpful? Give feedback.
-
I assume in some cases it's the visual selection that gets passed to the prompt, but if one tries to use it through the telescope integration, the selection disappears and nothing gets passed (or the current line at most)
Beta Was this translation helpful? Give feedback.
All reactions