ocurrent / ocaml-ci

A CI for OCaml projects
https://ocaml.ci.dev
112 stars 74 forks source link

Correct copy-paste behaviour in logs #879

Closed benmandrew closed 11 months ago

benmandrew commented 11 months ago

This PR fixes two issues:

  1. Currently when copy-pasting logs on Firefox, an extra newline is added to each line. This is related to the CSS property user-select: none (and browser-specific variants) that is attached to the line number span to the left of each log line. This PR removes the CSS property which fixes the issue. Fixes #875.

There is a slight regression on Safari in that the line numbers now have the appearance of being partially selected along with the log lines, however the line numbers themselves (which are ::before pseudo-elements) are not copied and the pasting behaviour is as expected. It appears that when selecting text in Safari, the containing element is highlighted rather than the text itself. As it makes no functional difference, I'll let it be.

  1. In Chrome and Safari, copy-pasted logs do not include a space between paragraphs (i.e. two newlines) when they should. Firefox currently does include this. As a fix, this PR replaces empty log lines with newline characters which creates the correct behaviour in Chrome and Safari. In Firefox there are now two spaces between each paragraph, but I would rather have two spaces than no spaces so I include this fix.

Correct paragraph behaviour; Firefox pre-fix and Chrome and Safari post-fix:

/: (comment macos-homebrew-4.14.1_arm64_opam-2.1)

/: (user (uid 1000) (gid 1000))

Incorrect behaviour; Chrome and Safari pre-fix:

/: (comment macos-homebrew-4.14.1_arm64_opam-2.1)
/: (user (uid 1000) (gid 1000))

Incorrect behaviour; Firefox post-fix:

/: (comment macos-homebrew-4.14.1_arm64_opam-2.1)

/: (user (uid 1000) (gid 1000))

Tested on Macos M1, on Chrome (117.0.5938.92), Firefox (117.0.1), and Safari (15.6.1).