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 小时
- 30 天内合并 PR
- 94
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sysprog21/codetrial 的其他 Issue
-
Highlight the active line in the code editor可能已有人在做 @ArthurArthurArthur0817 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
sysprog21/codetrial#247 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Support configurable and randomized interviewer voices and accents可能已有人在做 @MorganHo001 于 1 天前认领。 未关闭
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 于 1 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 55/100
sysprog21/codetrial#255 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 sysprog21/codetrial 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 75/100
element-hq/lk-jwt-service#248 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
pact-foundation/pact-cli#154 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
antithesishq/bombadil#361 ·
维护者通常 1 天内回复
-
test(executor_l0): assert execute() TaskOutcome, not only bus events / 断言 execute() 返回的 TaskOutcome未关闭type:debt
难度 2/5 1-3 小时 新手友好度 62/100
skaiy/wild_agentos#425 ·
维护者通常 1 天内回复