On some browsers/platforms, single-line preformatted text that runs off the screen is difficult to use.
On MacOS Chrome, in particular, the instant you hover over the text the horizontal scrollbar obscures the text, and then never goes away again, no matter how long you leave your cursor somewhere else on the screen. It makes it difficult to read or select the text:
On MacOS Firefox, the scrollbar does not appear when you hover over the text. The only way to see text that runs off the screen is to select the text and pull your cursor to the right of the screen. Then the scrollbar briefly appears (and obscures the text just as in MacOS Chrome), but goes away very quickly and is generally unusable.
Safari has the same behaviour as Firefox.
I know there are some hacky ways to detect scrollbar width in javascript, but I’m not sure if this is actually a Discourse bug or a browser bug?
I don’t want arbitrary wrapping when I post code, I want it to scroll. It’s precisely what the <pre> tag is for, I only use the single backticks for inline code.
I don’t agree that opting out of using an inadequate alternative to avoid a bug is a self-inflicted wound.
This has 0% to do with Discourse, and 100% to do with rendering choices of particular browsers on particular operating systems. You can “fix” it by adding CSS that targets those particular browsers and operating systems, if you want.
For me the scrollbar disappears soon after the pointer is moved away from the code area. To read the overflowing code, you can scroll horizontally, and then move the move the mouse out of the way. In a second or so, the scrollbar disappears.
For context, macOS has three options for scrollbars:
I tested the link in the OP with the other two options, and “When scrolling” behaves the same way (i.e. scrollbar fades out once mouse is away from the code block) whereas “Always” will display the scrollbar below the one-liner in your linked example:
You can easily add some padding in a theme component, @awesomerobot or @Johani can suggest something.
Technically we could do a conversion like this in a Markdown plugin, but we would then diverge from spec quite drastically, so I am very uncomfortable making a change like that.
Adding padding though for your site is trivial if you must, or teaching users there is another option.