Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(workspace) symbol picker is limited to the first 128 elements #1437

Closed
poliorcetics opened this issue Jan 4, 2022 · 8 comments · Fixed by #5055
Closed

(workspace) symbol picker is limited to the first 128 elements #1437

poliorcetics opened this issue Jan 4, 2022 · 8 comments · Fixed by #5055
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@poliorcetics
Copy link
Contributor

After #1041 it is now possible to search for symbols in a whole workspace. Problem is, there are often a lot more symbols than the default (from where) 128 displayed symbols and the list is not updated as I enter text.

Reproduction steps

  1. Go to the helix repository
  2. Open helix-lsp/src/client.rs
  3. Open the symbol picker Space+s
  4. There should be aroud 50 symbols (48 on dbaed0b for me)
  5. Searching for workspace_symbols goes to line 769 for me.
  6. Open the workspace symbol picker Space+Shift+s (Space+S)
  7. Search for workspace_symbols
  8. There is no result and the prompt displays 0/128

Environment

  • Platform: Linux Ubuntu 21.10
  • Helix version: v0.5.0-331-gdbaed0b on git describe
~/.cache/helix/helix.log

A llittle heavy since I used -vvv so I uploaded a file instead

helix.log

@poliorcetics poliorcetics added the C-bug Category: This is a bug label Jan 4, 2022
@kirawi kirawi added the A-helix-term Area: Helix term improvements label Jan 4, 2022
@archseer
Copy link
Member

archseer commented Jan 5, 2022

Can you specify what filetype and language server are you using? It's likely that the LSP limits the unfiltered response and returns more results if a query is provided (but we currently don't support that)

@poliorcetics
Copy link
Contributor Author

Sure, I opened a Rust file helix-lsp/src/client.rs, with rust-analyzer as my language server.

@Aatroxs
Copy link

Aatroxs commented May 25, 2022

I also have the same problem

@julianbieber
Copy link

When you are facing this issue with rust-analyzer, the limit of symbols returned in a single query is configurable vie rust-analyzer.workspace.symbol.search.limit.

[[language]]
name = "rust"
scope = "source.rust"
injection-regex = "rust"
file-types = ["rs"]
roots = ["Cargo.toml", "Cargo.lock"]
auto-format = true
comment-token = "//"
language-server = { command = "rust-analyzer" }
config = { rust-analyzer.workspace.symbol.search.limit = 1048576 }
indent = { tab-width = 4, unit = "    " }

@sudormrfbin
Copy link
Member

Neovim's telescope has a "dynamic" workspace symbol picker which essentially sends the workspace/symbols request to the LS on every keypress with the new query text. We currently send a single request with an empty string and filter the results returned by this request:

pub fn workspace_symbol_picker(cx: &mut Context) {
let doc = doc!(cx.editor);
let current_url = doc.url();
let language_server = language_server!(cx.editor, doc);
let offset_encoding = language_server.offset_encoding();
let future = language_server.workspace_symbols("".to_string());

According to the LSP spec, an empty string should return all symbols, but since this is computationally expensive it might choose to limit the number of results. For rust-analyzer the limit can be controlled via a config option, but ideally we would have a picker that can re-request workspace symbols with the new query on every keypress (this kind of "dynamic" picker will also be useful for interactive global search/live grep - #196).

@sam-mccall
Copy link
Contributor

clangd dev here, we also break spec by limiting to 100 results (same as code completion), happy to elaborate if it's helpful.

According to the LSP spec, an empty string should return all symbols, but since this is computationally expensive it might choose to limit the number of results

Not just computationally expensive on the server, but we can overwhelm clients: "all symbols" can easily be 1M+, and there are clients out there written in vimscript and such...

@creikey
Copy link

creikey commented Nov 27, 2022

clangd dev here, we also break spec by limiting to 100 results (same as code completion), happy to elaborate if it's helpful.

According to the LSP spec, an empty string should return all symbols, but since this is computationally expensive it might choose to limit the number of results

Not just computationally expensive on the server, but we can overwhelm clients: "all symbols" can easily be 1M+, and there are clients out there written in vimscript and such...

How should the symbol picker be used then if the symbol search can only query out of 100 symbols? Most workspaces have more than 100 symbols

@creikey
Copy link

creikey commented Nov 27, 2022

Oh wait I understand now, helix was querying for every single symbol from the LSP and filtering via its own search algorithm. #3110 fixes this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug
Projects
None yet
8 participants