Skip to content

Commit

Permalink
Add resetSelectionOnContextMenu option
Browse files Browse the repository at this point in the history
  • Loading branch information
janodvarko authored and marijnh committed Oct 8, 2013
1 parent 64e4c6a commit 9ebe46e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -2183,7 +2183,11 @@ window.CodeMirror = (function() {

var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
if (!pos || opera) return; // Opera is difficult.
if (posEq(sel.from, sel.to) || posLess(pos, sel.from) || !posLess(pos, sel.to))

// Reset the current text selection only if the click is done outside of the selection
// and 'resetSelectionOnContextMenu' option is true.
var reset = cm.options.resetSelectionOnContextMenu;
if (reset && (posEq(sel.from, sel.to) || posLess(pos, sel.from) || !posLess(pos, sel.to)))
operation(cm, setSelection)(cm.doc, pos, pos);

var oldCSS = display.input.style.cssText;
Expand Down Expand Up @@ -3290,6 +3294,8 @@ window.CodeMirror = (function() {
option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true);
option("showCursorWhenSelecting", false, updateSelection, true);

option("resetSelectionOnContextMenu", true);

option("readOnly", false, function(cm, val) {
if (val == "nocursor") {onBlur(cm); cm.display.input.blur();}
else if (!val) resetInput(cm, true);
Expand Down

0 comments on commit 9ebe46e

Please sign in to comment.