Skip to content

Editor: Format Document (Shift+Alt+F) does nothing #68

Description

@KrisPowers

The Format Document command appears in the Edit menu and Shift+Alt+F is listed as its shortcut, but pressing it does nothing. The handler in FullscreenIDE.tsx is explicitly a no-op with a comment acknowledging it has no equivalent yet.

What needs to happen

The most practical path here is to call external formatters based on the file language, similar to how most editors handle this:

  • TypeScript / TSX / JS: call prettier or eslint --fix if available in the project
  • Rust: call rustfmt
  • Go: call gofmt
  • Python: call black or autopep8
  • C / C++: call clang-format
  • JSON: can be done in-house with JSON.stringify(JSON.parse(...), null, 2) since we already parse JSON

The formatter should be invoked via the C++ backend (similar to how shell commands work), the formatted text piped back, and the editor buffer replaced with the result. If no formatter is found for the language, show a small notification rather than silently doing nothing.

Files likely involved

  • app/frontend/src/fullscreen/FullscreenIDE.tsx -- the menu command handler
  • app/frontend/src/components/GpuEditor.tsx -- would need a "replace all content" API
  • cpp/src/ -- new formatter invocation logic
  • A language-to-formatter map

Acceptance criteria

  • Shift+Alt+F on a JS/TS file runs prettier if it exists and replaces the buffer
  • On a Rust file, runs rustfmt
  • On a file with no known formatter, shows a small "No formatter available for [language]" toast
  • Cursor position is preserved where possible after formatting

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions