Skip to content

Commit

Permalink
Fix dropping of selection in contenteditable input style
Browse files Browse the repository at this point in the history
Issue #3979
  • Loading branch information
marijnh committed May 2, 2016
1 parent 6ddab77 commit b9e0c4c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -1663,9 +1663,9 @@
return result;
},

showSelection: function(info) {
showSelection: function(info, takeFocus) {
if (!info || !this.cm.display.view.length) return;
if (info.focus) this.showPrimarySelection();
if (info.focus || takeFocus) this.showPrimarySelection();
this.showMultipleSelections(info);
},

Expand Down Expand Up @@ -3101,7 +3101,7 @@
}

if (op.updatedDisplay || op.selectionChanged)
op.preparedSelection = display.input.prepareSelection();
op.preparedSelection = display.input.prepareSelection(op.focus);
}

function endOperation_W2(op) {
Expand All @@ -3114,8 +3114,9 @@
cm.display.maxLineChanged = false;
}

var takeFocus = op.focus && op.focus == activeElt() && (!document.hasFocus || document.hasFocus())
if (op.preparedSelection)
cm.display.input.showSelection(op.preparedSelection);
cm.display.input.showSelection(op.preparedSelection, takeFocus);
if (op.updatedDisplay || op.startHeight != cm.doc.height)
updateScrollbars(cm, op.barMeasure);
if (op.updatedDisplay)
Expand All @@ -3125,8 +3126,7 @@

if (cm.state.focused && op.updateInput)
cm.display.input.reset(op.typing);
if (op.focus && op.focus == activeElt() && (!document.hasFocus || document.hasFocus()))
ensureFocus(op.cm);
if (takeFocus) ensureFocus(op.cm);
}

function endOperation_finish(op) {
Expand Down

0 comments on commit b9e0c4c

Please sign in to comment.