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
Eval did not return a valid python object, on signature popup #3870
Comments
So the relevant parts of the logs are:
That's the first parameter. The The way to calculate this is here.
Something's off in this calculation when the above is the |
Here's a quick and dirty fix: diff --git a/ycmd/utils.py b/ycmd/utils.py
index 74c352b2..55937915 100644
--- a/ycmd/utils.py
+++ b/ycmd/utils.py
@@ -163,8 +163,11 @@ def ByteOffsetToCodepointOffset( line_value, byte_offset ):
This method converts the |byte_offset|, which is a 1-based utf-8 byte offset,
into a 1-based codepoint offset in the unicode string |line_value|."""
- byte_line_value = ToBytes( line_value )
- return len( ToUnicode( byte_line_value[ : byte_offset - 1 ] ) ) + 1
+ if byte_offset == 0:
+ return 0
+ else:
+ byte_line_value = ToBytes( line_value )
+ return len( ToUnicode( byte_line_value[ : byte_offset - 1 ] ) ) + 1
def CodepointOffsetToByteOffset( unicode_line_value, codepoint_offset ):
@@ -179,8 +182,11 @@ def CodepointOffsetToByteOffset( unicode_line_value, codepoint_offset ):
version of |unicode_line_value|."""
# Should be a no-op, but in case someone passes a bytes instance.
- unicode_line_value = ToUnicode( unicode_line_value )
- return len( ToBytes( unicode_line_value[ : codepoint_offset - 1 ] ) ) + 1
+ if codepoint_offset == 0:
+ return 0
+ else:
+ unicode_line_value = ToUnicode( unicode_line_value )
+ return len( ToBytes( unicode_line_value[ : codepoint_offset - 1 ] ) ) + 1
def GetUnusedLocalhostPort(): The backtrace was caused by miscalculating offset
On the other hand, phpactor should really send |
Yeah, if the php lang server used the newer signature help response, then it would work better. As it uses the older one without the offsets we just have to guess, and we guess wrong. But yeah, are we saying that our whole calculation is off ? CodepointOffsetToByteOffset is supposed to only work with 1-based offsets..... right ?!
|
From the
So this specifically says the output is 0-based. Changing it to 1-based is an API break, but one we might want to make. Here's a patch I think is enough to solve this: diff --git a/ycmd/completers/language_server/language_server_completer.py b/ycmd/completers/language_server/language_server_completer.py
index cdbafa18c..14b61cd5c 100644
--- a/ycmd/completers/language_server/language_server_completer.py
+++ b/ycmd/completers/language_server/language_server_completer.py
@@ -1524,7 +1524,7 @@ class LanguageServerCompleter( Completer ):
for arg in sig[ 'parameters' ]:
arg_label = arg[ 'label' ]
if not isinstance( arg_label, list ):
- begin = sig[ 'label' ].find( arg_label, end )
+ begin = sig[ 'label' ].find( arg_label, end ) + 1 # 1-based
end = begin + len( arg_label )
else:
begin, end = arg_label Alternatively: diff --git a/ycmd/completers/language_server/language_server_completer.py b/ycmd/completers/language_server/language_server_completer.py
index cdbafa18c..151bc8307 100644
--- a/ycmd/completers/language_server/language_server_completer.py
+++ b/ycmd/completers/language_server/language_server_completer.py
@@ -1529,8 +1529,8 @@ class LanguageServerCompleter( Completer ):
else:
begin, end = arg_label
arg[ 'label' ] = [
- utils.CodepointOffsetToByteOffset( sig_label, begin ),
- utils.CodepointOffsetToByteOffset( sig_label, end ) ]
+ utils.CodepointOffsetToByteOffset( sig_label, begin + 1 ) - 1,
+ utils.CodepointOffsetToByteOffset( sig_label, end + 1 ) - 1 ]
result.setdefault( 'activeParameter', 0 )
result.setdefault( 'activeSignature', 0 )
return result |
now it works like this - no errors but something wrong with offsets |
The first offset is definitely wrong. That's what I've been complaining about, with phpactor making us guess. I've created phpactor/phpactor#1235, which should resolve the rest of the issue. |
Fixed a while ago. The rest is up to phpactor. |
btw i just stopped use php |
Issue Prelude
Please complete these steps and check these boxes (by putting an
x
insidethe brackets) before filing your issue:
[Frequently Asked Questions][faq] section.
about to report and couldn't find an answer to my problem. ([Example Google
search.][search])
vim --version
.:YcmDebugInfo
.the
:YcmToggleLogs
command.version) I am using.
my issue, using
vim -Nu /path/to/YCM/vimrc_ycm_minimal
, including what Iexpected to happen and what actually happened.
of
install.py
(orcmake
/make
/ninja
) including its invocationthat any help I receive is a selfless, heartfelt gift of their free time. I
know I am not entitled to anything and will be polite and courteous.
actually perform all of these steps.
Thank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.
Issue Details
vim -Nu /path/to/YCM/ycm_vimrc_minimal
:edit index.php
array_slice(
where index.php looks like:
before editing
after
" only adding config for custom language server (-vvv for logging)
What did you expect to happen?
Ycm show signature popup and continue to work without error messages
What actually happened?
With appearance of signatute popup i see bunch of error messages, and signatute popup not disappering
[vim error messages] (https://gist.github.com/TuM0xA-S/2848781a7503eb0b48fe487227ae00b4)
Diagnostic data
Output of
vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Feb 10 2021 18:06:52)
Included patches: 1-2489
Compiled by Brenton Horne
Huge version with GTK2 GUI. Features included (+) or not (-):
+acl -farsi +mouse_sgr +tag_binary
+arabic +file_in_path -mouse_sysmouse -tag_old_static
+autocmd +find_in_path +mouse_urxvt -tag_any_white
+autochdir +float +mouse_xterm -tcl
-autoservername +folding +multi_byte +termguicolors
+balloon_eval -footer +multi_lang +terminal
+balloon_eval_term +fork() -mzscheme +terminfo
+browse +gettext +netbeans_intg +termresponse
++builtin_terms -hangul_input +num64 +textobjects
+byte_offset +iconv +packages +textprop
+channel +insert_expand +path_extra +timers
+cindent +ipv6 +perl/dyn +title
+clientserver +job +persistent_undo +toolbar
+clipboard +jumplist +popupwin +user_commands
+cmdline_compl +keymap +postscript +vartabs
+cmdline_hist +lambda +printer +vertsplit
+cmdline_info +langmap +profile +virtualedit
+comments +libcall +python/dyn +visual
+conceal +linebreak +python3/dyn +visualextra
+cryptv +lispindent +quickfix +viminfo
+cscope +listcmds +reltime +vreplace
+cursorbind +localmap +rightleft +wildignore
+cursorshape -lua +ruby/dyn +wildmenu
+dialog_con_gui +menu +scrollbind +windows
+diff +mksession +signs +writebackup
+digraphs +modify_fname +smartindent +X11
+dnd +mouse +sound -xfontset
-ebcdic +mouseshape +spell +xim
+emacs_tags +mouse_dec +startuptime +xpm
+eval +mouse_gpm +statusline +xsmp_interact
+ex_extra -mouse_jsbterm -sun_workshop +xterm_clipboard
+extra_search +mouse_netterm +syntax -xterm_save
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "
/.vim/vimrc"/.vim/gvimrc"user exrc file: "$HOME/.exrc"
system gvimrc file: "/etc/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "
defaults file: "$VIMRUNTIME/defaults.vim"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0 -pthread -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.32/core_perl/CORE -L/usr/local/lib -Wl,--as-needed -o vim -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lelf -lcanberra -lacl -lattr -lgpm -ldl -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.32/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib -L/usr/lib/perl5/5.32/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc
Output of
YcmDebugInfo
Printing YouCompleteMe debug information...
-- Resolve completions: Up front
-- Client logfile: /tmp/ycm_a8330ukj.log
-- Server Python interpreter: /usr/bin/python3
-- Server Python version: 3.9.2
-- Server has Clang support compiled in: False
-- Clang version: None
-- No extra configuration file found
-- GenericLSP completer debug information:
-- phpCompleter running
-- phpCompleter process ID: 4803
-- phpCompleter executable: ['/home/tum0xa/src/phpactor/bin/phpactor', 'language-server', '-vvv']
-- phpCompleter logfiles:
-- /tmp/phpcompleter_stderrim5ydxfr.log
-- phpCompleter Server State: Initialized
-- phpCompleter Project Directory: /home/tum0xa/src/phpsite
-- phpCompleter Settings: {}
-- Server running at: http://127.0.0.1:35485
-- Server process ID: 4790
-- Server logfiles:
-- /tmp/ycmd_35485_stdout_u4ihzteu.log
-- /tmp/ycmd_35485_stderr_c2r_0k5v.log
Output of
YcmDiags
No warnings or errors detected.
Output of
git rev-parse HEAD
in YouCompleteMe installation directorya3d0223
Vim error messages
https://gist.github.com/TuM0xA-S/2848781a7503eb0b48fe487227ae00b4
Contents of YCM, ycmd and completion engine logfiles
ycm:
https://gist.github.com/TuM0xA-S/01e1d584f313ed8a0a1d9af66420f32f
https://gist.github.com/TuM0xA-S/a02e0c5cb03607dc054887871a1bea19
https://gist.github.com/TuM0xA-S/0dc339a57805d67f4c981c411a429c84
language server:
https://gist.github.com/TuM0xA-S/b46fff7f0cd7279caa2d84412f1895b6
OS version, distribution, etc.
Linux 5.11.2-1-MANJARO GNU/Linux
Output of build/install commands
./install.py --go-completer --clangd-completer
The text was updated successfully, but these errors were encountered: