Skip to content

Commit cb1a877

Browse files
committed
CodeCoverage: fixed lines background after scrolling to right
1 parent 928cc28 commit cb1a877

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

src/CodeCoverage/Generators/template.phtml

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,36 +35,47 @@
3535
div.code {
3636
background: white;
3737
border: 1px dotted silver;
38+
padding: .4em 0;
3839
display: none;
3940
color: #333;
40-
position: relative;
4141
overflow: auto;
4242
}
4343

4444
code,
4545
div.code {
4646
font: 13px/1.3 monospace;
47-
padding: .4em .7em;
4847
}
4948

50-
div.code div {
49+
div.code > div {
50+
float: left;
51+
min-width: 100%;
52+
position: relative;
53+
}
54+
55+
aside {
56+
min-width: 100%;
57+
position: absolute;
58+
}
59+
60+
aside div {
5161
white-space: pre;
62+
padding-left: .7em;
5263
}
5364

54-
div.code a {
65+
aside a {
5566
color: #c0c0c0;
5667
}
5768

58-
div.code a:hover {
69+
aside a:hover {
5970
color: inherit;
6071
font-weight: bold;
6172
text-decoration: none;
6273
}
6374

6475
code {
76+
display: block;
6577
white-space: nowrap;
66-
position: absolute;
67-
top: 0;
78+
position: relative;
6879
}
6980

7081
a {
@@ -139,10 +150,12 @@
139150
</table>
140151

141152
<div class="code" id="F<?= $id ?>">
142-
<?php
153+
<div>
154+
<aside>
155+
<?php
143156
$code = file_get_contents($info->file);
144157
$lineCount = substr_count($code, "\n") + 1;
145-
$digits = ceil(log10($lineCount));
158+
$digits = ceil(log10($lineCount)) + 1;
146159

147160
$prevClass = NULL;
148161
$closeTag = $buffer = '';
@@ -163,11 +176,15 @@
163176
}
164177
echo $buffer . $closeTag;
165178

166-
echo strtr(highlight_string($code, TRUE), [
167-
'<code>' => "<code style='left: {$digits}em'>",
179+
$code = strtr(highlight_string($code, TRUE), [
180+
'<code>' => "<code style='margin-left: {$digits}em'>",
168181
'<span style="color: ' => '<span class="',
169182
]);
170-
?></div>
183+
?>
184+
</aside>
185+
<?= $code ?>
186+
</div>
187+
</div>
171188
</div>
172189
<?php endforeach ?>
173190

0 commit comments

Comments
 (0)