Skip to content

feat: customize spacing #131

Closed
Closed

Description

@kbuffardi

Problem

The editor is defaulting to the tab button being translated into the equivalent into 4 space indentation. Instead, the user should have control over indentation options.

Proposed solution

Add a notification in the bottom status bar, after the status-cursor location, that shows the spacing such as: Spacing: 2 spaces ^ but show it inside a dropdown button. However, it should be "dropup" button instead, as indicated by the ^, which indicates clicking on it will open choices above it (rather than below)

If the user clicks the Spacing button, they should have three options: 2 spaces .., 4 spaces ...., and Tab ⇥ (ending with U+21E5 character). By default, 2 spaces should be selected, unless the file is named Makefile or *.makefile in which case Tab should be the default. The selection should be file-specific so that different standards can be applied to different files of the same project. The selection should affect the indentation of the editor, such as when the user enters a [tab] or when the editor automatically indents in a nested code segment. If a new standard is selected, it should be the default for all future files, with the exception of Makefiles (previously mentioned) should always default to a tab.

The dropup selections should also include an option (separated by a horizontal line) for "Apply to file") which if clicked, applies the new indentation standard to the existing code in the open file. For instance, if a file has 4 spaces for each level of indentation is used but the user selects "2 spaces .." then all indentations that are 4 spaces should be converted to 2.

Alternatives considered

No response

Acceptance criteria

No response

Suggested priority

Low

Additional context

No response

Before submitting

  • I searched existing issues and did not find an existing request for this feature.

Activity

  1. kbuffardi commented on Nov 6, 2026

    @kbuffardi
    OwnerAuthor

    Confirmed implementation plan

    The original file-specific wording is superseded by the confirmed behavior below:

    • Persist two extension-wide indentation defaults: one for Makefiles and one for all other files.
    • Treat files named Makefile or matching *.makefile as the Makefile category; all other files use the general category.
    • A selection changes the default editor indentation behavior for every file in its category, including future active files in that category.
    • General files default to two spaces; Makefiles default to tabs. Users may choose any of the three options for either category.
    • Do not automatically rewrite source text when a default changes.
    • Apply to file converts only the active file's leading indentation, preserves alignment and continuation whitespace, and produces one undoable edit.
    • Do not add per-file overrides or persist spacing state in the project session.

    Implementation will add a status-bar dropup after the cursor status, persistent settings, Monaco indentation updates, active-tab category handling, and focused regression coverage. The implementation will be submitted in a pull request that closes #131.

  2. kbuffardi commented on Nov 6, 2026

    @kbuffardi
    OwnerAuthor

    Follow-up correction

    User feedback:

    update the "dropup" options so (1) the current selection is bold while the others are not, (2) clicking outside of the options closes the "dropup" without changing the selection, (3) "Apply to file" isn't currently applying the selection to the actively viewed file

    The implementation now makes only the selected radio option bold, closes the dropup on outside clicks without mutating settings, and detects active-document indentation before applying the selected style. Regression coverage was added and PR #133 was updated.

  3. kbuffardi commented on Nov 6, 2026

    @kbuffardi
    OwnerAuthor

    Follow-up visual refinement

    User feedback:

    also, instead of a literal ^ the button should have an up arrow (similar to the cpp-standard down arrow but in the opposite direction) instead of just a caret.

    PR #133 now uses the upward chevron ⌃ in the static control and dynamic label. Focused spacing tests and lint pass.

  4. kbuffardi commented on Nov 6, 2026

    @kbuffardi
    OwnerAuthor

    Revised implementation plan: authoritative editor spacing

    User feedback:

    plan-agent update the plan because the current implementation doesn't work. When the spacing option is changed and I edit the current file to add a new nested block, it is just using 2 spaces all the time. After changing the option, the nesting indentation (and all new indentation) should immediately adopt the new selection. Similarly, the "apply to file" selection isn't making changes to the open file.

    Root causes

    • Monaco content detection remains enabled. Existing two-space text therefore overrides the selected tabSize/insertSpaces values.
    • The current code does not update Monaco's model indentSize, so nested auto-indentation retains two spaces.
    • Apply infers a source policy only at click time and is tested only as a pure helper, not through the controller or a real editor model.

    Planned correction

    1. Make the selection authoritative in editor.js: initialize and update Monaco with detectIndentation: false, plus aligned tabSize, indentSize, and insertSpaces values.
    2. Capture an active document's original indentation policy before applying a newly selected category policy. Apply will convert from this observed source to the selected target, with detection only as a fallback.
    3. Preserve the current contract: selection changes future/new indentation only; Apply converts leading indentation in only the active document and never writes disk or inactive tabs.
    4. Add controller tests for select-then-Apply and a browser smoke test that verifies both real Monaco model options and a newly typed nested C++ block. Include tab/Makefile coverage.

    Acceptance criteria

    • Selecting 2 spaces, 4 spaces, or tabs immediately controls Monaco's Tab and nested-block indentation despite the file's existing content.
    • Apply visibly converts the active model to the selected policy without changing interior/alignment whitespace, inactive tabs, or disk files.
    • The new controller and browser tests fail against the current PR implementation and pass with the correction.
  5. kbuffardi commented on Nov 6, 2026

    @kbuffardi
    OwnerAuthor

    Implementation update: selected spacing is authoritative

    User feedback:

    the spacing selection still isnt' working correctly. I edited an existing file (With 2 spaces), changed the option to Tab and it did nothing when I wrote new code in the file:

    The fix now disables Monaco's content-based indentation detection and sets tabSize, indentSize, and insertSpaces together for every selection. This prevents existing two-space content from overriding Tab or four-space behavior, without changing document text during selection. PR #133 and local dist/ outputs were rebuilt with the correction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions