Skip to content

fix(intellij): handle square brackets in file paths for autocomplete#11474

Merged
RomneyDa merged 5 commits into
continuedev:mainfrom
Tarasusrus:fix/intellij-uri-square-brackets
Mar 26, 2026
Merged

fix(intellij): handle square brackets in file paths for autocomplete#11474
RomneyDa merged 5 commits into
continuedev:mainfrom
Tarasusrus:fix/intellij-uri-square-brackets

Conversation

@Tarasusrus

@Tarasusrus Tarasusrus commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

Use File.toURI() instead of URI constructor for Windows two-slash
file:// URIs to properly percent-encode special characters like [ ].
Fixes #10978.


Summary by cubic

Fixes URI parsing for file paths with square brackets to prevent IntelliJ autocomplete crashes on Windows two‑slash file URIs. Builds Windows file://C:/... URIs with the cross‑platform multi‑arg URI(...) constructor so [ and ] are percent‑encoded.

  • Bug Fixes
    • Update UriUtils to handle Windows two‑slash file:// URIs using URI("file", "", "/$path", null) instead of File.toURI() to avoid host‑dependent behavior.
    • Add regression tests for Unix and Windows; strengthen Windows checks for scheme, decoded path (with literal brackets), and encoded URI string.

Written for commit 2d6a66d. Summary will update on new commits.

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 16, 2026
@github-actions

github-actions Bot commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Tarasusrus

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA.

Use File.toURI() instead of URI constructor for Windows two-slash
file:// URIs to properly percent-encode special characters like [ ].
Fixes continuedev#10978.
@Tarasusrus
Tarasusrus force-pushed the fix/intellij-uri-square-brackets branch from 6e4b338 to 609cf8f Compare March 16, 2026 04:50
@Tarasusrus
Tarasusrus requested a review from a team as a code owner March 16, 2026 04:50
@Tarasusrus
Tarasusrus requested review from RomneyDa and removed request for a team March 16, 2026 04:50

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 issues found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/UriUtils.kt">

<violation number="1" location="extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/UriUtils.kt:30">
P1: `File(path).toURI()` reparses `file://` URI text as a host-local path, causing cross-platform URI corruption and double-encoding of already escaped segments.</violation>
</file>

<file name="extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt">

<violation number="1" location="extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt:85">
P2: Windows regression test assertions are too weak to catch drive-letter or bracket-handling regressions in `file://C:/...` URIs.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Verify that square brackets are percent-encoded and drive letter
and directory structure are preserved in parsed URI path.
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Mar 16, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt">

<violation number="1" location="extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt:86">
P2: Test incorrectly expects percent-encoded brackets in `URI.path`; `path` is decoded for `java.net.URI`, so this assertion is invalid.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

The CI runs on Linux where C: is not a drive letter.
Assert that brackets are encoded and structure is preserved
without platform-specific path assumptions.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt">

<violation number="1" location="extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt:86">
P2: Windows bracket-path regression test was weakened and no longer asserts key Windows URI guarantees (encoding/preservation), allowing incorrect rewrites to pass.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@RomneyDa

Copy link
Copy Markdown
Contributor

@Tarasusrus could you check the cubic comment? seems potentially valid

File.toURI() is platform-dependent — on non-Windows hosts it treats
Windows drive paths (e.g. C:/Users/...) as relative paths, producing
corrupted URIs. The multi-arg URI(scheme, host, path, fragment)
constructor is pure RFC 2396 string manipulation and works identically
on all platforms.

Also strengthens the Windows bracket test with exact equality assertions
instead of loose contains/assertFalse checks.
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Mar 26, 2026

@RomneyDa RomneyDa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Tarasusrus thanks for the contribution!

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Mar 26, 2026
@RomneyDa
RomneyDa merged commit c5490d9 into continuedev:main Mar 26, 2026
52 of 65 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autocomplete crashes with files having square brackets in the filepath/filename.

2 participants