feat(editor): add formatter status bar with smart configuration managment#16829
feat(editor): add formatter status bar with smart configuration managment#16829
Conversation
ndoschek
left a comment
There was a problem hiding this comment.
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!
- 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)
- 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.
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.
packages/editor/src/browser/language-status/editor-language-status-service.ts
Outdated
Show resolved
Hide resolved
packages/editor/src/browser/language-status/editor-language-status-service.ts
Outdated
Show resolved
Hide resolved
packages/editor/src/browser/language-status/editor-language-status-service.ts
Show resolved
Hide resolved
46a75dc to
fb2be7e
Compare
ndoschek
left a comment
There was a problem hiding this comment.
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
packages/editor/src/browser/language-status/editor-language-status-service.ts
Show resolved
Hide resolved
packages/editor/src/browser/language-status/editor-formatter-status-contribution.ts
Outdated
Show resolved
Hide resolved
…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>
fb2be7e to
d6c086b
Compare
| /* ADDED STYLES - NOT FROM VSCODE */ | ||
| text-decoration: none; | ||
| cursor: pointer; | ||
| padding: 2px 6px; |
There was a problem hiding this comment.
nit: we could reuse theia CSS variables here and for the margin below
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):
Monaco implementation (monaco-formatter-service.ts):
Formatter status contribution (editor-formatter-status-contribution.ts):
Status bar integration (editor-language-status-service.ts):
Follow-ups
Breaking changes
Attribution
Review checklist
nlsservice (for details, please see the Internationalization/Localization section in the Coding Guidelines)Reminder for reviewers