ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.47k stars 2.81k forks source link

Diagnostic line display has "Press ENTER or type command to continue" for some long golang errors #4182

Closed JacobLeach closed 1 year ago

JacobLeach commented 1 year ago

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your issue:

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

The diagnostic line echos do not seem to handle tab characters which Go uses in error messages. When ycm truncates the message: https://github.com/ycm-core/YouCompleteMe/blob/4f1dcf4f971517b5a41d420b3671259f917e3827/python/ycm/vimsupport.py#L750-L764

the message is less than the vim width but it appears vim's echo command is turning the tabs into multiple spaces which causes the message length to exceed the vim width and that causes the "Press ENTER or type command to continue" message.

I added message = message.replace( '\t', ' ' ) right after https://github.com/ycm-core/YouCompleteMe/blob/4f1dcf4f971517b5a41d420b3671259f917e3827/python/ycm/vimsupport.py#L753C5-L753C43 and it resolved the issue but I've not been able to find any reliable information on how vim handles tab characters in echos so I'm unsure if there is a better method of handling this.

  1. Create main.go with the following contents:
package main

func veryLongFunction(
    str1 string,
    str2 string,
    str3 string,
    str4 string,
    str5 string,
    str6 string,
    str7 string,
    str8 string,
    str9 string,
    str10 string,
    str11 string,
    str12 string,
) string {
    return ""
}

func main() {
    veryLongFunction()
}
  1. vim -Nu YouCompleteMe/vimrc_ycm_minimal main.go
  2. Move the cursor over the veryLongFunction() line in the main() function

Diagnostic display that properly truncates to avoid "Press ENTER or type command to continue"

ycm_error

Diagnostic data

Output of vim --version

test@660f0669253b:~$ vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Aug 18 2023 04:12:26)
Included patches: 1-3995, 4563, 4646, 4774, 4895, 4899, 4901, 4919, 213
Modified by team+vim@tracker.debian.org
Compiled by team+vim@tracker.debian.org
Huge version without GUI.  Features included (+) or not (-):
+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              +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           +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          +ruby              +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
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -Wdate-time -g -O2 -ffile-prefix-map=/build/vim-Zf4SpW/vim-8.2.3995=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lm -ltinfo -lselinux -lsodium -lacl -lattr -lgpm -L/usr/lib -llua5.2 -Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.34/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python3.10/config-3.10-x86_64-linux-gnu -lpython3.10 -lcrypt -ldl -lm -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-3.0 -lm -L/usr/lib
test@660f0669253b:~$

Output of YcmDebugInfo

Printing YouCompleteMe debug information...
-- Resolve completions: Up front
-- Client logfile: /tmp/ycm_9mo7d7f_.log
-- Server Python interpreter: /usr/bin/python3
-- Server Python version: 3.10.12
-- Server has Clang support compiled in: False
-- Clang version: None
-- No extra configuration file found
-- Go completer debug information:
--   gopls running
--   gopls process ID: 8149
--   gopls executable: ['/home/test/YouCompleteMe/third_party/ycmd/third_party/go/bin/gopls', '-logfile', '/tmp/gopls_stderr5qnw5eur.log', '-rpc.trace']
--   gopls logfiles:
--     /tmp/gopls_stderr5qnw5eur.log
--   gopls Server State: Initialized
--   gopls Project Directory: /home/test
--   gopls Settings: {
--   "hints": {
--     "assignVariableTypes": true,
--     "compositeLiteralFields": true,
--     "compositeLiteralTypes": true,
--     "constantValues": true,
--     "functionTypeParameters": true,
--     "parameterNames": true,
--     "rangeVariableTypes": true
--   },
--   "hoverKind": "Structured",
--   "semanticTokens": true
-- }
-- Server running at: http://127.0.0.1:51791
-- Server process ID: 8137
-- Server logfiles:
--   /tmp/ycmd_51791_stdout_j2lit44i.log
--   /tmp/ycmd_51791_stderr_olvaqqmp.log
-- Semantic highlighting supported: True
-- Virtual text supported: False
-- Popup windows supported: True
Press ENTER or type command to continue

Output of YcmDiags

main.go
main.go|21 col 19 error| not enough arguments in call to veryLongFunction have () want (string, string, string, string, string, string, string, string, string, string, string, string) [WrongArgCount]
[Location List] ycm_loc                                                                                                                                         1,1             All
"[Location List]" line 1 of 1 --100%-- col 1

Output of git rev-parse HEAD in YouCompleteMe installation directory

test@660f0669253b:~/YouCompleteMe$ git rev-parse HEAD
4f1dcf4f971517b5a41d420b3671259f917e3827

Contents of YCM, ycmd and completion engine logfiles

https://gist.github.com/JacobLeach/fd124aa062c0c1951c109ddf441ea29e

OS version, distribution, etc.

I reproduced for this issue in an interactive ubuntu container:

test@660f0669253b:~$ cat /etc/*ease
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

Output of build/install commands

N/A

puremourning commented 1 year ago

Thanks for the detailed report.

Yeah I can see that would be annoying. We should strip tabs out of the diagnostics.

Fancy making a PR ? :)

BTW as a workaround, you could use virtual text for diagnostics display: https://github.com/ycm-core/YouCompleteMe#the-gycm_echo_current_diagnostic-option