src/common/util.js/replaceEndOfLineWith
function replaceEndOfLineWith(text, replacement) {
  const parts = [];
  for (const part of text.split("\n")) {
    if (parts.length !== 0) {
      parts.push(replacement);
    }
    parts.push(part);
  }
  return parts;
}