Merge #10802
10802: Allow clients to configure the global workspace search limit r=Veykril a=knutwalker Playing around with [helix](https://helix-editor.com) I realized that the global worksapce symbol search works different compared to vs-code. Helix requires all possible symbols in one query and does no subsequent refinement searched. This PR adds a configuration option to override the default search limit with the default being the currently hardocded value. Helix users can increment this limit for their instance with a config like ```toml [[language]] name = "rust" language-server = { command = "rust-analyzer" } [language.config] workspace = { symbol = { search = { limit = 65536 }}} ``` Other editors are not affected by this change. Co-authored-by: Paul Horn <dev@knutwalker.engineer>
This commit is contained in:
@@ -33,7 +33,7 @@ use vfs::AbsPathBuf;
|
||||
|
||||
use crate::{
|
||||
cargo_target_spec::CargoTargetSpec,
|
||||
config::RustfmtConfig,
|
||||
config::{RustfmtConfig, WorkspaceSymbolConfig},
|
||||
diff::diff,
|
||||
from_proto,
|
||||
global_state::{GlobalState, GlobalStateSnapshot},
|
||||
@@ -403,7 +403,9 @@ pub(crate) fn handle_workspace_symbol(
|
||||
) -> Result<Option<Vec<SymbolInformation>>> {
|
||||
let _p = profile::span("handle_workspace_symbol");
|
||||
|
||||
let (all_symbols, libs) = decide_search_scope_and_kind(¶ms, &snap);
|
||||
let config = snap.config.workspace_symbol();
|
||||
let (all_symbols, libs) = decide_search_scope_and_kind(¶ms, &config);
|
||||
let limit = config.search_limit;
|
||||
|
||||
let query = {
|
||||
let query: String = params.query.chars().filter(|&c| c != '#' && c != '*').collect();
|
||||
@@ -414,13 +416,13 @@ pub(crate) fn handle_workspace_symbol(
|
||||
if libs {
|
||||
q.libs();
|
||||
}
|
||||
q.limit(128);
|
||||
q.limit(limit);
|
||||
q
|
||||
};
|
||||
let mut res = exec_query(&snap, query)?;
|
||||
if res.is_empty() && !all_symbols {
|
||||
let mut query = Query::new(params.query);
|
||||
query.limit(128);
|
||||
query.limit(limit);
|
||||
res = exec_query(&snap, query)?;
|
||||
}
|
||||
|
||||
@@ -428,14 +430,12 @@ pub(crate) fn handle_workspace_symbol(
|
||||
|
||||
fn decide_search_scope_and_kind(
|
||||
params: &WorkspaceSymbolParams,
|
||||
snap: &GlobalStateSnapshot,
|
||||
config: &WorkspaceSymbolConfig,
|
||||
) -> (bool, bool) {
|
||||
// Support old-style parsing of markers in the query.
|
||||
let mut all_symbols = params.query.contains('#');
|
||||
let mut libs = params.query.contains('*');
|
||||
|
||||
let config = snap.config.workspace_symbol();
|
||||
|
||||
// If no explicit marker was set, check request params. If that's also empty
|
||||
// use global config.
|
||||
if !all_symbols {
|
||||
|
||||
Reference in New Issue
Block a user