@@ -60,7 +60,7 @@ var CodeMirror = (function() {
6060 // whether the user is holding shift. reducedSelection is a hack
6161 // to get around the fact that we can't create inverted
6262 // selections. See below.
63- var shiftSelecting , reducedSelection , lastDoubleClick ;
63+ var shiftSelecting , reducedSelection , lastClick , lastDoubleClick ;
6464 // Variables used by startOperation/endOperation to track what
6565 // happened during the operation.
6666 var updateInput , changes , textChanged , selectionChanged , leaveInputAlone , gutterDirty ;
@@ -84,7 +84,6 @@ var CodeMirror = (function() {
8484 // which point we can't mess with it anymore. Context menu is
8585 // handled in onMouseDown for Gecko.
8686 if ( ! gecko ) connect ( scroller , "contextmenu" , onContextMenu ) ;
87- connect ( code , "dblclick" , operation ( onDblClick ) ) ;
8887 connect ( scroller , "scroll" , function ( ) {
8988 updateDisplay ( [ ] ) ;
9089 if ( options . fixedGutter ) gutter . style . left = scroller . scrollLeft + "px" ;
@@ -238,7 +237,7 @@ var CodeMirror = (function() {
238237 // Check whether this is a click in a widget
239238 for ( var n = e_target ( e ) ; n != wrapper ; n = n . parentNode )
240239 if ( n . parentNode == code && n != mover ) return ;
241- var ld = lastDoubleClick ; lastDoubleClick = null ;
240+
242241 // First, see if this is a click in the gutter
243242 for ( var n = e_target ( e ) ; n != wrapper ; n = n . parentNode )
244243 if ( n . parentNode == gutterText ) {
@@ -264,17 +263,18 @@ var CodeMirror = (function() {
264263
265264 if ( ! focused ) onFocus ( ) ;
266265 e_preventDefault ( e ) ;
267- if ( ld && + new Date - ld < 400 ) return selectLine ( start . line ) ;
266+
267+ var now = + new Date ;
268+ if ( lastDoubleClick > now - 400 ) {
269+ return selectLine ( start . line ) ;
270+ } else if ( lastClick > now - 400 ) {
271+ lastDoubleClick = now ;
272+ return selectWordAt ( start ) ;
273+ } else { lastClick = now ; }
268274
269275 setCursor ( start . line , start . ch , true ) ;
270276 var last = start , going ;
271- // And then we have to see if it's a drag event, in which case
272- // the dragged-over text must be selected.
273- function end ( ) {
274- focusInput ( ) ;
275- updateInput = true ;
276- move ( ) ; up ( ) ;
277- }
277+
278278 function extend ( e ) {
279279 var cur = posFromMouse ( e , true ) ;
280280 if ( cur && ! posEq ( cur , last ) ) {
@@ -298,16 +298,11 @@ var CodeMirror = (function() {
298298 var cur = posFromMouse ( e ) ;
299299 if ( cur ) setSelectionUser ( start , cur ) ;
300300 e_preventDefault ( e ) ;
301- end ( ) ;
301+ focusInput ( ) ;
302+ updateInput = true ;
303+ move ( ) ; up ( ) ;
302304 } ) , true ) ;
303305 }
304- function onDblClick ( e ) {
305- var pos = posFromMouse ( e ) ;
306- if ( ! pos ) return ;
307- selectWordAt ( pos ) ;
308- e_preventDefault ( e ) ;
309- lastDoubleClick = + new Date ;
310- }
311306 function onDrop ( e ) {
312307 e . preventDefault ( ) ;
313308 var pos = posFromMouse ( e , true ) , files = e . dataTransfer . files ;
0 commit comments