Added end position calculation
parent
8268d158cd
commit
4c160e1209
|
@ -32,7 +32,17 @@ class Formatter
|
||||||
if ($content === $new) {
|
if ($content === $new) {
|
||||||
return [];
|
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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -47,8 +47,8 @@ class FormattingTest extends TestCase
|
||||||
'character' => 0
|
'character' => 0
|
||||||
],
|
],
|
||||||
'end' => [
|
'end' => [
|
||||||
'line' => PHP_INT_MAX,
|
'line' => 20,
|
||||||
'character' => PHP_INT_MAX
|
'character' => 0
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'newText' => $expected
|
'newText' => $expected
|
||||||
|
|
Loading…
Reference in New Issue