FittenTech / fittencode.vim

Fitten Code AI Programming Assistant for Vim
63 stars 5 forks source link

[bug] 当覆盖INSERT模式下 i 键操作后,无法正常使用<tab>键补全 #22

Closed WuJunkai2004 closed 1 month ago

WuJunkai2004 commented 1 month ago

使用bash内部自带的vim时,可以用显示可以补全的内容,但是无法使用补全。 使用verbose map 时,发现按键没有绑定到任何操作上。

luozhiya commented 1 month ago

@WuJunkai2004

无法复现,请您提供一下 vim 版本信息

fittencode 的按键是绑定在 insert 模式下的, 要用 verbose imap <tab> 来查看

WuJunkai2004 commented 1 month ago

@WuJunkai2004

无法复现,请您提供一下 vim 版本信息

fittencode 的按键是绑定在 insert 模式下的, 要用 verbose imap <tab> 来查看

版本为9.0

VIM - Vi IMproved 9.0 (2022 Jun 28, 编译于 Jul 14 2023 00:15:07) VIM - Vi IMproved 9.0 (2022 Jun 28, 编译于 Jul 14 2023 00:15:07) 包含补丁: 1-1403 编译者 巨型版本 无图形界面。 可使用(+)与不可使用(-)的功能: +acl +file_in_path +mouse_urxvt -tag_any_white +arabic +find_in_path +mouse_xterm -tcl +autocmd +float +multi_byte +termguicolors +autochdir +folding +multi_lang +terminal -autoservername -footer -mzscheme +terminfo -balloon_eval +fork() +netbeans_intg +termresponse +balloon_eval_term +gettext +num64 +textobjects -browse -hangul_input +packages +textprop ++builtin_terms +iconv +path_extra +timers +byte_offset +insert_expand +perl/dyn +title +channel +ipv6 +persistent_undo -toolbar +cindent +job +popupwin +user_commands -clientserver +jumplist +postscript +vartabs +clipboard +keymap +printer +vertsplit +cmdline_compl +lambda +profile +vim9script +cmdline_hist +langmap -python +viminfo +cmdline_info +libcall +python3/dyn +virtualedit +comments +linebreak +quickfix +visual +conceal +lispindent +reltime +visualextra +cryptv +listcmds +rightleft +vreplace +cscope +localmap +ruby/dyn +wildignore +cursorbind -lua +scrollbind +wildmenu +cursorshape +menu +signs +windows +dialog_con +mksession +smartindent +writebackup +diff +modify_fname -sodium -X11 +digraphs +mouse -sound -xfontset -dnd -mouseshape +spell -xim -ebcdic +mouse_dec +startuptime -xpm +emacs_tags -mouse_gpm +statusline -xsmp +eval -mouse_jsbterm -sun_workshop -xterm_clipboard +ex_extra +mouse_netterm +syntax -xterm_save +extra_search +mouse_sgr +tag_binary -farsi -mouse_sysmouse -tag_old_static 系统 vimrc 文件: "/etc/vimrc" 用户 vimrc 文件: "$HOME/.vimrc" 第二用户 vimrc 文件: "~/.vim/vimrc" 用户 exrc 文件: "$HOME/.exrc" defaults 文件: "$VIMRUNTIME/defaults.vim" $VIM 预设值: "/etc" $VIMRUNTIME 预设值: "/usr/share/vim/vim90" 编译方式: gcc -c -I. -Iproto -DHAVE_CONFIG_H -I/usr/include/ncursesw -march=nocona -msahf -mtune=generic -O2 -pipe -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 链接方式: gcc -pipe -Wl,--as-needed -o vim.exe -lm -lncursesw -liconv -lacl -lintl -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -fstack-protector-strong -L/usr/lib/perl5/core_perl/CORE -lperl -lpthread -ldl -lcrypt

使用verbose imap <TAB>可以注意到绑定了FittenAccept()函数,但是手动输入函数并无效果,仅会输出Accept. 目前使用TAB键的表现,像是会退后一些字符,或者跳转到上一行。

luozhiya commented 1 month ago

@WuJunkai2004

版本为9.0

9.0 是支持的。

手动输入函数并无效果

您有什么场景需要手动输入 FittenAccept 函数?一般用 <Tab> 更方便,不用切模式。 而且退回 normal 输入函数时,补全的提示应该也会消失吧。

退后一些字符,或者跳转到上一行

试下这个 patch。

diff --git a/plugin/fittencode.vim b/plugin/fittencode.vim
index 1f06781..72d98c1 100644
--- a/plugin/fittencode.vim
+++ b/plugin/fittencode.vim
@@ -247,7 +247,7 @@ endif
 function! FittenMapping()
     execute "inoremap" keytrans(g:fitten_trigger) '<Cmd>call CodeCompletion()<CR>'
     if !empty(g:fitten_accept_key)
-        execute 'inoremap' keytrans(g:fitten_accept_key) '<C-r>=FittenAccept()<CR>'
+        execute 'inoremap' keytrans(g:fitten_accept_key) '<C-r>=FittenAccept()<CR><Right>'
     endif
 endfunction
WuJunkai2004 commented 1 month ago

试下这个 patch。

效果依旧不变,会退后一些字符,或者跳转到上一行。
将FittenAccept()绑定到其他非\的按键上,也会产生相同效果。

更晚一点的时候,我会尝试上传录屏和我的完整vimrc文件,以供排查

WuJunkai2004 commented 1 month ago

@luozhiya

视频附件均由OneDrive进行共享。
视频前15秒演示了\和多次\表现正常,但是tab会无法输出,且导致回退。
一分钟至1:15秒处演示了将FittenAccept绑定到\上后,也会出现异常。

我的vim配置文件里面覆盖了大量的原版指令的映射,不知是否会导致上述问题/

WuJunkai2004 commented 1 month ago

经过调试,应是第186行处出现问题
屏幕截图 2024-05-09 170814
在我的系统中,normal i 无法正常运行,可能与我的配置文件中覆盖了 i 的映射有关。

WuJunkai2004 commented 1 month ago

23