fix(completion): do not propose <?php if completion context is not given (#593)
fixes #372pull/589/merge v5.3.6
parent
d9bc0b0285
commit
a8f60c9cf6
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue