Closed davidbrochart closed 4 days ago
It looks like this may be some weird interaction between the emoji and the added style for the extension - presumably the usual issue of emoji widths? If you remove the styling for the extension, the screenshot no longer shows that empty space.
I didn't think the screenshots in the docs had this empty space before, so I quickly checked the history using git bisect. It looks like this was introduced with the normalisation of the SVGs in #4675.
from textual.app import App, ComposeResult
from textual.widgets import DirectoryTree
class DirectoryTreeApp(App):
CSS = """
DirectoryTree > .directory-tree--extension {
text-style: none;
}
"""
def compose(self) -> ComposeResult:
yield DirectoryTree("./")
if __name__ == "__main__":
app = DirectoryTreeApp()
app.run()
That rings a bell. It is an issue with Textual's notion of character widths not matching the browser's.
Segments are positioned according to where Textual things the character starts. When segments are combined, it can result in emoji not being where you would expect.
The normalization of segments is a good thing for tests. It means that inconsequential changes don't break all the snapshots. But it can produce lower quality SVGs.
I think the solution may be to offer the normalization on a switch, so that screenshots are exported without it, but tests are still normalized.
Don't forget to star the repository!
Follow @textualizeio for Textual updates.
Running the
DirectoryTree
widget example gives this:But when saved to SVG with the command palette, an extra space is added: