Skip to content

Enhance Rust Analyzer and Code Editor with New Features and Fixes#118

Merged
tristanpoland merged 22 commits into
mainfrom
game-gen
May 12, 2026
Merged

Enhance Rust Analyzer and Code Editor with New Features and Fixes#118
tristanpoland merged 22 commits into
mainfrom
game-gen

Conversation

@tristanpoland
Copy link
Copy Markdown
Member

This pull request introduces significant improvements to the code editor's rendering and scrolling logic, focusing on better handling of visible rows (especially with hidden or folded lines), as well as adding a custom VS Code-style scrollbar. The changes refactor how visible lines are tracked and processed, ensuring accurate cursor and selection rendering, and optimize performance for large files.

Editor Scrollbar:

  • Added a new editor_scrollbar.rs file that implements a custom, thin vertical scrollbar for the code editor, supporting drag and click-to-scroll interactions in a VS Code style.

Visible Rows Refactor and Rendering Accuracy:

  • Replaced the use of contiguous visible_range with explicit visible_rows and visible_row_offsets throughout TextElement, ensuring correct rendering and interaction when lines are hidden or folded. This affects cursor/selection rendering, line highlighting, and layout calculations. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Performance and Maintainability:

  • Improved performance for large files by optimizing how visible lines are iterated and highlighted, and by removing unnecessary intermediate allocations. [1] [2] [3]

Dependency Updates:

  • Added engine_class_derive and pulsar_reflection as dependencies in the generated Cargo.toml for core projects.

These changes collectively enhance the editor's usability, visual accuracy, and maintainability, especially in scenarios involving line folding or large documents.

Reworked discovery order and validation in mod.rs:109.
Added explicit override support via PULSAR_RUST_ANALYZER_PATH in mod.rs:110.
Added absolute path scanning for GUI-launch environments (macOS app PATH gaps), including HOME/.cargo/bin and CARGO_HOME/bin in mod.rs:168.
Added rustup discovery from multiple rustup locations, not just PATH, in mod.rs:197.
Added robust executable verification that detects rustup proxy stubs missing the rust-analyzer component in mod.rs:251.
Rebuilt rustup install flow to try all rustup candidates and verify installed binary before use in mod.rs:349.
Made GitHub fallback download architecture-aware for x86_64 and aarch64 on all major OSes in mod.rs:417.
Added downloader fallback behavior (curl/wget on Unix, PowerShell/curl on Windows) in mod.rs:437.
Added pre-spawn validation so broken/proxy binaries trigger self-healing install before launch in mod.rs:638.
Persisted the resolved/installed analyzer path back into manager state after successful spawn in mod.rs:578.
Minimap (minimap.rs) — full rewrite as a GPUI Element:

Gets actual bounds at prepaint time so all heights are real, not hardcoded px(100)
Scroll sync: when the doc is taller than the minimap, minimap_scroll_offset slides the density bars to follow the document scroll proportionally
Viewport indicator: positioned by scroll_abs / content_h (fraction of document scrolled) × real container_h — no more relative() guessing
Click/drag: captures scroll_handle in closures, sets offset.y directly from click fraction — no // TODO left
Custom scrollbar (editor_scrollbar.rs) — new file:

Thin 12 px track, always visible (no fade-in/out complexity)
Thumb: sized by viewport / content ratio, positioned by scroll_abs / max_offset — both using the real ScrollHandle APIs (max_offset().height, bounds().size.height)
Drag: click on thumb starts drag, MouseMoveEvent computes delta and scales it by max_offset / track_travel
Click on track: jumps to clicked position with thumb centered
text_input.rs:

Code editor mode: generic Scrollbar removed, EditorScrollbar + optional Minimap added as absolutely-positioned overlay elements
Non-code inputs: generic Scrollbar unchanged
Revert "Code editor folding"

This reverts commit 1cf8989.
@tristanpoland tristanpoland marked this pull request as ready for review May 12, 2026 16:36
@tristanpoland tristanpoland merged commit 1197b93 into main May 12, 2026
1 of 4 checks passed
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