Let the candidate choose the editor indentation width

オープン
#589 コメント 2 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@princelu1009 がすでに取り組んでいます。

2026年11月5日 から。

  • #590 @princelu1009 による — オープン

評価

この 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.js pass unmodified.
  • New cases in tests/browser/editor.test.js and tests/browser/editor-options.test.js cover 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日 11時間
マージ済み PR(30日)
224

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sysprog21/codetrial のほかの issue

sysprog21/codetrial の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。