Add indentation guides to the code editor
メンテナーはふだん 1 日以内に返信
評価
この issue はまだ評価されていません。
説明
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
- 主要言語
- Rust
- スター
- 144
- フォーク
- 41
- 平均マージ
- 1日 7時間
- マージ済み PR(30日)
- 94
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sysprog21/codetrial のほかの issue
-
Highlight the active line in the code editor対応中かも @ArthurArthurArthur0817 が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
sysprog21/codetrial#247 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Support configurable and randomized interviewer voices and accents対応中かも @MorganHo001 が今日担当しました。 オープン
sysprog21/codetrial#261 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
sysprog21/codetrial#258 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 1〜2日 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
Add an example drawing area to coding interviews対応中かも @Chuyutseng が今日担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
sysprog21/codetrial#255 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
sysprog21/codetrial の issue をすべて見る
似ている issue
-
status:needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
agentic-os-org/ANOLISA#6742 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
git-ai-project/git-ai#2406 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
Kc1t/alethe-agents#312 ·
メンテナーはふだん 3 日以内に返信