Skip to content

Add editor font size setting#531

Merged
makermelissa merged 1 commit into
circuitpython:betafrom
makermelissa-ai-assistant:issue-353-font-size
Jul 17, 2026
Merged

Add editor font size setting#531
makermelissa merged 1 commit into
circuitpython:betafrom
makermelissa-ai-assistant:issue-353-font-size

Conversation

@makermelissa-ai-assistant

@makermelissa-ai-assistant makermelissa-ai-assistant commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a Font Size number input to the settings dialog
  • clamp saved font sizes between 8px and 48px
  • apply the saved font size to both CodeMirror and the Serial terminal on startup and after saving settings
  • keep existing settings intact when the Settings dialog is canceled or closed

Testing

  • npm run build
  • browser smoke test: changed Font Size from 16 to 22 and verified the editor computed font size changed to 22px
  • verified the built bundle includes xterm fontSize updates and the settings-dialog cancel fallback

Refs #353

@makermelissa makermelissa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, found a few bugs along the way, but it appears to be working well.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a user-configurable editor font size setting and applies it consistently across both the CodeMirror editor and the xterm serial terminal, including on startup and after saving settings. It also updates the Settings dialog so cancel/close no longer overwrites existing settings, and adjusts the dialog layout styling to accommodate the new control.

Changes:

  • Add editorFontSize as a numeric setting (8–48px) and render it in the Settings dialog.
  • Clamp numeric setting values on save and apply the configured font size to CodeMirror (via a compartment) and xterm (via options.fontSize) after settings changes.
  • Update Settings dialog behavior so cancel/close does not replace the existing settings object.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
sass/layout/_layout.scss Switch Settings dialog layout to a two-column grid suitable for label/control pairs (including the new number input).
js/script.js Introduce font-size setting plumbing and apply it to CodeMirror and xterm (including refitting the terminal after changes).
js/layout.js Export refitTerminal() for reuse from the main script.
js/common/settings.js Add a numeric input type, clamp number values on save, and avoid overwriting settings when the dialog is canceled/closed.
Comments suppressed due to low confidence (1)

js/layout.js:158

  • refitTerminal() can be invoked during layout.js module initialization (via fixViewportHeight() / loadPanelSettings()), before setupXterm() assigns state.terminal. In that case the current implementation will throw when it dereferences state.terminal._core.... Add an early guard so the function safely no-ops until the terminal has been created/opened.
export function refitTerminal() {
    // Custom function to replace the terminal refit function as it was a bit buggy

    // Re-fitting the terminal requires a full re-layout of the DOM which can be tricky to time right.
    // see https://www.macarthur.me/posts/when-dom-updates-appear-to-be-asynchronous

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@makermelissa
makermelissa merged commit d494e0a into circuitpython:beta Jul 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants