Add indentation guides to the code editor
Maintainer thường phản hồi trong vòng 1 ngày
@sidney-Hung đang làm issue này rồi.
Từ ngày 7/10/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Summary
Add vertical indentation guides (indent lines) to the code editor component to improve visual hierarchy and readability when navigating nested code.
Motivation / Problem Statement
When viewing or editing code with multiple levels of nesting it can be difficult to visually trace which indentation level matches which block.
Adding indentation guides will:
- Make block scope and code hierarchy clear at a glance.
- Prevent misaligned code during editing.
Proposed Architecture & Changes
The editor relies on multiple synchronized layers stacked behind the <textarea> (the line-number gutter, the syntax-color overlay, and the input textarea itself). This change introduces a dedicated fourth layer, #editor-guides, positioned beneath the syntax-color overlay:
| File | Proposed Change |
|---|---|
web/indent-guides.js (new) |
Implements indentGuides(code) to generate HTML for the guides layer. Each full 4-column indent level produces a <span class="indent-guide">. Tabs and 4 spaces align to the same guide; partial indentation yields no guide. |
web/interview.html |
Injects the <pre id="editor-guides"> layer into the editor markup. |
web/interview.js |
Repaints guide lines strictly on text changes (paintEditor()), bypassing unnecessary redraws on caret movement. Synchronizes scroll offsets (scrollTop, scrollLeft) with the textarea. |
web/styles.css |
Enforces font, sizing, padding, and tab-stop parity across layers. Sets guide text to transparent and disables pointer events (pointer-events: none). Renders guides as 1px grey vertical lines spanning the full line height. |
Key Design Decisions & Considerations
- Full-Line Layout Rendering: Rather than rendering only leading whitespace, the entire line is written out with transparent text. This ensures
#editor-guidesshares the exact scrollable scrollWidth and scrollHeight as<textarea>, preventing guide alignment drift on long lines or near file bottoms. - Blank-Line Depth Continuity: Empty lines inherit the shallower depth of their nearest non-blank neighbors (
min(prev_indent, next_indent)). Guides run unbroken through blank lines inside a block and terminate cleanly once the block ends. - Continuous Vertical Lines: Uses
display: inline-blockinstead of standard inline spans to ensure each segment reaches the full line height, rendering solid continuous lines instead of broken dashes. - Separation of Concerns: The existing syntax highlighter and
<textarea>remain untouched. The trade-off is managing font, sizing, and scroll synchronization across one additional layer.
Verification & Testing
tests/browser/indent-guides.test.js(new): 7 tests covering nesting depth, tab vs. space mixing, HTML character escaping, blank-line width calculation, and trailing newlines.tests/browser/editor-font-size.test.js: Extended to assert that the guide layer maintains identical alignment with the<textarea>across all font sizes.
Result
- Ngôn ngữ chính
- Rust
- Star
- 144
- Fork
- 41
- Merge trung bình
- 1 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 93
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của sysprog21/codetrial
-
Highlight the active line in the code editorCó thể đã có người làm @ArthurArthurArthur0817 đã nhận 3 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
sysprog21/codetrial#247 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Downloaded markdown reports use internal lowercase keys instead of display labels for programming languagesCó thể đã có người làm @SkyDrive2 đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
sysprog21/codetrial#246 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support configurable and randomized interviewer voices and accentsCó thể đã có người làm @MorganHo001 đã nhận 2 ngày trước. Đang mở
sysprog21/codetrial#261 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
sysprog21/codetrial#258 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của sysprog21/codetrial
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
chroma-core/chroma#7879 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority middle
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
KATO-Hiro/AtCoderClans#12838 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
clap_complete env (PowerShell): values after a space don't complete in Windows PowerShell 5.1Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày