Repository navigation
fix: expand Windows-style tilde paths - #16
Conversation
Reviewer's GuideAPIUpdate the public tilde-expansion function to use platform-appropriate separators and keep a trailing separator for tilde-root completion.
TestsAdd platform-independent checks for accepted tilde separators and trailing-separator behavior during completion.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/util.rs" line_range="305" />
<code_context>
/// into a text box, so somebody has to do it.
+fn tilde_suffix(path: &str, windows: bool) -> Option<&str> {
+ path.strip_prefix("~/")
+ .or_else(|| windows.then(|| path.strip_prefix("~\\")).flatten())
+}
+
</code_context>
<issue_to_address>
**Repeated separator escapes home directory**
When A Windows-style input has two backslashes immediately after `~`, such as `~\\Documents`, `tilde_suffix` strips only the first backslash, leaving a root-relative suffix; `home.join(rest)` then resolves it from the drive root instead of beneath the user's home, so the expanded path points to the wrong location.
Normalize repeated separators after the tilde prefix or ensure the suffix is relative before joining it to the home directory.
</issue_to_address>
### Comment 2
<location path="src/util.rs" line_range="305" />
<code_context>
/// into a text box, so somebody has to do it.
+fn tilde_suffix(path: &str, windows: bool) -> Option<&str> {
+ path.strip_prefix("~/")
+ .or_else(|| windows.then(|| path.strip_prefix("~\\")).flatten())
+}
+
</code_context>
<issue_to_address>
**Home-directory completion scans siblings**
When windows completion input is exactly `~\\`, `expand_tilde` turns this into the home path with no trailing separator; `complete_path` then treats the home directory’s basename as the completion prefix and scans its parent, so tab completion offers siblings instead of entries inside the home directory.
Preserve the trailing separator when expanding this input, or handle it as a request to scan the home directory before splitting the expanded path.
</issue_to_address>Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: src/util.rs:305, src/util.rs:305
|
fixed both findings: repeated Windows separators are normalized before joining to the home directory, and |
Sourcery withdrew this approval because it has stopped reviewing this pull request.
|
Sourcery has withdrawn its approval of this pull request. It auto-reviews a pull request 5 times, and this push is past that limit, so the approval no longer reflects code Sourcery has read. Comment |
Summary
~\\pathusing the user home directory on Windows~/patheverywhereVerification
Summary by Sourcery
Correct tilde path expansion across Windows and Unix separator conventions.
Bug Fixes:
Enhancements:
Tests: