From eded05ea697ba875519af9c147c7dcc69f5c5cd5 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke <marijnh@gmail.com> Date: Sun, 22 Jul 2012 23:00:28 +0200 Subject: [PATCH] Use a zero-width space for end-of-line placeholder in IE8+ They magically wrap when a real space is added. --- lib/codemirror.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 5591cd6d4..89401a976 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -2665,7 +2665,12 @@ var CodeMirror = (function() { outPos += l; span_(text, style); // Output empty wrapper when at end of line - if (outPos == wrapAt && outPos == len) html.push(open + (gecko ? "​" : " ") + "</span>"); + // (Gecko and IE8+ do strange wrapping when adding a space + // to the end of the line. Other browsers don't react well + // to zero-width spaces. So we do hideous browser sniffing + // to determine which to use.) + if (outPos == wrapAt && outPos == len) + html.push(open + (gecko || (ie && !ie_lt8) ? "​" : " ") + "</span>"); // Stop outputting HTML when gone sufficiently far beyond measure else if (outPos > wrapAt + 10 && /\s/.test(text)) span = function(){}; } -- GitLab