1
0
Fork 0

fix(completion): do not propose <?php if completion context is not given (#593)

fixes #372
pull/589/merge v5.3.6
Jens Hausdorf 2018-02-07 20:55:25 +01:00 committed by Felix Becker
parent d9bc0b0285
commit a8f60c9cf6
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,