Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[rust-analyzer] Workspace symbol picker should search the same symbol types as the single-file symbol picker #7882

Closed
willhansen opened this issue Aug 9, 2023 · 1 comment
Labels
C-enhancement Category: Improvements upstream

Comments

@willhansen
Copy link

willhansen commented Aug 9, 2023

The Problem

With rust, the workspace symbol picker and the single-file symbol picker have different search behavior, even with a single file in the project. This is unintuitive, and the default behavior should be that they are the same.

  • The workspace symbol picker does not return any function names unless there are absolutely no struct names that fuzzy match the given string.
  • The single-file symbol picker searches both from the beginning

Reproduction:

With a file generated by this python script:

#!/usr/bin/env python3

n = 300
with open("main.rs", "w") as file:
    file.write('fn main() {println!("asdf");}\n')
    for i in range(n):
        file.write('fn a' + str(i) + '_snake_func() {println!("asdf");}\n')
        file.write('fn a' + str(i) + 'CamelFunc() {println!("asdf");}\n')
        file.write('struct a' + str(i) + '_snake_struct();\n')
        file.write('struct a' + str(i) + 'CamelStruct();\n')

Workspace symbol picker:
Selection_265

Single-file symbol picker:
Selection_264

The Fix

This can by fixed with this language.toml file, making both symbol pickers include functions from the beginning:

[[language]]
name = "rust"

[language.config.workspace.symbol.search]
kind = "all_symbols"

This should be set by default.

(continued from discussion: #7867)

@willhansen willhansen added the C-enhancement Category: Improvements label Aug 9, 2023
@pascalkuthe
Copy link
Member

There seem to be some performance concerns about changing the default rust-lang/rust-analyzer#14553 (comment).

You can also append # to search for functions too. It doesn't currently work in helix but #7265 will fix that. I think we should stick with the RA default. Whether a different default is the better choice or not should be discussed and changed upstream instead of here.

In the meantime adding this t your personal config is a very simple workaround

@helix-editor helix-editor locked and limited conversation to collaborators Sep 12, 2023
@pascalkuthe pascalkuthe converted this issue into discussion #8256 Sep 12, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
C-enhancement Category: Improvements upstream
Projects
None yet
Development

No branches or pull requests

2 participants