fannheyward / coc-rust-analyzer

rust-analyzer extension for coc.nvim
MIT License
1.13k stars 39 forks source link

Autoimport imports local modules twice #976

Closed kwinso closed 2 years ago

kwinso commented 2 years ago

When I try to import local module, it imports it twice for some reason (some other libs that not belong to my project is auto-imported normally): image Then I hit Enter: image

What's the output of :CocInfo

## versions

vim version: NVIM v0.7.0
node version: v16.14.2
coc.nvim version: 0.0.80-3dc25e03 2022-03-29 23:12:08 +0800
coc.nvim directory: /home/mouse/.vim/plugged/coc.nvim
term: xterm-256color
platform: linux

## Log of coc.nvim

2022-04-27T23:01:43.134 INFO (pid:176068) [plugin] - coc.nvim initialized with node: v16.14.2 after 414ms
2022-04-27T23:01:43.892 INFO (pid:176068) [attach] - receive notification: highlight []
2022-04-27T23:01:44.254 INFO (pid:176068) [attach] - receive notification: highlight []
2022-04-27T23:01:45.883 INFO (pid:176068) [attach] - receive notification: highlight []
2022-04-27T23:01:48.380 WARN (pid:176068) [workspace] - workspace.createStatusBarItem is deprecated, please use window.createStatusBarItem instead. 
    at Object.<anonymous> (/home/mouse/.config/coc/extensions/node_modules/coc-rls/lib/index.js:5711:39)
    at __webpack_require__ (/home/mouse/.config/coc/extensions/node_modules/coc-rls/lib/index.js:20:30)
2022-04-27T23:01:48.382 WARN (pid:176068) [workspace] - workspace.createOutputChannel is deprecated, please use window.createOutputChannel instead. 
    at Object.<anonymous> (/home/mouse/.config/coc/extensions/node_modules/coc-rls/lib/index.js:131:44)
    at Generator.next (<anonymous>)
2022-04-27T23:01:48.395 INFO (pid:176068) [services] - registered service "rust-client"
2022-04-27T23:01:48.472 INFO (pid:176068) [services] - registered service "rust-analyzer"
2022-04-27T23:01:48.472 INFO (pid:176068) [services] - Rust Analyzer Language Server state change: stopped => starting
2022-04-27T23:01:48.606 INFO (pid:176068) [extension:coc-rls] - Detected active channel: stable-x86_64-unknown-linux-gnu (since 'rust-client.channel' is unspecified)
2022-04-27T23:01:48.645 INFO (pid:176068) [language-client-index] - Language server "rust-analyzer" started with 176099
2022-04-27T23:01:48.671 INFO (pid:176068) [services] - Rust Analyzer Language Server state change: starting => running
2022-04-27T23:01:48.684 INFO (pid:176068) [services] - service rust-analyzer started
2022-04-27T23:01:48.878 INFO (pid:176068) [extension:coc-rls] - Detected active channel: stable-x86_64-unknown-linux-gnu (since 'rust-client.channel' is unspecified)
2022-04-27T23:01:49.404 INFO (pid:176068) [attach] - Request action: diagnosticList []
2022-04-27T23:01:53.188 INFO (pid:176068) [attach] - Request action: diagnosticList []
2022-04-27T23:02:00.586 INFO (pid:176068) [attach] - receive notification: highlight []
2022-04-27T23:02:02.713 INFO (pid:176068) [completion-complete] - 0 results from: 
2022-04-27T23:02:02.714 INFO (pid:176068) [attach] - Request action: doKeymap [ 'iPGJzPg==0' ]
2022-04-27T23:02:02.856 INFO (pid:176068) [attach] - Request action: doKeymap [ 'iPGJzPg==0' ]
2022-04-27T23:02:03.886 INFO (pid:176068) [completion-complete] - 3 results from: snippets,rust-client,rust-analyzer
2022-04-27T23:02:04.115 INFO (pid:176068) [completion-complete] - 3 results from: snippets,rust-client,rust-analyzer
2022-04-27T23:02:04.381 INFO (pid:176068) [completion-complete] - 3 results from: snippets,rust-client,rust-analyzer
2022-04-27T23:02:39.865 INFO (pid:176068) [completion-complete] - 0 results from: 
2022-04-27T23:02:41.341 INFO (pid:176068) [attach] - Request action: diagnosticList []
2022-04-27T23:02:41.650 INFO (pid:176068) [attach] - receive notification: highlight []
2022-04-27T23:02:43.040 INFO (pid:176068) [attach] - Request action: diagnosticList []
2022-04-27T23:02:44.500 INFO (pid:176068) [attach] - receive notification: showInfo []

What's the output of :CocCommand rust-analyzer.serverVersion image

My nvim config

fannheyward commented 2 years ago

You're using coc-rls and coc-rust-analyzer, you shouldn't use them at same time, disable one and try again.

kwinso commented 2 years ago

I've done :CocUninstall coc-rls and the problem is still present. Now in :CocInfo it says this:

2022-04-28T15:03:55.667 INFO (pid:180079) [completion-complete] - 1 results from: rust-analyzer

So as I understood, rust-analyzer is the only extension that will do completion. But "double import" still happens.

fannheyward commented 2 years ago

Can you reproduce this with VS Code + rust-analyzer? If so, it's an issue of rust-analyzer.

Set "rust-analyzer.trace.server": "verbose" in your coc-settings.json, and when reproduce this issue, checkout :CocCommand workspace.showOutput rust-analyzer.

kwinso commented 2 years ago

I tried to import the same module in VSCode, it works as expected.

The output of :CocCommand workspace.showOutput rust-analyzer (initialization and the autocompletion request/response):

[Trace - 3:22:57 PM] Sending request 'initialize - (0)'.
Params: {
    "processId": 185095,
    "rootPath": "/home/mouse/code/rust/ash",
    "rootUri": "file:///home/mouse/code/rust/ash",
    "capabilities": {
        "workspace": {
            "applyEdit": true,
            "workspaceEdit": {
                "documentChanges": true,
                "resourceOperations": [
                    "create",
                    "rename",
                    "delete"
                ],
                "failureHandling": "textOnlyTransactional",
                "normalizesLineEndings": true
            },
            "didChangeConfiguration": {
                "dynamicRegistration": true
            },
            "didChangeWatchedFiles": {
                "dynamicRegistration": true
            },
            "symbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                }
            },
            "codeLens": {
                "refreshSupport": true
            },
            "executeCommand": {
                "dynamicRegistration": true
            },
            "configuration": true,
            "fileOperations": {
                "dynamicRegistration": true,
                "didCreate": true,
                "didRename": true,
                "didDelete": true,
                "willCreate": true,
                "willRename": true,
                "willDelete": true
            },
            "semanticTokens": {
                "refreshSupport": true
            },
            "workspaceFolders": true
        },
        "textDocument": {
            "publishDiagnostics": {
                "relatedInformation": true,
                "versionSupport": true,
                "tagSupport": {
                    "valueSet": [
                        1,
                        2
                    ]
                },
                "codeDescriptionSupport": true,
                "dataSupport": true
            },
            "synchronization": {
                "dynamicRegistration": true,
                "willSave": true,
                "willSaveWaitUntil": true,
                "didSave": true
            },
            "completion": {
                "dynamicRegistration": true,
                "contextSupport": true,
                "completionItem": {
                    "snippetSupport": true,
                    "commitCharactersSupport": true,
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "deprecatedSupport": true,
                    "preselectSupport": true,
                    "insertReplaceSupport": true,
                    "tagSupport": {
                        "valueSet": [
                            1
                        ]
                    },
                    "resolveSupport": {
                        "properties": [
                            "documentation",
                            "detail",
                            "additionalTextEdits"
                        ]
                    },
                    "insertTextModeSupport": {
                        "valueSet": [
                            1,
                            2
                        ]
                    }
                },
                "completionItemKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25
                    ]
                },
                "insertTextMode": 2
            },
            "hover": {
                "dynamicRegistration": true,
                "contentFormat": [
                    "markdown",
                    "plaintext"
                ]
            },
            "signatureHelp": {
                "dynamicRegistration": true,
                "contextSupport": true,
                "signatureInformation": {
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "activeParameterSupport": true,
                    "parameterInformation": {
                        "labelOffsetSupport": true
                    }
                }
            },
            "references": {
                "dynamicRegistration": true
            },
            "definition": {
                "dynamicRegistration": true
            },
            "documentHighlight": {
                "dynamicRegistration": true
            },
            "documentSymbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "hierarchicalDocumentSymbolSupport": true,
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                },
                "labelSupport": true
            },
            "codeAction": {
                "dynamicRegistration": true,
                "isPreferredSupport": true,
                "disabledSupport": true,
                "dataSupport": true,
                "honorsChangeAnnotations": false,
                "resolveSupport": {
                    "properties": [
                        "edit"
                    ]
                },
                "codeActionLiteralSupport": {
                    "codeActionKind": {
                        "valueSet": [
                            "",
                            "quickfix",
                            "refactor",
                            "refactor.extract",
                            "refactor.inline",
                            "refactor.rewrite",
                            "source",
                            "source.organizeImports"
                        ]
                    }
                }
            },
            "codeLens": {
                "dynamicRegistration": true
            },
            "formatting": {
                "dynamicRegistration": true
            },
            "rangeFormatting": {
                "dynamicRegistration": true
            },
            "onTypeFormatting": {
                "dynamicRegistration": true
            },
            "rename": {
                "dynamicRegistration": true,
                "prepareSupport": true
            },
            "documentLink": {
                "dynamicRegistration": true,
                "tooltipSupport": true
            },
            "typeDefinition": {
                "dynamicRegistration": true
            },
            "implementation": {
                "dynamicRegistration": true
            },
            "declaration": {
                "dynamicRegistration": true
            },
            "colorProvider": {
                "dynamicRegistration": true
            },
            "foldingRange": {
                "dynamicRegistration": true,
                "rangeLimit": 5000,
                "lineFoldingOnly": true
            },
            "selectionRange": {
                "dynamicRegistration": true
            },
            "callHierarchy": {
                "dynamicRegistration": true
            },
            "linkedEditingRange": {
                "dynamicRegistration": true
            },
            "semanticTokens": {
                "dynamicRegistration": true,
                "tokenTypes": [
                    "namespace",
                    "type",
                    "class",
                    "enum",
                    "interface",
                    "struct",
                    "typeParameter",
                    "parameter",
                    "variable",
                    "property",
                    "enumMember",
                    "event",
                    "function",
                    "method",
                    "macro",
                    "keyword",
                    "modifier",
                    "comment",
                    "string",
                    "number",
                    "regexp",
                    "operator"
                ],
                "tokenModifiers": [
                    "declaration",
                    "definition",
                    "readonly",
                    "static",
                    "deprecated",
                    "abstract",
                    "async",
                    "modification",
                    "documentation",
                    "defaultLibrary"
                ],
                "formats": [
                    "relative"
                ],
                "requests": {
                    "range": true,
                    "full": {
                        "delta": true
                    }
                },
                "multilineTokenSupport": false,
                "overlappingTokenSupport": false
            }
        },
        "window": {
            "showMessage": {
                "messageActionItem": {
                    "additionalPropertiesSupport": true
                }
            },
            "showDocument": {
                "support": true
            },
            "workDoneProgress": true
        },
        "general": {
            "regularExpressions": {
                "engine": "ECMAScript",
                "version": "ES2020"
            },
            "markdown": {
                "parser": "marked",
                "version": "4.0.10"
            }
        },
        "experimental": {
            "snippetTextEdit": true,
            "resolveCodeAction": true,
            "serverStatusNotification": true,
            "commands": {
                "commands": [
                    "rust-analyzer.runSingle",
                    "rust-analyzer.debugSingle",
                    "rust-analyzer.showReferences",
                    "rust-analyzer.gotoLocation",
                    "editor.action.triggerParameterHints"
                ]
            }
        }
    },
    "initializationOptions": {
        "enable": true,
        "terminal": {
            "startinsert": false
        },
        "debug": {
            "runtime": "termdebug",
            "vimspector": {
                "configuration": {
                    "name": "launch"
                }
            }
        },
        "inlayHints": {
            "enable": true,
            "typeHintsSeparator": "‣",
            "chainingHintsSeparator": "‣",
            "refreshOnInsertMode": false,
            "renderColons": true,
            "maxLength": 25,
            "typeHints": true,
            "chainingHints": true,
            "closureReturnTypeHints": false,
            "reborrowHints": false,
            "lifetimeElisionHints": {
                "enable": "never",
                "useParameterNames": false
            },
            "hideNamedConstructorHints": false
        },
        "trace": {
            "server": "verbose"
        },
        "updates": {
            "prompt": true,
            "checkOnStartup": true,
            "channel": "stable"
        },
        "assist": {
            "exprFillDefault": "todo",
            "importGranularity": "crate",
            "importEnforceGranularity": false,
            "importPrefix": "plain",
            "importGroup": true,
            "allowMergingIntoGlobImports": true
        },
        "cache": {
            "warmup": true
        },
        "callInfo": {
            "full": true
        },
        "cargo": {
            "autoreload": true,
            "allFeatures": false,
            "unsetTest": [
                "core"
            ],
            "features": [],
            "runBuildScripts": true,
            "useRustcWrapperForBuildScripts": true,
            "noDefaultFeatures": false,
            "noSysroot": false
        },
        "checkOnSave": {
            "enable": true,
            "allTargets": true,
            "command": "check",
            "extraArgs": []
        },
        "completion": {
            "addCallArgumentSnippets": true,
            "addCallParenthesis": true,
            "snippets": {
                "Arc::new": {
                    "postfix": "arc",
                    "body": "Arc::new(${receiver})",
                    "requires": "std::sync::Arc",
                    "description": "Put the expression into an `Arc`",
                    "scope": "expr"
                },
                "Rc::new": {
                    "postfix": "rc",
                    "body": "Rc::new(${receiver})",
                    "requires": "std::rc::Rc",
                    "description": "Put the expression into an `Rc`",
                    "scope": "expr"
                },
                "Box::pin": {
                    "postfix": "pinbox",
                    "body": "Box::pin(${receiver})",
                    "requires": "std::boxed::Box",
                    "description": "Put the expression into a pinned `Box`",
                    "scope": "expr"
                },
                "Ok": {
                    "postfix": "ok",
                    "body": "Ok(${receiver})",
                    "description": "Wrap the expression in a `Result::Ok`",
                    "scope": "expr"
                },
                "Err": {
                    "postfix": "err",
                    "body": "Err(${receiver})",
                    "description": "Wrap the expression in a `Result::Err`",
                    "scope": "expr"
                },
                "Some": {
                    "postfix": "some",
                    "body": "Some(${receiver})",
                    "description": "Wrap the expression in an `Option::Some`",
                    "scope": "expr"
                }
            },
            "postfix": {
                "enable": true
            },
            "autoimport": {
                "enable": true
            },
            "autoself": {
                "enable": true
            },
            "privateEditable": {
                "enable": false
            }
        },
        "diagnostics": {
            "enable": true,
            "enableExperimental": false,
            "disabled": [],
            "remapPrefix": {},
            "warningsAsHint": [],
            "warningsAsInfo": []
        },
        "experimental": {
            "procAttrMacros": true
        },
        "files": {
            "watcher": "client",
            "excludeDirs": []
        },
        "highlightRelated": {
            "references": true,
            "exitPoints": true,
            "breakPoints": true,
            "yieldPoints": true
        },
        "highlighting": {
            "strings": true
        },
        "hover": {
            "documentation": true,
            "linksInHover": true
        },
        "hoverActions": {
            "enable": true
        },
        "joinLines": {
            "joinElseIf": true,
            "removeTrailingComma": true,
            "unwrapTrivialBlock": true,
            "joinAssignments": true
        },
        "lens": {
            "enable": true,
            "implementations": true,
            "run": true,
            "methodReferences": false,
            "references": false,
            "enumVariantReferences": false,
            "forceCustomCommands": true
        },
        "linkedProjects": [],
        "notifications": {
            "cargoTomlNotFound": true
        },
        "primeCaches": {
            "numThreads": 0
        },
        "procMacro": {
            "enable": true,
            "ignored": {}
        },
        "runnables": {
            "cargoExtraArgs": []
        },
        "rustfmt": {
            "extraArgs": [],
            "enableRangeFormatting": false
        },
        "workspace": {
            "symbol": {
                "search": {
                    "scope": "workspace",
                    "kind": "only_types",
                    "limit": 128
                }
            }
        }
    },
    "trace": "verbose",
    "workspaceFolders": [
        {
            "uri": "file:///home/mouse/code/rust/ash",
            "name": "ash"
        }
    ],
    "locale": "en_US",
    "clientInfo": {
        "name": "coc.nvim",
        "version": "0.0.80"
    }
}

[Trace - 3:22:57 PM] Received response 'initialize - (0)' in 7ms.
Result: {
    "capabilities": {
        "textDocumentSync": {
            "openClose": true,
            "change": 2,
            "save": {}
        },
        "selectionRangeProvider": true,
        "hoverProvider": true,
        "completionProvider": {
            "resolveProvider": true,
            "triggerCharacters": [
                ":",
                ".",
                "'"
            ]
        },
        "signatureHelpProvider": {
            "triggerCharacters": [
                "(",
                ",",
                "<"
            ]
        },
        "definitionProvider": true,
        "typeDefinitionProvider": true,
        "implementationProvider": true,
        "referencesProvider": true,
        "documentHighlightProvider": true,
        "documentSymbolProvider": true,
        "workspaceSymbolProvider": true,
        "codeActionProvider": {
            "codeActionKinds": [
                "",
                "quickfix",
                "refactor",
                "refactor.extract",
                "refactor.inline",
                "refactor.rewrite"
            ],
            "resolveProvider": true
        },
        "codeLensProvider": {
            "resolveProvider": true
        },
        "documentFormattingProvider": true,
        "documentRangeFormattingProvider": false,
        "documentOnTypeFormattingProvider": {
            "firstTriggerCharacter": "=",
            "moreTriggerCharacter": [
                ".",
                ">",
                "{"
            ]
        },
        "renameProvider": {
            "prepareProvider": true
        },
        "foldingRangeProvider": true,
        "declarationProvider": true,
        "workspace": {
            "fileOperations": {
                "willRename": {
                    "filters": [
                        {
                            "scheme": "file",
                            "pattern": {
                                "glob": "**/*.rs",
                                "matches": "file"
                            }
                        },
                        {
                            "scheme": "file",
                            "pattern": {
                                "glob": "**",
                                "matches": "folder"
                            }
                        }
                    ]
                }
            }
        },
        "callHierarchyProvider": true,
        "semanticTokensProvider": {
            "legend": {
                "tokenTypes": [
                    "comment",
                    "keyword",
                    "string",
                    "number",
                    "regexp",
                    "operator",
                    "namespace",
                    "type",
                    "struct",
                    "class",
                    "interface",
                    "enum",
                    "enumMember",
                    "typeParameter",
                    "function",
                    "method",
                    "property",
                    "macro",
                    "variable",
                    "parameter",
                    "angle",
                    "arithmetic",
                    "attribute",
                    "attributeBracket",
                    "bitwise",
                    "boolean",
                    "brace",
                    "bracket",
                    "builtinAttribute",
                    "builtinType",
                    "character",
                    "colon",
                    "comma",
                    "comparison",
                    "constParameter",
                    "derive",
                    "dot",
                    "escapeSequence",
                    "formatSpecifier",
                    "generic",
                    "label",
                    "lifetime",
                    "logical",
                    "macroBang",
                    "operator",
                    "parenthesis",
                    "punctuation",
                    "selfKeyword",
                    "selfTypeKeyword",
                    "semicolon",
                    "typeAlias",
                    "toolModule",
                    "union",
                    "unresolvedReference"
                ],
                "tokenModifiers": [
                    "documentation",
                    "declaration",
                    "definition",
                    "static",
                    "abstract",
                    "deprecated",
                    "readonly",
                    "defaultLibrary",
                    "async",
                    "attribute",
                    "callable",
                    "constant",
                    "consuming",
                    "controlFlow",
                    "crateRoot",
                    "injected",
                    "intraDocLink",
                    "library",
                    "mutable",
                    "public",
                    "reference",
                    "trait",
                    "unsafe"
                ]
            },
            "range": true,
            "full": {
                "delta": true
            }
        },
        "inlayHintProvider": true,
        "experimental": {
            "externalDocs": true,
            "hoverRange": true,
            "joinLines": true,
            "matchingBrace": true,
            "moveItem": true,
            "onEnter": true,
            "openCargoToml": true,
            "parentModule": true,
            "runnables": {
                "kinds": [
                    "cargo"
                ]
            },
            "ssr": true,
            "workspaceSymbolScopeKindFiltering": true
        }
    },
    "serverInfo": {
        "name": "rust-analyzer",
        "version": "b5d7a712e 2022-04-25 stable"
    }
}

<SOME OTHER LOGS>

[Trace - 3:23:16 PM] Sending request 'completionItem/resolve - (21)'.
Params: {
    "label": "Command (use commands::Command)",
    "kind": 8,
    "deprecated": false,
    "sortText": "fffffff0",
    "filterText": "Command",
    "textEdit": {
        "newText": "Command",
        "insert": {
            "start": {
                "line": 9,
                "character": 4
            },
            "end": {
                "line": 9,
                "character": 8
            }
        },
        "replace": {
            "start": {
                "line": 9,
                "character": 4
            },
            "end": {
                "line": 9,
                "character": 8
            }
        }
    },
    "additionalTextEdits": [
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 0
                },
                "end": {
                    "line": 2,
                    "character": 0
                }
            },
            "newText": "use commands::Command;"
        },
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 0
                },
                "end": {
                    "line": 2,
                    "character": 0
                }
            },
            "newText": "\n"
        }
    ],
    "data": {
        "position": {
            "textDocument": {
                "uri": "file:///home/mouse/code/rust/ash/src/main.rs"
            },
            "position": {
                "line": 9,
                "character": 8
            }
        },
        "imports": [
            {
                "full_import_path": "commands::Command",
                "imported_name": "Command"
            }
        ]
    }
}

[Trace - 3:23:16 PM] Received response 'completionItem/resolve - (21)' in 10ms.
Result: {
    "label": "Command (use commands::Command)",
    "kind": 8,
    "deprecated": false,
    "sortText": "fffffff0",
    "filterText": "Command",
    "textEdit": {
        "newText": "Command",
        "insert": {
            "start": {
                "line": 9,
                "character": 4
            },
            "end": {
                "line": 9,
                "character": 8
            }
        },
        "replace": {
            "start": {
                "line": 9,
                "character": 4
            },
            "end": {
                "line": 9,
                "character": 8
            }
        }
    },
    "additionalTextEdits": [
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 0
                },
                "end": {
                    "line": 2,
                    "character": 0
                }
            },
            "newText": "use commands::Command;"
        },
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 0
                },
                "end": {
                    "line": 2,
                    "character": 0
                }
            },
            "newText": "\n"
        },
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 0
                },
                "end": {
                    "line": 2,
                    "character": 0
                }
            },
            "newText": "use commands::Command;"
        },
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 0
                },
                "end": {
                    "line": 2,
                    "character": 0
                }
            },
            "newText": "\n"
        }
    ]
}
fannheyward commented 2 years ago

Reproduced, but looks like it's rust-analyzer's issue:

"additionalTextEdits": [
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 0
                },
                "end": {
                    "line": 2,
                    "character": 0
                }
            },
            "newText": "use commands::Command;"
        },
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 0
                },
                "end": {
                    "line": 2,
                    "character": 0
                }
            },
            "newText": "\n"
        },
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 0
                },
                "end": {
                    "line": 2,
                    "character": 0
                }
            },
            "newText": "use commands::Command;"
        },
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 0
                },
                "end": {
                    "line": 2,
                    "character": 0
                }
            },
            "newText": "\n"
        }
    ]

RA returns two use commands::Command; textEdits, coc/coc-rust-analyzer applied them.

kwinso commented 2 years ago

Oh, then I should probably go to rust-analyzers repo with my issue. Thanks for help!

alansartorio commented 2 years ago

I think I found where this problem is coming from, I opened an issue in coc.nvim here.