Skip to content

Commit eded05e

Browse files
committed
Use a zero-width space for end-of-line placeholder in IE8+
They magically wrap when a real space is added.
1 parent f4f023a commit eded05e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/codemirror.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2665,7 +2665,12 @@ var CodeMirror = (function() {
26652665
outPos += l;
26662666
span_(text, style);
26672667
// Output empty wrapper when at end of line
2668-
if (outPos == wrapAt && outPos == len) html.push(open + (gecko ? "&#x200b;" : " ") + "</span>");
2668+
// (Gecko and IE8+ do strange wrapping when adding a space
2669+
// to the end of the line. Other browsers don't react well
2670+
// to zero-width spaces. So we do hideous browser sniffing
2671+
// to determine which to use.)
2672+
if (outPos == wrapAt && outPos == len)
2673+
html.push(open + (gecko || (ie && !ie_lt8) ? "&#x200b;" : " ") + "</span>");
26692674
// Stop outputting HTML when gone sufficiently far beyond measure
26702675
else if (outPos > wrapAt + 10 && /\s/.test(text)) span = function(){};
26712676
}

0 commit comments

Comments
 (0)