Skip to content

ts-ls slow to insert completion because of "completionItem/resolve" #4757

Open
@rafael-unloan

Description

@rafael-unloan

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

I noticed that particular completion items take 1.5 - 2 secs to be inserted.
I traced it down to this:

               ;; see #3498 typescript-language-server does not provide the
               ;; proper insertText without resolving.
               (if (lsp-completion--find-workspace 'ts-ls)
                   (lsp-completion--resolve candidate)
                 candidate))

Pretty much 99% of the 1.5 - 2 sec latency is from lsp-completion--resolve
I know that this was added to support text edits (e.g. auto-imports) etc, but I wonder, how does VSCode do it and not lag for 1 - 2 secs?

Screen.Recording.2025-04-11.at.10.31.30.PM.mov

Steps to reproduce

Try inserting completion items for a Typescript project

Expected behavior

Completion should be almost instant

Which Language Server did you use?

ts-ls

OS

MacOS

Error callstack

N/A (performance issue)

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions