Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for #3261 Selection problem in IE11, when leaving an iframe while selecting #3272

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
focused: false,
suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
selectingText: false,
draggingText: false,
highlight: new Delayed(), // stores highlight worker timeout
keySeq: null, // Unfinished key sequence
Expand Down Expand Up @@ -3567,7 +3568,8 @@
var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) &&
type == "single" && (contained = sel.contains(start)) > -1 &&
!sel.ranges[contained].empty())
!sel.ranges[contained].empty() &&
!cm.state.selectingText)
leftButtonStartDrag(cm, e, start, modifier);
else
leftButtonSelect(cm, e, start, type, modifier);
Expand Down Expand Up @@ -3607,6 +3609,12 @@
var display = cm.display, doc = cm.doc;
e_preventDefault(e);

// #3261: make sure, that we're not starting a second selection
if (cm.state.selectingText) {
cm.state.selectingText(e);
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not check this in onMouseDown? That'd also save the extra condition above (when deciding between a drag and a select).

}

var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
if (addNew && !e.shiftKey) {
ourIndex = doc.sel.contains(start);
Expand Down Expand Up @@ -3727,6 +3735,7 @@
}

function done(e) {
cm.state.selectingText = false;
counter = Infinity;
e_preventDefault(e);
display.input.focus();
Expand All @@ -3740,6 +3749,7 @@
else extend(e);
});
var up = operation(cm, done);
cm.state.selectingText = up;
on(document, "mousemove", move);
on(document, "mouseup", up);
}
Expand Down