@@ -158,10 +158,24 @@ var setSelectHandlers = function()
158
158
return false ;
159
159
}
160
160
161
- var srcElement = findParentElementByTag ( event . srcElement , "div" ) ;
161
+ var srcElement = findParentElementByTag ( event . target , "div" ) ;
162
162
file . onmouseover = function ( event2 ) {
163
+ // not quite the right target, but we adjust
163
164
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 ) ;
165
179
return false ;
166
180
} ;
167
181
showSelection ( file , srcElement , srcElement ) ;
@@ -354,10 +368,15 @@ var stageLines = function(reverse) {
354
368
/* Compute the selection before actually making it. Return as object
355
369
* with 2-element array "bounds", and "good", which indicates if the
356
370
* selection contains add/del lines. */
357
- var computeSelection = function ( list , from , to )
371
+ var computeSelection = function ( list , from , to )
358
372
{
359
373
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 ) ;
361
380
if ( startIndex == - 1 || endIndex == - 1 ) {
362
381
return false ;
363
382
}
0 commit comments