@@ -32,6 +32,9 @@ SOFTWARE.
32
32
p . cm = null ;
33
33
p . canvas = null ;
34
34
p . fill = "#6CF" ;
35
+ p . lineSpacing = 2 ;
36
+ p . lastBottom = - 1 ;
37
+ p . lastRight = - 1 ;
35
38
36
39
p . initialize = function ( cm , canvas , fill ) {
37
40
this . cm = cm ;
@@ -52,7 +55,7 @@ SOFTWARE.
52
55
var scroll = cm . getScrollInfo ( ) ;
53
56
var top = cm . indexFromPos ( cm . coordsChar ( { left :0 , top :scroll . top } , "local" ) ) ;
54
57
var bottom = cm . indexFromPos ( cm . coordsChar ( { left :scroll . clientWidth , top :scroll . top + scroll . clientHeight } , "local" ) ) ;
55
-
58
+
56
59
for ( var i = 0 , l = matches . length ; i < l ; i ++ ) {
57
60
var match = matches [ i ] ;
58
61
var active = ( match == activeMatch ) ;
@@ -66,6 +69,7 @@ SOFTWARE.
66
69
if ( active ) { ctx . globalAlpha = 0.6 ; }
67
70
var startRect = cm . charCoords ( startPos , "local" ) ;
68
71
var endRect = cm . charCoords ( endPos , "local" ) ;
72
+
69
73
if ( startRect . bottom == endRect . bottom ) {
70
74
this . drawHighlight ( ctx , startRect . left , startRect . top , endRect . right , endRect . bottom , scroll . top ) ;
71
75
} else {
@@ -87,7 +91,17 @@ SOFTWARE.
87
91
} ;
88
92
89
93
p . drawHighlight = function ( ctx , left , top , right , bottom , scrollY , startCap , endCap ) {
90
- var capW = 4 ;
94
+ var capW = 5 ;
95
+
96
+ left = left + 0.5 | 0 ;
97
+ right = right + 0.5 | 0 ;
98
+ top = top + 0.5 | 0 + this . lineSpacing ;
99
+ bottom = bottom + 0.5 | 0 ;
100
+
101
+ if ( top > this . lastBottom - 1 ) { this . lastBottom = bottom ; }
102
+ else if ( left < this . lastRight ) { left = this . lastRight ; }
103
+ this . lastRight = right ;
104
+
91
105
var a = ctx . globalAlpha ;
92
106
if ( startCap ) {
93
107
ctx . globalAlpha = a * 0.5 ;
@@ -105,6 +119,7 @@ SOFTWARE.
105
119
106
120
p . clear = function ( ) {
107
121
this . canvas . width = this . canvas . width ;
122
+ this . lastBottom = - 1 ;
108
123
} ;
109
124
110
125
window . SourceHighlighter = SourceHighlighter ;
0 commit comments