@@ -158,10 +158,24 @@ var setSelectHandlers = function()
158158 return false ;
159159 }
160160
161- var srcElement = findParentElementByTag ( event . srcElement , "div" ) ;
161+ var srcElement = findParentElementByTag ( event . target , "div" ) ;
162162 file . onmouseover = function ( event2 ) {
163+ // not quite the right target, but we adjust
163164 var target2 = findParentElementByTag ( event2 . target , "div" ) ;
164- showSelection ( file , srcElement , target2 ) ;
165+ if ( target2 . getAttribute ( "index" ) == null ) {
166+ // hit testing hit a button -> we need to find the sibling which is under
167+ var hit = function ( elem ) {
168+ var top = elem . offsetTop ;
169+ var bottom = top + elem . offsetHeight ;
170+ return top < event2 . y &&
171+ bottom >= event2 . y ;
172+ }
173+ while ( target2 && ! hit ( target2 ) ) {
174+ target2 = target2 . nextSibling
175+ }
176+ }
177+ if ( target2 )
178+ showSelection ( file , srcElement , target2 ) ;
165179 return false ;
166180 } ;
167181 showSelection ( file , srcElement , srcElement ) ;
@@ -354,10 +368,15 @@ var stageLines = function(reverse) {
354368/* Compute the selection before actually making it. Return as object
355369 * with 2-element array "bounds", and "good", which indicates if the
356370 * selection contains add/del lines. */
357- var computeSelection = function ( list , from , to )
371+ var computeSelection = function ( list , from , to )
358372{
359373 var startIndex = parseInt ( from . getAttribute ( "index" ) ) ;
360- var endIndex = parseInt ( to . getAttribute ( "index" ) ) ;
374+ var toIndex = to . getAttribute ( "index" ) ;
375+ if ( toIndex === null ) {
376+ to = to . nextSibling ; // or the next one
377+ toIndex = to . getAttribute ( "index" ) ;
378+ }
379+ var endIndex = parseInt ( toIndex ) ;
361380 if ( startIndex == - 1 || endIndex == - 1 ) {
362381 return false ;
363382 }
0 commit comments