Skip to content

Commit 2ebe7c4

Browse files
committed
Address code review
1 parent f9699ee commit 2ebe7c4

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

crates/aether_path/src/file_path.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,11 @@ impl FilePath {
118118
.as_url()
119119
.path_segments()?
120120
.next_back()
121+
// A trailing slash (`.../foo/`) yields a final empty segment,
122+
// meaning the URL points at a directory. Drop it so we return
123+
// `None` rather than `""`.
121124
.filter(|seg| !seg.is_empty())?;
122-
Some(percent_decode_str(last).decode_utf8_lossy())
125+
percent_decode_str(last).decode_utf8().warn_on_err()
123126
},
124127
}
125128
}

crates/oak_db/src/file_imports.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,12 @@ fn narrow_package_top_level(file: File, db: &dyn Db, package: Package) -> Vec<Im
158158
}
159159

160160
/// The file's `library()` / `require()` attaches as `Package` layers, in LIFO
161-
/// order (latest-attached first). `before` narrows to a top-level cursor: with
162-
/// `Some(offset)`, keep only file-scope calls that have run by `offset`; with
163-
/// `None`, keep every attach (the end-of-file view, used for lazy contexts).
161+
/// order (latest-attached first). `before` selects which calls to include:
162+
///
163+
/// - `None`: every attach. The end-of-file view, used for lazy contexts.
164+
/// - `Some(offset)`: only top-level (file-scope) calls that have run by
165+
/// `offset`. Calls nested in a block (e.g. inside `test_that({})`) are
166+
/// dropped, as are calls after the offset.
164167
fn attach_layers(file: File, db: &dyn Db, before: Option<TextSize>) -> Vec<ImportLayer> {
165168
let index = file.semantic_index(db);
166169
let file_scope = ScopeId::from(0);
@@ -239,7 +242,7 @@ fn package_imports(file: File, db: &dyn Db, package: Package) -> Vec<ImportLayer
239242
/// 6. base.
240243
///
241244
/// `offset` narrows the components of layer 4. `None` produces the end-of-file
242-
/// view and keeps every `library()` call. `Some(offset)` keeps only the calls
245+
/// view and uses every `library()` call. `Some(offset)` uses only the calls
243246
/// that have run by `offset`. The other layers are sourced or attached before
244247
/// the file body runs, so they never narrow.
245248
fn testthat_imports(

0 commit comments

Comments
 (0)