Skip to content

Commit 7a011d2

Browse files
committed
wip
1 parent b63d5e8 commit 7a011d2

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed

src/CodeSnippet.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ protected function getBoundsMulti(int $totalNumberOfLineInFile): Bounds
182182
$this->trimSnippetSize($bounds);
183183
$this->updateSnippetLineCount($bounds);
184184

185+
// $surroundedBounds = Bounds::createFromArray($this->surroundingLines);
186+
//
187+
// if ($surroundedBounds->end > $bounds->end) {
188+
// $bounds->end = $surroundedBounds->end + 1;
189+
// }
190+
//
191+
// $this->ensureBoundsAreWithinLimits($bounds, $totalNumberOfLineInFile);
192+
185193
return $bounds;
186194
}
187195

tests/CodeSnippetTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,17 @@ public function it_gets_the_line_number()
136136
$this->assertEquals(3, $snippet->getLineNumberStart());
137137
$this->assertEquals(3, $snippet->getLineNumberEnd());
138138
}
139+
140+
/** @test */
141+
public function it_ensures_the_entire_surrounding_lines_are_displayed()
142+
{
143+
$file = new File($this->testsPath('data/file3.php'));
144+
145+
$snippet = (new CodeSnippet())
146+
->surroundingLines(18, 23)
147+
->snippetLineCount(4)
148+
->fromFile($file);
149+
150+
$this->assertMatchesSnapshot($snippet->getLines());
151+
}
139152
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
17:
2+
selected: false
3+
lineNumber: 17
4+
value: ''
5+
isSelected: false
6+
18:
7+
selected: true
8+
lineNumber: 18
9+
value: ' collect([])'
10+
isSelected: true
11+
19:
12+
selected: true
13+
lineNumber: 19
14+
value: ' ->map(function($a) {'
15+
isSelected: true
16+
20:
17+
selected: true
18+
lineNumber: 20
19+
value: ' return $a;'
20+
isSelected: true
21+
21:
22+
selected: true
23+
lineNumber: 21
24+
value: ' })'
25+
isSelected: true
26+
22:
27+
selected: true
28+
lineNumber: 22
29+
value: ' ->filter()'
30+
isSelected: true
31+
23:
32+
selected: true
33+
lineNumber: 23
34+
value: ' ->ray();'
35+
isSelected: true

tests/data/file3.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
class MyClass
4+
{
5+
protected function test()
6+
{
7+
/**
8+
@var Ray $ray
9+
*/
10+
$ray = ray()->text('hello world')
11+
->blue()
12+
->large();
13+
14+
Ray
15+
::rateLimiter()
16+
->count(5);
17+
18+
collect([])
19+
->map(function($a) {
20+
return $a;
21+
})
22+
->filter()
23+
->ray();
24+
}
25+
}
26+
27+
function test($foo)
28+
{
29+
ray($foo);
30+
31+
// ray(12);
32+
33+
$one = strtolower("test" . ' two');
34+
$two = '2';
35+
36+
if ($two === '2') {
37+
rd($two);
38+
}
39+
40+
return $one . $two . $foo;
41+
}

0 commit comments

Comments
 (0)