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,10 +162,12 @@ class CompletionProvider
|
||||||
|| (
|
|| (
|
||||||
$node instanceof Node\Statement\InlineHtml
|
$node instanceof Node\Statement\InlineHtml
|
||||||
&& (
|
&& (
|
||||||
$context === null
|
$context !== null
|
||||||
// Make sure to not suggest on the > trigger character in HTML
|
// Make sure to not suggest on the > trigger character in HTML
|
||||||
|| $context->triggerKind === CompletionTriggerKind::INVOKED
|
&& (
|
||||||
|| $context->triggerCharacter === '<'
|
$context->triggerKind === CompletionTriggerKind::INVOKED
|
||||||
|
|| $context->triggerCharacter === '<'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|| $pos == new Position(0, 0)
|
|| $pos == new Position(0, 0)
|
||||||
|
|
|
@ -444,7 +444,7 @@ class CompletionTest extends TestCase
|
||||||
], true), $items);
|
], true), $items);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHtmlWithPrefix()
|
public function testHtmlWontBeProposedWithoutCompletionContext()
|
||||||
{
|
{
|
||||||
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/html_with_prefix.php');
|
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/html_with_prefix.php');
|
||||||
$this->loader->open($completionUri, file_get_contents($completionUri));
|
$this->loader->open($completionUri, file_get_contents($completionUri));
|
||||||
|
@ -452,7 +452,21 @@ class CompletionTest extends TestCase
|
||||||
new TextDocumentIdentifier($completionUri),
|
new TextDocumentIdentifier($completionUri),
|
||||||
new Position(0, 1)
|
new Position(0, 1)
|
||||||
)->wait();
|
)->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(
|
new CompletionItem(
|
||||||
'<?php',
|
'<?php',
|
||||||
CompletionItemKind::KEYWORD,
|
CompletionItemKind::KEYWORD,
|
||||||
|
|
Loading…
Reference in New Issue