@@ -4,6 +4,10 @@ local config = require("copilot.config")
44local hl_group = require (" copilot.highlight" ).group
55local util = require (" copilot.util" )
66
7+ local _ , has_nvim_0_10_x = pcall (function ()
8+ return vim .version ().minor == 10
9+ end )
10+
711local mod = {}
812
913--- @alias copilot_suggestion_context { first ?: integer , cycling ?: integer , cycling_callbacks ?: (fun ( ctx : copilot_suggestion_context ): nil )[], params ?: table , suggestions ?: copilot_get_completions_data_completion[] , choice ?: integer , shown_choices ?: table<string , true> }
@@ -470,7 +474,11 @@ function mod.accept(modifier)
470474 vim .api .nvim_feedkeys (vim .api .nvim_replace_termcodes (" <Space><Left><Del>" , true , false , true ), " n" , false )
471475 vim .lsp .util .apply_text_edits ({ { range = range , newText = newText } }, 0 , " utf-16" )
472476 -- Put cursor at the end of current line.
473- vim .api .nvim_feedkeys (vim .api .nvim_replace_termcodes (" <End>" , true , false , true ), " n" , false )
477+ local cursor_keys = " <End>"
478+ if has_nvim_0_10_x then
479+ cursor_keys = string.rep (" <Down>" , # vim .split (newText , " \n " , { plain = true }) - 1 ) .. cursor_keys
480+ end
481+ vim .api .nvim_feedkeys (vim .api .nvim_replace_termcodes (cursor_keys , true , false , true ), " n" , false )
474482end
475483
476484function mod .accept_word ()
0 commit comments