Skip to content

fix: support Windows path completion - #7

Merged
programmersd21 merged 2 commits into
mainfrom
fix/windows-path-completion
Nov 28, 2026
Merged

programmersd21 merged 2 commits into
mainfrom
fix/windows-path-completion

Conversation

@programmersd21

@programmersd21 programmersd21 commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • split completion input on both slash styles on Windows
  • preserve Unix path parsing on Unix
  • add cross-platform regression coverage for Windows drive paths and mixed separators

Verification

  • regression tests added; CI will run formatting, Clippy and tests

Summary by Sourcery

Fix cross-platform path splitting so completion correctly handles Windows paths without changing Unix behavior.

Bug Fixes:

  • Fix path completion on Windows by recognizing both native and Unix-style separators, including drive paths.

Enhancements:

  • Preserve Unix path completion behavior while supporting mixed separators on Windows.

Tests:

  • Add regression coverage for Unix paths, Windows drive paths, and mixed separator handling.

@sourcery-ai

sourcery-ai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Split completion paths using both slash styles on Windows while retaining slash-only parsing elsewhere, and route complete_path through the helper.

  • src/util.rs L392-403, L411

Tests

Add regression coverage for Unix paths, Windows drive paths, and mixed separators.

  • src/util.rs L824-839

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Nov 28, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 09b6de2e-9738-4f69-8867-b96defee6305
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@programmersd21
programmersd21 merged commit 03ae5b0 into main Nov 28, 2026
5 checks passed
@programmersd21
programmersd21 deleted the fix/windows-path-completion branch November 28, 2026 03:51

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 4 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/util.rs" line_range="394" />
<code_context>
 /// reads are not free.
