neoclide / coc-java

Java extension for coc.nvim
Eclipse Public License 1.0
447 stars 40 forks source link

Organize import failing when selecting from multiple values #241

Closed tbates1996 closed 10 months ago

tbates1996 commented 1 year ago

I'm failing to run my organize import command nnoremap <silent> <leader>o :silent! call CocActionAsync('organizeImport')<CR> after upgrading my dev environment. When imports have more than one option, I get a Error log in my coc logs which I've pasted below.

Steps to reproduce:

  1. Start up neovim and load a java buffer with coc-java running
  2. Execute command from above to call organizeImport
  3. This window pops up image
  4. Select an option.
  5. Nothing happens and the error message from below is logged.
## versions

vim version: NVIM v0.8.2
node version: v18.13.0
coc.nvim version: 0.0.82-b7375d5f 2023-01-30 05:09:03 +0800
coc.nvim directory: /Users/tsb/.vim/plugged/coc.nvim
term: tmux
platform: darwin

## Log of coc.nvim

2023-01-31T13:21:16.465 INFO (pid:43590) [attach] - receive notification: doAutocmd [
  2,
  {
    regcontents: [ 'import com.google.inject.Inject;' ],
    visual: false,
    inclusive: false,
    regname: '',
    operator: 'd',
    regtype: 'V'
  },
  4,
  1000
]
2023-01-31T13:21:19.244 INFO (pid:43590) [attach] - receive notification: organizeImport []
2023-01-31T13:21:19.608 ERROR (pid:43590) [attach] - Error on notification organizeImport TypeError: Cannot destructure property 'edit' of 't' as it is null.
    at Km.applyCodeAction (/Users/-/.vim/plugged/coc.nvim/build/index.js:261:11566)
    at async Km.organizeImport (/Users/-/.vim/plugged/coc.nvim/build/index.js:261:9450)
    at async _b.cocAction (/Users/-/.vim/plugged/coc.nvim/build/index.js:281:46242)
    at async EventEmitter.<anonymous> (/Users/-/.vim/plugged/coc.nvim/build/index.js:281:47836)
mikelue commented 1 year ago

I've faced the same issue, with additional information:

  1. The mode would be visual mode
  2. Enter key is unable to make proper import action

圖片

Any comment would be appreciated. The COC plugin is awesome, thanks a lot.


My Config:

{
    "list.normalMappings": {
        "q": "do:exit"
    },
    "outline.splitCommand": "leftabove 40vs",
    "callHierarchy.splitCommand": "belowright 80vs",
    "tabnine.triggers": [
        "#"
    ],
    "[java]": {
        "suggest.autoTrigger": "none"
    },
    "java.configuration.runtimes": [
        {
            "name": "JavaSE-1.8",
            "path": "/usr/lib/jvm/java-8-openjdk-amd64"
        },
        {
            "name": "JavaSE-17",
            "path": "/usr/lib/jvm/java-17-openjdk-amd64"
        }
    ],
    "java.jdt.ls.java.home": "/usr/lib/jvm/java-17-openjdk-amd64",
    "java.jdt.ls.lombokSupport.enabled": false,
    "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms256m -Xlog:disable -javaagent:${userHome}/Code/ycmd/lombok.jar",
    "java.completion.importOrder": [
        "java",
        "javax",
        "org.springframework",
        "org",
        "com",
        "guru.mikelue",
        "com.bizzan",
        "",
        "#"
    ],
    "java.sources.organizeImports.starThreshold": 5,
    "java.sources.organizeImports.staticStarThreshold": 3,
    "java.compile.nullAnalysis.mode": "disabled",
    "java.completion.favoriteStaticMembers": [
        "org.assertj.core.api.Assertions.*",
        "org.assertj.core.api.Assumptions.*",
        "mockit.*",
        "org.hamcrest.Matchers.*",
        "org.junit.jupiter.api.Assertions.*",
        "org.junit.jupiter.api.Assumptions.*",
        "org.junit.jupiter.api.DynamicContainer.*",
        "org.junit.jupiter.api.DynamicTest.*",
        "org.mockito.Mockito.*",
        "org.mockito.ArgumentMatchers.*",
        "org.mockito.Answers.*",
        "org.junit.Assert.*",
        "org.junit.Assume.*"
    ],
    "java.imports.gradle.wrapper.checksums": [
        {
            "sha256": "49f50491cdc25871a296ca10deb3ae69f81e26b0d7fa968d93d169ec15ed8fd7",
            "allowed": false
        }
    ],
    "java.format.settings.url": "file:///home/mike/Code/ycmd/eclipse-formatter.xml"
}

My VIM info:

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled May 10 2022 08:40:37)
Included patches: 1-749
Modified by team+vim@tracker.debian.org
Compiled by team+vim@tracker.debian.org
Huge version without GUI.  Features included (+) or not (-):
+acl               +channel           +cscope            +ex_extra          -hangul_input      +linebreak         +mouse_dec         -mzscheme          +profile           +sodium            -tcl               +user_commands     +wildmenu          
+arabic            +cindent           +cursorbind        +extra_search      +iconv             +lispindent        +mouse_gpm         +netbeans_intg     -python            -sound             +termguicolors     +vartabs           +windows           
+autocmd           -clientserver      +cursorshape       -farsi             +insert_expand     +listcmds          -mouse_jsbterm     +num64             +python3           +spell             +terminal          +vertsplit         +writebackup       
+autochdir         -clipboard         +dialog_con        +file_in_path      +ipv6              +localmap          +mouse_netterm     +packages          +quickfix          +startuptime       +terminfo          +vim9script        -X11               
-autoservername    +cmdline_compl     +diff              +find_in_path      +job               -lua               +mouse_sgr         +path_extra        +reltime           +statusline        +termresponse      +viminfo           -xfontset          
-balloon_eval      +cmdline_hist      +digraphs          +float             +jumplist          +menu              -mouse_sysmouse    -perl              +rightleft         -sun_workshop      +textobjects       +virtualedit       -xim               
+balloon_eval_term +cmdline_info      -dnd               +folding           +keymap            +mksession         +mouse_urxvt       +persistent_undo   -ruby              +syntax            +textprop          +visual            -xpm               
-browse            +comments          -ebcdic            -footer            +lambda            +modify_fname      +mouse_xterm       +popupwin          +scrollbind        +tag_binary        +timers            +visualextra       -xsmp              
++builtin_terms    +conceal           +emacs_tags        +fork()            +langmap           +mouse             +multi_byte        +postscript        +signs             -tag_old_static    +title             +vreplace          -xterm_clipboard   
+byte_offset       +cryptv            +eval              +gettext           +libcall           -mouseshape        +multi_lang        +printer           +smartindent       -tag_any_white     -toolbar           +wildignore        -xterm_save        
   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-cdpF6P/vim-9.0.0749=. -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 -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/python3.10/config-3.10-x86_64-linux-gnu -lpython3.10 -lcrypt -ldl -lm -lm 
chemzqm commented 10 months ago

Fixed on coc-java@1.15.2 and latest coc.nvim.