Repository navigation
Let the candidate choose the editor indent width - #590
Merged
Merged
Conversation
ColtenOuO
requested changes
Nov 5, 2026
ColtenOuO
left a comment
Collaborator
There was a problem hiding this comment.
Please provide some screenshots of your changes (some frontend changes in this PR)
jserv
reviewed
Nov 5, 2026
jserv
reviewed
Nov 5, 2026
jserv
reviewed
Nov 5, 2026
princelu1009
force-pushed
the
editor-indent-width
branch
from
November 5, 2026 11:55
1f663da to
a155276
Compare
princelu1009
force-pushed
the
editor-indent-width
branch
from
November 5, 2026 12:20
a155276 to
cd50805
Compare
Contributor
Include screenshots in the pull request description rather than in the comments. |
jserv
reviewed
Nov 5, 2026
jserv
reviewed
Nov 5, 2026
jserv
reviewed
Nov 5, 2026
jserv
reviewed
Nov 5, 2026
princelu1009
force-pushed
the
editor-indent-width
branch
from
November 5, 2026 15:04
cd50805 to
20b073e
Compare
jserv
reviewed
Nov 5, 2026
jserv
reviewed
Nov 5, 2026
jserv
reviewed
Nov 5, 2026
jserv
reviewed
Nov 5, 2026
princelu1009
force-pushed
the
editor-indent-width
branch
from
November 6, 2026 04:43
20b073e to
356bef1
Compare
jserv
reviewed
Nov 6, 2026
jserv
reviewed
Nov 6, 2026
jserv
reviewed
Nov 6, 2026
princelu1009
force-pushed
the
editor-indent-width
branch
from
November 6, 2026 05:36
356bef1 to
7282db3
Compare
jserv
reviewed
Nov 6, 2026
jserv
reviewed
Nov 6, 2026
princelu1009
force-pushed
the
editor-indent-width
branch
from
November 6, 2026 12:05
7282db3 to
7c0e1c9
Compare
jserv
previously requested changes
Nov 6, 2026
jserv
left a comment
Contributor
There was a problem hiding this comment.
Rebase onto latest main branch and resolve conflicts.
jserv
reviewed
Nov 6, 2026
jserv
reviewed
Nov 6, 2026
The editor always indented by four spaces, while 130 of the 151 JavaScript starters indent by two, so the first Tab or Enter inside a starter function broke its indentation and a candidate had no way to pick another width. The lobby's editor options gain an Indentation choice of two spaces, four spaces or a tab. Four spaces stays the default, leaves no URL parameter and keeps the editor exactly as it was, so existing interview URLs and the task page behave as before. Under another choice, a starter with an indented block sets one space width for the buffer, measured once from the starter rather than the live buffer, so a four-space Python starter stays four-space instead of raising IndentationError or TabError; the choice applies where the starter measures none. Enter at the end of a line above a deeper body matches that body, past any comment-only lines, so pasted code keeps its width. Tab and Shift+Tab treat each selected line by its own leading character: a tab line moves by a tab, a space line by the space width, and a blank line follows the nearest code above it. Close sysprog21#589 Change-Id: Iae59277d8424dd3730257d256ce546e5d2f162ea
princelu1009
force-pushed
the
editor-indent-width
branch
from
November 6, 2026 14:34
7c0e1c9 to
4b4385a
Compare
jserv
dismissed stale reviews from themself
November 6, 2026 14:40
No merge conflicts at the current head.
Contributor
|
Thank @princelu1009 for contributing! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The code editor always indented by four spaces (
INDENTinweb/editor.js), while 130 of the 151 JavaScript starters indent by two, so the first Tab or Enter inside a JavaScript starter function produced a body at a different width from the line above it, and a candidate who writes two-space or tab-indented code had no way to change it.The lobby's editor options gain an Indentation select with 2 spaces, 4 spaces (the default) and Tab. The choice is saved in the browser and forwarded to the interview in a new
editorIndentURL parameter. Four spaces keeps the editor exactly asmainhas it. Under another choice, a starter with an indented block sets one space width for the buffer, used by unindented and space-indented lines alike (bufferIndentinweb/indent-guides.js, which sharesdetectWidth's voting over space-indented lines only); the choice applies where the starter measures none, as in the JavaScript and C starters written with an empty body. A tab-indented line keeps tabs, and a blank line follows the nearest non-blank line above it, so a blank line inside a tab-indented block takes a tab. That width is measured once from the starter, never from the live buffer, so Tab, a language switch, Restore, undo or a paste cannot change it, Tab and Shift+Tab stay exact opposites, and a four-space Python starter stays four-space under a two-space or tab choice instead of raisingIndentationErrororTabError. Enter at the end of a line, with nothing selected, above a block that already has a deeper body matches that body, skipping lines the tokenizer marks as comment-only (line, block or doc comments) since a comment may sit at any column, so pasted code keeps its own width.indentSelectionandindentNewlinetake the unit as an argument, whichinterview.jshands to the code workspace (web/workspace.js) through its controller, and a block Tab or Shift+Tab resolves it for each selected line. Shift+Tab takes back one level: a single tab, or up to one unit's width of spaces, where the tab unit counts as four columns to matchtab-size: 4.Four spaces leaves no URL parameter and no stored value, so existing interview URLs behave as before, and the 66 existing tests in
tests/browser/editor.test.jspass unmodified. The task page is unchanged, as agreed in #589: it honors none of the lobby's editor options today. The interview start payload pinned intests/web/contract.rsdoes not change, since this is a display preference neither Jim nor the report needs.Validation: new cases in
tests/browser/editor.test.js(each unit for Tab, block indent and outdent, Enter after{and a Python:, a selection mixing tab and space functions,followingIndent),tests/browser/editor-options.test.js(round-trip, unknown values fall back to four, only known values are stored),tests/browser/lobby.test.js(the select survives a reload, is disabled for the whiteboard and reaches the interview URL),tests/browser/indent-guides.test.js(bufferIndentreturnsnullwith no space-indented block, the width otherwise, ignoring tab-indented lines) andtests/browser/editor-pipeline.test.json the real interview page (editorIndent=2andtab, a four-space Python starter under each, Tab then a language switch then Shift+Tab on the two-space JavaScript starter, Enter over a pasted four-space Python body undereditorIndent=2, two Tab presses on a blank line of the Python starter under2andtab, and Enter with text after the caret, a closer after it, or a selection, above a deeper line, Enter over a two-space line or block comment above a four-space body, and Tab on a blank line inside a tab-indented block). Restoring the oldeditor.js, removing the unit arguments inweb/interview.js, applying one unit to a whole selection, droppingfollowingIndent, measuring the width from the live buffer, letting unindented lines take the choice over a measured starter, consulting the body below for a selection or mid-line caret, counting a comment line as the body, dropping the look at the line above, letting a non-blank line take a tab from above, skipping only line comments, dropping the workspace's unit arguments, or not short-circuiting the default each fails a test. The full browser suite passes exceptmedia-probe.test.js's WebRTC tone test, which fails the same way on cleanmainhere;./scripts/test.shon macOS passes everything this change touches, and the lanes that fail (cargo-test's connection-drain timeout under load, task-authoring's timing ratio, run-budget, interactive-review-hook's/private/varpath, and six git-hooks checks needing shellcheck, ruff or network) fail the same way on cleanmain. Not run: a manual check in a live interview.Screenshots
Lobby: the new Indentation choice in Editor options
JavaScript with 2 spaces: Enter after
{nests by two at each levelClose #589
Summary by cubic
Lets candidates choose 2 spaces, 4 spaces, or Tab for the editor's indentation in the lobby, instead of the fixed four spaces. The choice is saved in the browser and forwarded to the interview via an
editorIndentURL parameter, and drives Tab, Shift+Tab, and auto-indent after Enter. Four spaces remains the default and leaves no URL parameter, so existing interview URLs and the task page behave exactly as before. Closes #589.Written for commit 4b4385a. Summary will update on new commits.