Skip to content

Add logic for tilde symbol expansion#1233

Open
AR-DEV-1 wants to merge 2 commits intoRedot-Engine:masterfrom
AR-DEV-1:tilde-filedialog
Open

Add logic for tilde symbol expansion#1233
AR-DEV-1 wants to merge 2 commits intoRedot-Engine:masterfrom
AR-DEV-1:tilde-filedialog

Conversation

@AR-DEV-1
Copy link
Contributor

@AR-DEV-1 AR-DEV-1 commented Mar 16, 2026

TL;DR

This PR adds the tilde symbol (which is used in UNIX based OS). It checks for your platform & expands the tilde symbol to your home dir (which is USERPROFILE on Windows & HOME on Linux).

This is a recording of the PR in work:

PR.Showcase.webm

Note

Contributed by 2LazyDevs.

Summary by CodeRabbit

  • New Features

    • Home directory shortcut (~) now expands to the user’s home on Unix/Linux and Windows.
    • File dialog inputs (file/folder fields, current path) now expand and normalize submitted paths.
  • Bug Fixes

    • More consistent path parsing and handling across platforms (improves drive-letter and path position behavior).

@coderabbitai
Copy link

coderabbitai bot commented Mar 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cf5867d4-f0d2-4e9a-b231-4b1383771487

📥 Commits

Reviewing files that changed from the base of the PR and between 96af008 and f7c9e4e.

📒 Files selected for processing (1)
  • platform/windows/os_windows.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • platform/windows/os_windows.cpp

Walkthrough

Adds a new OS::expand_path(const String&) API with platform overrides (Unix, Windows) that expand leading tilde (~) to the user home directory; integrates this expansion into FileDialog path inputs and current-path handling. Also tweaks Windows get_unique_id() GUID extraction.

Changes

Cohort / File(s) Summary
Core OS
core/os/os.h, core/os/os.cpp
Declare virtual expand_path(const String &) and provide base implementation returning input unchanged.
Unix OS driver
drivers/unix/os_unix.h, drivers/unix/os_unix.cpp
Add OS_Unix::expand_path override that expands leading ~/~/... using HOME.
Windows OS
platform/windows/os_windows.h, platform/windows/os_windows.cpp
Add OS_Windows::expand_path override that expands leading ~/~/... using USERPROFILE. Also adjust GUID extraction logic in get_unique_id().
File dialog
scene/gui/file_dialog.cpp
Use OS::get_singleton()->expand_path() in _dir_submitted(), _action_pressed(), set_current_dir(), and set_current_path() to normalize user and current paths before parsing/operations.

Sequence Diagram

sequenceDiagram
    actor User
    participant FileDialog
    participant OS as OS::get_singleton()
    participant Platform as "Platform OS\n(Unix / Windows)"

    User->>FileDialog: Submit path (e.g., "~/proj")
    FileDialog->>OS: expand_path(p_path)
    activate OS
    OS->>Platform: expand_path(p_path)
    activate Platform
    Platform->>Platform: if p_path starts with "~", replace with HOME/USERPROFILE
    Platform-->>OS: expanded path
    deactivate Platform
    OS-->>FileDialog: expanded path
    deactivate OS
    FileDialog->>FileDialog: use expanded path for navigation / file ops
    FileDialog-->>User: show files / navigate
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding tilde symbol expansion functionality across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can disable sequence diagrams in the walkthrough.

Disable the reviews.sequence_diagrams setting to disable sequence diagrams in the walkthrough.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scene/gui/file_dialog.cpp`:
- Around line 1229-1237: set_current_dir currently forwards raw input to
_change_dir while set_current_path expands tilde via
OS::get_singleton()->expand_path, causing inconsistent behavior; update
set_current_dir (and any callers like the block in file_dialog.cpp that parses
path into path_dir/path_file and calls set_current_dir) to call
OS::get_singleton()->expand_path on its input before passing to _change_dir so
"~" and other expansions behave consistently with set_current_path and
_change_dir receives an expanded absolute path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0734b4e9-195e-46a3-91f7-7f76b3028075

📥 Commits

Reviewing files that changed from the base of the PR and between 8080a78 and 59a325e.

📒 Files selected for processing (7)
  • core/os/os.cpp
  • core/os/os.h
  • drivers/unix/os_unix.cpp
  • drivers/unix/os_unix.h
  • platform/windows/os_windows.cpp
  • platform/windows/os_windows.h
  • scene/gui/file_dialog.cpp

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@platform/windows/os_windows.cpp`:
- Around line 2503-2514: In OS_Windows::expand_path, after you prepend
USERPROFILE into path (work with variables path and home in that function),
normalize the separators before returning: convert Windows backslashes to the
engine's canonical '/' form (e.g., replace '\\' with '/'), and ensure any mixed
separators are resolved so expanded results like "~/foo" produce
"C:/Users/me/foo" instead of "C:\Users\me/foo".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 24d21657-42ec-4938-9f79-ed4bf9e31714

📥 Commits

Reviewing files that changed from the base of the PR and between 59a325e and 96af008.

📒 Files selected for processing (7)
  • core/os/os.cpp
  • core/os/os.h
  • drivers/unix/os_unix.cpp
  • drivers/unix/os_unix.h
  • platform/windows/os_windows.cpp
  • platform/windows/os_windows.h
  • scene/gui/file_dialog.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • scene/gui/file_dialog.cpp

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Arctis-Fireblight
Copy link
Contributor

Looks good from a review standpoint, I just need to do some testing and we should be good for merge!

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

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants