Skip to content

feat(editor): add formatter status bar with smart configuration managment#16829

Merged
sgraband merged 3 commits intomasterfrom
sg/displayFormatter
Feb 23, 2026
Merged

feat(editor): add formatter status bar with smart configuration managment#16829
sgraband merged 3 commits intomasterfrom
sg/displayFormatter

Conversation

@sgraband
Copy link
Contributor

@sgraband sgraband commented Jan 14, 2026

What it does

Introduce a new FormatterService abstraction and enhanced status bar
integration for managing document formatters across the editor.

New FormatterService (editor-formatter-service.ts):

  • Define FormatterService interface for formatter management
  • Provide formatter status, availability, and configuration APIs
  • Support preference scope detection (User/Workspace/Folder)
  • Emit events when formatters change

Monaco implementation (monaco-formatter-service.ts):

  • Implement FormatterService using Monaco's language features
  • Extract formatter metadata from registered providers
  • Integrate with Theia's preference system for persistence

Formatter status contribution (editor-formatter-status-contribution.ts):

  • Extract formatter-specific UI logic to dedicated contribution
  • Handle display info for 0, 1, and multiple formatter scenarios
  • Show warning/error icons for misconfigured formatters
  • Provide quick pick for formatter selection with scope handling

Status bar integration (editor-language-status-service.ts):

  • Add support for pinning language status items to the status bar
  • Add Configure and Info buttons for formatter items in the tooltip
  • Track pinned items to properly update on editor changes

Follow-ups

Breaking changes

  • This PR introduces breaking changes and requires careful review. If yes, the breaking changes section in the changelog has been updated.

Attribution

Review checklist

Reminder for reviewers

@github-project-automation github-project-automation bot moved this to Waiting on reviewers in PR Backlog Jan 14, 2026
@sgraband sgraband requested a review from ndoschek January 14, 2026 15:43
Copy link
Member

@ndoschek ndoschek left a comment

Choose a reason for hiding this comment

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

Hi @sgraband, thanks for this improvement!
Overall it looks solid to me already, but I noticed one issue and have a few suggestions, would be great if you can take another look, TIA!

  1. I have one issue, when testing the formatter item in the Theia example app.
    When I try to switch the formatter, e.g. to the markdown table formatter, which is not configured as default one, I get this console error:
preference-service.ts:455 Uncaught (in promise) Error: Unable to write to Folder Settings because no resource is provided.
    at PreferenceServiceImpl.set (preference-service.ts:455:19)
    at MonacoFormatterService.setDefaultFormatter (monaco-formatter-service.ts:184:38)
    at EditorLanguageStatusService.showFormatterQuickPick (editor-language-status-service.ts:328:37)
  1. I would prefer if we integrate the formatter item in the languageStatusItem ( { } ). This way the user could still pin the item if needed and we do not show it by default.
Image

Also, could you please update the PR template, e.g. add a few test instructions, also for later reference.

PS: As discussed offline, I found a few issues with general formatting and configuring the formatting overall, but I will address this separately (GH-15959) after this PR is done.

@ndoschek ndoschek mentioned this pull request Jan 27, 2026
30 tasks
@sgraband sgraband force-pushed the sg/displayFormatter branch 2 times, most recently from 46a75dc to fb2be7e Compare January 30, 2026 10:16
@sgraband sgraband marked this pull request as ready for review January 30, 2026 10:17
@sgraband sgraband requested a review from ndoschek January 30, 2026 10:17
Copy link
Member

@ndoschek ndoschek left a comment

Choose a reason for hiding this comment

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

Thanks for the update, this is great that it is embedded in the language status bar item now!

I just noticed one issue:
I think somehow folder and workspace scope got mixed up:
When i am in a single workspace, e.g. theia, I get this info for my current formatter: Configured in Folder Settings and when i am in a multi-root workspace I get Configured in Workspace Settings, while it should exactly be the other way round.

Would be great if you could have another look, TIA

…ement

Introduce a new FormatterService abstraction and enhanced status bar
integration for managing document formatters across the editor.

New FormatterService (editor-formatter-service.ts):
- Define FormatterService interface for formatter management
- Provide formatter status, availability, and configuration APIs
- Support preference scope detection (User/Workspace/Folder)
- Emit events when formatters change

Monaco implementation (monaco-formatter-service.ts):
- Implement FormatterService using Monaco's language features
- Extract formatter metadata from registered providers
- Integrate with Theia's preference system for persistence

Formatter status contribution (editor-formatter-status-contribution.ts):
- Extract formatter-specific UI logic to dedicated contribution
- Handle display info for 0, 1, and multiple formatter scenarios
- Show warning/error icons for misconfigured formatters
- Provide quick pick for formatter selection with scope handling

Status bar integration (editor-language-status-service.ts):
- Add support for pinning language status items to the status bar
- Add Configure and Info buttons for formatter items in the tooltip
- Track pinned items to properly update on editor changes
Fix race condition in EditorLanguageStatusService that caused duplicate
pinned status bar items when switching between editors.

Root cause: The .finally() block cleared pendingUpdate prematurely after
intermediate updates completed, and language mode element updates happened
outside the promise chain. This allowed parallel execution of updates,
corrupting currentlyPinnedItems tracking.

Solution: Introduce scheduleUpdate() to chain ALL status bar operations
through a single promise chain, including language mode element updates.
This ensures updates are serialized and pinned items are properly tracked.
Signed-off-by: Simon Graband <sgraband@eclipsesource.com>
@sgraband sgraband force-pushed the sg/displayFormatter branch from fb2be7e to d6c086b Compare February 23, 2026 13:59
Copy link
Member

@ndoschek ndoschek left a comment

Choose a reason for hiding this comment

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

Thank you @sgraband for the updates, code looks good to me and everything works now as expected. 👍

/* ADDED STYLES - NOT FROM VSCODE */
text-decoration: none;
cursor: pointer;
padding: 2px 6px;
Copy link
Member

Choose a reason for hiding this comment

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

nit: we could reuse theia CSS variables here and for the margin below

@github-project-automation github-project-automation bot moved this from Waiting on reviewers to Needs merge in PR Backlog Feb 23, 2026
@sgraband sgraband merged commit 65eeabe into master Feb 23, 2026
10 checks passed
@sgraband sgraband deleted the sg/displayFormatter branch February 23, 2026 15:09
@github-project-automation github-project-automation bot moved this from Needs merge to Done in PR Backlog Feb 23, 2026
@github-actions github-actions bot added this to the 1.69.0 milestone Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants