-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix: Preserve multiple consecutive spaces in Theia UI elements #16935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Preserve multiple consecutive spaces in Theia UI elements #16935
Conversation
|
Hi @awaisahmed119, thank you for your contribution to Theia! Before we can proceed, could you please sign the Eclipse Contributor Agreement (ECA). This is a one-time requirement for contributing to Eclipse Foundation projects. To sign the ECA:
After signing, we can retrigger the ECA check and it should pass automatically and we can run the remaining workflows too. |
9ccf5d6 to
bbccbc1
Compare
Done |
|
should we be setting white-space-collapse instead? white-space changes other behaviors as well other than collapsing spaces, right? |
The white-space-collapse property is newer (CSS Text Level 4) and has limited browser support, making it unsuitable for production use. While white-space does control multiple behaviors (space collapsing, wrapping, and line breaks), you actually need that combined control for this use case. Using white-space: pre gives you both space preservation and no-wrap behavior for tree nodes, while white-space: pre-wrap provides space preservation with wrapping for tooltips. If you used white-space-collapse, you'd need multiple separate properties to achieve the same result with worse browser compatibility. The white-space property seems the correct, widely-supported solution here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall! Nice comprehensive fix for the whitespace issue across multiple UI components.
One small thing, there seems to be a linting issue in tab-bars.ts, could you have a quick look there? TIA!
Fixed. Please have a look. |
d021cbf to
0f5b460
Compare
Fixes: eclipse-theia#16865 PROBLEM: - Multiple consecutive spaces in file/folder names were collapsed to single space - HTML whitespace normalization and textContent API both collapse spaces CSS CHANGES: - tree.css: Applied white-space: pre to .theia-TreeNodeSegment and .theia-TreeNodeSegmentGrow - dialog.css: Applied white-space: pre-wrap to dialog content (li, div) - tabs.css: Applied white-space: pre-wrap to tab hover title and caption - tooltip.css: Applied white-space: pre-wrap to .theia-tooltip - breadcrumbs.css: Applied white-space: pre-wrap to breadcrumb labels - tree-decorators.css: Applied white-space: pre to decorator badges JAVASCRIPT CHANGE: - tab-bars.ts (handleMouseEnterEvent): Replace consecutive spaces with non-breaking spaces (\u00A0) before passing to hover service RATIONALE: - CSS white-space: pre/pre-wrap handles directly rendered HTML elements - JavaScript solution needed for tooltips because hover-service.ts uses textContent which normalizes whitespace BEFORE CSS is applied - Non-breaking spaces (\u00A0) are not collapsed by textContent API - Used 'pre' for short content (tree nodes, badges) to prevent wrapping - Used 'pre-wrap' for long content (tooltips, dialogs, paths) to allow wrapping Fix: Fixed linting issues.
0f5b460 to
c55f16f
Compare
ndoschek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the updates!
This works great, thanks again for this improvement! 🎉
What it does
Fixes multiple consecutive spaces being collapsed to single space in Theia UI elements (explorer tree, dialogs, breadcrumbs, and editor tab tooltips).
How to test
"test file.txt","folder name")Follow-ups
Breaking changes
Attribution
Review checklist
nlsservice (for details, please see the Internationalization/Localization section in the Coding Guidelines)Reminder for reviewers