Let the candidate choose the editor indentation width
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
The code editor always indents by four spaces. INDENT is a constant in web/editor.js:4 (revision b2c2bc9), and both Tab (indentSelection) and auto-indent on Enter (indentNewline) insert it. Shift+Tab removes at most four leading spaces (/^\t|^ {1,4}/ in indentSelection).
This does not match the starter code the candidate is given. Of the 151 problems in web/problems/, 130 JavaScript starters indent by two spaces, while the Python, C, C++ and Java starters indent by four. In a JavaScript interview, the first Tab or Enter inside the starter function therefore produces a body indented at a different width from the line above it. A candidate who writes two-space or tab-indented code has no way to change this.
This falls under the editor settings gap (indentation) in the HackerRank Mock Interviews comparison of the contribution guide.
Proposed behavior
- A new editor option, beside the existing ones in
web/editor-options.js(autoIndent,autoClose, ...), selects the indentation unit: 2 spaces, 4 spaces (the default, so nothing changes for existing users) or a tab. - Tab, Shift+Tab and auto-indent on Enter on the interview page use the selected unit until the buffer has an indented block of its own, then the width that block uses, so a four-space Python starter is not nested at another width (agreed in review on #590).
- Shift+Tab removes one level of the selected unit rather than up to four spaces.
- The choice is saved the same way as the other editor options.
Out of scope: reformatting code the candidate has already written, and the task page, which honors none of the lobby's editor options today.
Acceptance criteria
- With 2 spaces selected, Tab at the start of a line inserts two spaces, Enter after
{indents the new line by two spaces more than the current one, and Shift+Tab removes two. - With tab selected, the same actions insert and remove a single
\t. - With the default, behavior is unchanged, and the existing tests in
tests/browser/editor.test.jspass unmodified. - New cases in
tests/browser/editor.test.jsandtests/browser/editor-options.test.jscover each unit and the saved option, and fail if the unit is ignored.
I am working on this and will open a pull request.
- 主要语言
- Rust
- 星标
- 223
- 派生
- 148
- 平均合并
- 1 天 10 小时
- 30 天内合并 PR
- 227
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sysprog21/codetrial 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
sysprog21/codetrial#604 · 1 条评论 ·
维护者通常 1 天内回复
-
Compare code semantically across a force push in review bundles可能已有人在做 @Alan52254 今天认领。 未关闭
sysprog21/codetrial#606 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Calculator % disagrees with // on negative operands可能已有人在做 @YunJ-Chang 今天认领。 未关闭
sysprog21/codetrial#602 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Start does nothing visible in the lobby when site data is blocked可能已有人在做 @sidney-Hung 今天认领。 未关闭
sysprog21/codetrial#600 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Add a Copy results action to the coding test panel可能已有人在做 @seallllllllll 今天认领。 未关闭
sysprog21/codetrial#598 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 sysprog21/codetrial 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
type: documentation
难度 2/5 1-3 小时 新手友好度 70/100
tauri-apps/tauri#16476 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
fish-shell/fish-shell#13084 · 1 条评论 ·
维护者通常 2 天内回复
-
bug: merge_insert does not detect concurrent inserts of the same FixedSizeBinary primary key可能已有人在做 @lance-gatefixer 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 84/100
lance-format/lance#10811 ·
维护者通常 2 天内回复
-
provider testing
难度 2/5 1-3 小时 新手友好度 78/100
mishraprafful/multihull#234 ·
维护者通常 1 天内回复