1
0
Fork 0

fix proposing php start tag when completion context is not given

by the LS client

fixes https://github.com/felixfbecker/php-language-server/issues/372
pull/593/head
jens1o 2018-02-06 20:34:26 +01:00
parent d9bc0b0285
commit 17af44555c
No known key found for this signature in database
GPG Key ID: C7437FC1B445CC49
2 changed files with 21 additions and 5 deletions

View File

@ -162,12 +162,14 @@ class CompletionProvider
|| (
$node instanceof Node\Statement\InlineHtml
&& (
$context === null
$context !== null
// Make sure to not suggest on the > trigger character in HTML
|| $context->triggerKind === CompletionTriggerKind::INVOKED
&& (
$context->triggerKind === CompletionTriggerKind::INVOKED
|| $context->triggerCharacter === '<'
)
)
)
|| $pos == new Position(0, 0)
) {
// HTML, beginning of file

View File

@ -444,7 +444,7 @@ class CompletionTest extends TestCase
], true), $items);
}
public function testHtmlWithPrefix()
public function testHtmlWontBeProposedWithoutCompletionContext()
{
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/html_with_prefix.php');
$this->loader->open($completionUri, file_get_contents($completionUri));
@ -452,7 +452,21 @@ class CompletionTest extends TestCase
new TextDocumentIdentifier($completionUri),
new Position(0, 1)
)->wait();
$this->assertCompletionsListSubset(new CompletionList([
$this->assertEquals(new CompletionList([], true), $items);
}
public function testHtmlWontBeProposedWithPrefixWithCompletionContext()
{
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/html_with_prefix.php');
$this->loader->open($completionUri, file_get_contents($completionUri));
$items = $this->textDocument->completion(
new TextDocumentIdentifier($completionUri),
new Position(0, 1),
new CompletionContext(CompletionTriggerKind::TRIGGER_CHARACTER, '<')
)->wait();
$this->assertEquals(new CompletionList([
new CompletionItem(
'<?php',
CompletionItemKind::KEYWORD,