diff --git a/CHANGELOG.md b/CHANGELOG.md index c146cb3..db68469 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,13 @@ All notable changes to the "rust-test-lens" extension will be documented in this Check [Keep a Changelog](https://keepachangelog.com/) for recommendations on how to structure this file. +## 0.1.2 + +- Fixes issue [#3](https://github.com/hdevalke/rust-test-lens/issues/3) where there is more than one target created. + ## 0.1.1 -- Fixes issue [#3](https://github.com/hdevalke/rust-test-lens/issues/3) where tests in binary crate were not launched. +- Fixes issue [#3](https://github.com/hdevalke/rust-test-lens/issues/3) where tests in binary crate are not launched. ## 0.1.0 diff --git a/package.json b/package.json index 13b3382..068dec3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "rust-test-lens", "displayName": "Rust Test Lens", "description": "Adds a code lens to quickly run or debug a single test for your Rust code.", - "version": "0.1.1", + "version": "0.1.2", "publisher": "hdevalke", "engines": { "vscode": "^1.30.2" diff --git a/src/RustTests.ts b/src/RustTests.ts index afb42d8..d3d6e84 100644 --- a/src/RustTests.ts +++ b/src/RustTests.ts @@ -59,14 +59,21 @@ export class RustTests { // fast path if (targets.length === 1) { target = targets[0]; - } - // slow path - for (const t of pkg.targets) { - if (t.src_path === uri) { - target = t; - break; + } else { + // slow path + // sort in order to find longest path. + targets.sort((a, b) => { + return b.src_path.length - a.src_path.length; + }); + for (const t of pkg.targets) { + let target_dir = dirname(t.src_path); + if (uri.startsWith(target_dir)) { + target = t; + break; + } } } + let kind = undefined; let name = undefined; if (target === undefined) {