Skip to content

Commit

Permalink
Fix Windows uri comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
Chase Coalwell committed Apr 28, 2022
1 parent aefd638 commit 0b29f1c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public Optional<ShapeId> getShapeIdFromLocation(String uri, Position position) {
entry.getValue().getRange().getEnd().getLine() - entry.getValue().getRange().getStart().getLine());

List<Map.Entry<ShapeId, Location>> matchingShapes = locations.entrySet().stream()
.filter(entry -> Paths.get(entry.getValue().getUri()).equals(Paths.get(uri)))
.filter(entry -> getUri(entry.getValue().getUri()).equals(getUri(uri)))
.filter(filterByLocation(position))
// Since the position is in each of the overlapping shapes, return the smallest range.
.sorted(rangeSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public void shapeIdFromLocation() throws Exception {

try (Harness hs = Harness.create(SmithyBuildExtensions.builder().build(), modelFiles)) {
SmithyProject project = hs.getProject();
String uri = "file:" + hs.file("main.smithy");
String testUri = "file:" + hs.file("test.smithy");
String uri = uri(hs.file("main.smithy"));
String testUri = uri(hs.file("test.smithy"));

assertFalse(project.getShapeIdFromLocation("empty.smithy", new Position(0, 0)).isPresent());
assertFalse(project.getShapeIdFromLocation(uri, new Position(0, 0)).isPresent());
Expand Down Expand Up @@ -149,4 +149,8 @@ private void correctLocation(Map<ShapeId, Location> locationMap, String shapeId,
Range range = new Range(new Position(startLine, startColumn), new Position(endLine, endColumn));
assertEquals(range, location.getRange());
}

private String uri(File f) {
return f.toURI().toString();
}
}

0 comments on commit 0b29f1c

Please sign in to comment.