Skip to content

Commit

Permalink
Fix copy/paste in IE
Browse files Browse the repository at this point in the history
  • Loading branch information
akimball authored and marijnh committed May 4, 2013
1 parent 9d92920 commit 53bc4b1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion addon/runmode/runmode.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
CodeMirror.runMode = function(string, modespec, callback, options) {
var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
var isIe8OrEarlier = /\bMSIE\s(\d+)/.exec(navigator.userAgent);
isIe8OrEarlier = isIe8OrEarlier && +isIe8OrEarlier[1] <= 8;

if (callback.nodeType == 1) {
var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
var node = callback, col = 0;
node.innerHTML = "";
callback = function(text, style) {
if (text == "\n") {
node.appendChild(document.createElement("br"));
// Emitting LF or CRLF on IE8 or earlier results in an incorrect display.
// Emitting a carriage return makes everything ok.
var newLine = isIe8OrEarlier ? '\r' : text;
var newLineSpan = node.appendChild(document.createElement("span"));
newLineSpan.appendChild( document.createTextNode(newLine));
col = 0;
return;
}
Expand Down

0 comments on commit 53bc4b1

Please sign in to comment.