Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/lsp/semantic: avoid doing semantic tokens for large files
LSP (and gopls) support both full-file semantic token requests and requests for just a range, typically roughly what's visible to the user. It can be slow to produce the full set for a very large file, so this code now responds with an error if the file is bigger than 100,000 bytes. After getting this error, vscode, at least, will stop asking for full requests and use range requests. Alternatively, server capabilities could say gopls never responds to full-file requests, but doing that doesn't stop vscode from asking for them. Another possibility would be to fix a time limit (like 8ms) for how long to spend generating full-file semantic tokens. That's tricky to get right, but one could instead generate an error when there are more than 4,000 semantic tokens (on my laptop, that's about 8ms.) Large files are unusual; a simple size limit seems adequate for now. Change-Id: Ieea0d16aad6e37cc4f14b1a6a7116a4e41197aae Reviewed-on: https://go-review.googlesource.com/c/tools/+/307729 Run-TryBot: Peter Weinberger <pjw@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Peter Weinberger <pjw@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
- Loading branch information