Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
fix(solc): flatten replacement target location (#846)
Browse files Browse the repository at this point in the history
* adjust the end location

* upd changelog
  • Loading branch information
rkrasiuk authored Jan 31, 2022
1 parent 01544ec commit a484960
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

### Unreleased

- Fix flatten replacement target location
[#846](https://github.com/gakonst/ethers-rs/pull/846)
- Fix duplicate files during flattening
[#813](https://github.com/gakonst/ethers-rs/pull/813)
- Add ability to flatten file imports
Expand Down
3 changes: 2 additions & 1 deletion ethers-solc/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ impl<T> SolDataUnit<T> {
pub fn loc_by_offset(&self, offset: isize) -> (usize, usize) {
(
offset.saturating_add(self.loc.start as isize) as usize,
offset.saturating_add(self.loc.end as isize) as usize,
// make the end location exclusive
offset.saturating_add(self.loc.end as isize + 1) as usize,
)
}
}
Expand Down
1 change: 1 addition & 0 deletions ethers-solc/tests/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,5 @@ fn can_flatten_file_with_duplicates() {
assert_eq!(result.matches("contract Foo {").count(), 1);
assert_eq!(result.matches("contract Bar {").count(), 1);
assert_eq!(result.matches("contract FooBar {").count(), 1);
assert_eq!(result.matches(";").count(), 1);
}

0 comments on commit a484960

Please sign in to comment.