+fn split_completion_path(input: &str, windows: bool) -> (&str, &str) {
+    let separator = if windows {
+        input.rfind(['/', '\\'])
+    } else {
+        input.rfind('/')
</code_context>
<issue_to_address>
**Backslash UNC input initiates SMB access**

When a Windows user types or pastes an attacker-provided `\\host\share\...` path into the input, `split_completion_path` treats the backslashes as directory separators, and `update_completion` immediately passes the resulting directory to `read_dir`; Windows attempts SMB authentication using the user's ambient credentials before the user accepts the candidate.

Avoid automatically enumerating UNC paths while the user types; require a deliberate action before accessing a remote share.
</issue_to_address>

### Comment 2
<location path="src/util.rs" line_range="394" />
<code_context>
 /// reads are not free.
+fn split_completion_path(input: &str, windows: bool) -> (&str, &str) {
+    let separator = if windows {
+        input.rfind(['/', '\\'])
+    } else {
+        input.rfind('/')
</code_context>
<issue_to_address>
**Drive-relative suggestions are missing**

When a Windows user enters a drive-relative path such as `C:rec` with no separator, `split_completion_path` returns an empty directory and keeps the drive-qualified text as the filename prefix, so `complete_path` scans the process’s current directory and returns no useful suggestions; accepted suggestions also resolve from the wrong directory.

Handle the drive prefix as the directory for drive-relative paths in `split_completion_path`.

Also at `src/util.rs:400-401`.
</issue_to_address>

### Comment 3
<location path="src/util.rs" line_range="394" />
<code_context>
 /// reads are not free.
+fn split_completion_path(input: &str, windows: bool) -> (&str, &str) {
+    let separator = if windows {
+        input.rfind(['/', '\\'])
+    } else {
+        input.rfind('/')
</code_context>
<issue_to_address>
**Backslash home paths return no candidates**

When a Windows user enters a home-relative path using `~\`, `expand_tilde` leaves the backslash form unchanged, so `complete_path` scans a literal `~\` path and returns no candidates.

Expand tilde paths using Windows backslashes as well as forward slashes.
</issue_to_address>

### Comment 4
<location path="src/util.rs" line_range="831-833" />
<code_context>
+            ("/home/user/", "rec")
+        );
+        assert_eq!(
+            split_completion_path("C:\\Users\\user\\rec", true),
+            ("C:\\Users\\user\\", "rec")
+        );
+        assert_eq!(
+            split_completion_path("C:/Users/user/rec", true),
</code_context>
<issue_to_address>
**Windows wiring regression goes undetected**

When `complete_path` is wired to use the non-Windows separator mode, `completion_path_splits_native_and_windows_separators` calls `split_completion_path` directly with `true`, so it passes even if `complete_path` stops enabling Windows separators and Windows path completion remains broken.

Add a test that exercises `complete_path` with a Windows-style path and verifies the resulting directory and candidates.
</issue_to_address>

Sourcery assessment

Approval pending. 4 findings to address first.

Blocking findings: src/util.rs:394, src/util.rs:394, src/util.rs:394, src/util.rs:833


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/util.rs
/// reads are not free.
fn split_completion_path(input: &str, windows: bool) -> (&str, &str) {
let separator = if windows {
input.rfind(['/', '\\'])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Backslash UNC input initiates SMB access

When a Windows user types or pastes an attacker-provided \\host\share\... path into the input, split_completion_path treats the backslashes as directory separators, and update_completion immediately passes the resulting directory to read_dir; Windows attempts SMB authentication using the user's ambient credentials before the user accepts the candidate.

Avoid automatically enumerating UNC paths while the user types; require a deliberate action before accessing a remote share.

Prompt for AI agents
In `src/util.rs` at line 394:

**Backslash UNC input initiates SMB access**

When a Windows user types or pastes an attacker-provided `\\host\share\...` path into the input, `split_completion_path` treats the backslashes as directory separators, and `update_completion` immediately passes the resulting directory to `read_dir`; Windows attempts SMB authentication using the user's ambient credentials before the user accepts the candidate.

Avoid automatically enumerating UNC paths while the user types; require a deliberate action before accessing a remote share.

Comment thread src/util.rs
/// reads are not free.
fn split_completion_path(input: &str, windows: bool) -> (&str, &str) {
let separator = if windows {
input.rfind(['/', '\\'])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Drive-relative suggestions are missing

When a Windows user enters a drive-relative path such as C:rec with no separator, split_completion_path returns an empty directory and keeps the drive-qualified text as the filename prefix, so complete_path scans the process’s current directory and returns no useful suggestions; accepted suggestions also resolve from the wrong directory.

Handle the drive prefix as the directory for drive-relative paths in split_completion_path.

Also at src/util.rs:400-401.

Prompt for AI agents
In `src/util.rs` at line 394:

**Drive-relative suggestions are missing**

When a Windows user enters a drive-relative path such as `C:rec` with no separator, `split_completion_path` returns an empty directory and keeps the drive-qualified text as the filename prefix, so `complete_path` scans the process’s current directory and returns no useful suggestions; accepted suggestions also resolve from the wrong directory.

Handle the drive prefix as the directory for drive-relative paths in `split_completion_path`.

Also at `src/util.rs:400-401`.

Comment thread src/util.rs
/// reads are not free.
fn split_completion_path(input: &str, windows: bool) -> (&str, &str) {
let separator = if windows {
input.rfind(['/', '\\'])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Backslash home paths return no candidates

When a Windows user enters a home-relative path using ~\, expand_tilde leaves the backslash form unchanged, so complete_path scans a literal ~\ path and returns no candidates.

Expand tilde paths using Windows backslashes as well as forward slashes.

Prompt for AI agents
In `src/util.rs` at line 394:

**Backslash home paths return no candidates**

When a Windows user enters a home-relative path using `~\`, `expand_tilde` leaves the backslash form unchanged, so `complete_path` scans a literal `~\` path and returns no candidates.

Expand tilde paths using Windows backslashes as well as forward slashes.

Comment thread src/util.rs
Comment on lines +831 to +833
split_completion_path("C:\\Users\\user\\rec", true),
("C:\\Users\\user\\", "rec")
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Windows wiring regression goes undetected

When complete_path is wired to use the non-Windows separator mode, completion_path_splits_native_and_windows_separators calls split_completion_path directly with true, so it passes even if complete_path stops enabling Windows separators and Windows path completion remains broken.

Add a test that exercises complete_path with a Windows-style path and verifies the resulting directory and candidates.

Prompt for AI agents
In `src/util.rs` at lines 831-833:

**Windows wiring regression goes undetected**

When `complete_path` is wired to use the non-Windows separator mode, `completion_path_splits_native_and_windows_separators` calls `split_completion_path` directly with `true`, so it passes even if `complete_path` stops enabling Windows separators and Windows path completion remains broken.

Add a test that exercises `complete_path` with a Windows-style path and verifies the resulting directory and candidates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant