1
0
Fork 0

Added end position calculation

pull/35/head
Michal Niewrzal 2016-10-05 17:42:40 +02:00 committed by Felix Becker
parent 8268d158cd
commit 4c160e1209
2 changed files with 13 additions and 3 deletions

View File

@ -32,9 +32,19 @@ class Formatter
if ($content === $new) {
return [];
}
return [new TextEdit(new Range(new Position(0, 0), new Position(PHP_INT_MAX, PHP_INT_MAX)), $new)];
return [new TextEdit(new Range(new Position(0, 0), $this->calculateEndPosition($content)), $new)];
}
/**
* @param string $content
* @return \LanguageServer\Protocol\Position
*/
private function calculateEndPosition(string $content): Position
{
$lines = explode("\n", $content);
return new Position(sizeof($lines) - 1, strlen(end($lines)));
}
/**
*
* @param string $uri

View File

@ -47,8 +47,8 @@ class FormattingTest extends TestCase
'character' => 0
],
'end' => [
'line' => PHP_INT_MAX,
'character' => PHP_INT_MAX
'line' => 20,
'character' => 0
]
],
'newText' => $expected