Skip to content

Commit adfccff

Browse files
author
natzhou
committed
fix: resolve the problem named "Sequence contains no elements"
1 parent fd6b3c1 commit adfccff

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/RustAnalyzer.TestAdapter/Cargo/ToolChainServiceExtensions.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,21 @@ public static async Task<Toolchain[]> GetInstalledToolchainsAsync(PathEx working
9797
if (activeRaw != null)
9898
{
9999
var i = Array.FindIndex(tcs, tc => tc.Name == activeRaw);
100+
101+
// 1.Background: There are cases where projects are pinned to specific Rust versions, and it's also possible that users have installed multiple Rust versions.
102+
103+
// 2.Result: This leads to matching failures during exact name matching.
104+
105+
// Example(e.g.):
106+
// Actual Name: `1.85.1 - x86_64 - pc - windows - msvc(active)`
107+
// activeRaw: `1.85.1 - x86_64 - pc - windows - msvc`
108+
109+
// This results in the error: "Sequence contains no elements"
110+
if (i == -1)
111+
{
112+
i = Array.FindIndex(tcs, t => t.Name.StartsWith(activeRaw));
113+
}
114+
100115
if (i != -1)
101116
{
102117
tcs[i].IsDefault = true;

0 commit comments

Comments
 (0)