Skip to content

Commit

Permalink
Fix another problem caused by the hack for codemirror#1474
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh authored and anaran committed Feb 22, 2014
1 parent 8a25485 commit 15a63b2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ window.CodeMirror = (function() {
on(d.scroller, "dragover", drag_);
on(d.scroller, "drop", operation(cm, onDrop));
}
on(d.scroller, "paste", function(e){
on(d.scroller, "paste", function(e) {
if (eventInWidget(d, e)) return;
focusInput(cm);
fastPoll(cm);
Expand All @@ -1609,7 +1609,7 @@ window.CodeMirror = (function() {
// Workaround for webkit bug https://bugs.webkit.org/show_bug.cgi?id=90206
// Add a char to the end of textarea before paste occur so that
// selection doesn't span to the end of textarea.
if (webkit && !cm.state.fakedLastChar) {
if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) {
var start = d.input.selectionStart, end = d.input.selectionEnd;
d.input.value += "$";
d.input.selectionStart = start;
Expand Down Expand Up @@ -1679,6 +1679,7 @@ window.CodeMirror = (function() {
if (captureMiddleClick) onContextMenu.call(cm, cm, e);
return;
case 2:
if (webkit) cm.state.lastMiddleDown = +new Date;
if (start) extendSelection(cm.doc, start);
setTimeout(bind(focusInput, cm), 20);
e_preventDefault(e);
Expand Down

0 comments on commit 15a63b2

Please sign in to comment.