Skip to content
This repository has been archived by the owner on May 9, 2021. It is now read-only.

Commit

Permalink
Fixes issue #3 by matching the longest prefix of a target path
Browse files Browse the repository at this point in the history
  • Loading branch information
hdevalke committed Mar 29, 2019
1 parent 1fd559a commit ffb9172
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 13 additions & 6 deletions src/RustTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ffb9172

Please sign in to comment.