From eef34958f942495dbc0707edfad26bcfcfc58cf9 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Thu, 8 Jan 2026 09:14:08 -0500 Subject: [PATCH] [ty] More sensible sorting for results returned by `all_symbols` Previously, we would only sort by name and file path (unless the symbol refers to an entire module). This led to somewhat confusing ordering, since the file path is absolute and can be anything. Sorting by module name after symbol name gives a more predictable ordering in common practice. This is mostly just an improvement for debugging purposes, i.e., when looking at the output of `all_symbols` directly. This mostly shouldn't impact completion ordering since completions do their own ranking. --- crates/ty_ide/src/all_symbols.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/ty_ide/src/all_symbols.rs b/crates/ty_ide/src/all_symbols.rs index b66607cb23..b8f70d4362 100644 --- a/crates/ty_ide/src/all_symbols.rs +++ b/crates/ty_ide/src/all_symbols.rs @@ -64,7 +64,11 @@ pub fn all_symbols<'db>( continue; } s.spawn(move |_| { - let symbols_for_file_span = tracing::debug_span!(parent: all_symbols_span, "symbols_for_file_global_only", ?file); + let symbols_for_file_span = tracing::debug_span!( + parent: all_symbols_span, + "symbols_for_file_global_only", + path = %file.path(&*db), + ); let _entered = symbols_for_file_span.entered(); if query.is_match_symbol_name(module.name(&*db)) { @@ -94,11 +98,13 @@ pub fn all_symbols<'db>( let key1 = ( s1.name_in_file() .unwrap_or_else(|| s1.module().name(db).as_str()), + s1.module().name(db).as_str(), s1.file.path(db).as_str(), ); let key2 = ( s2.name_in_file() .unwrap_or_else(|| s2.module().name(db).as_str()), + s2.module().name(db).as_str(), s2.file.path(db).as_str(), ); key1.cmp(&key2)