Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix proposing php start tag when completion context is not given by the ls client #593

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/CompletionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,12 @@ public function provideCompletion(PhpDocument $doc, Position $pos, CompletionCon
|| (
$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->triggerCharacter === '<'
&& (
$context->triggerKind === CompletionTriggerKind::INVOKED
|| $context->triggerCharacter === '<'
)
)
)
|| $pos == new Position(0, 0)
Expand Down
18 changes: 16 additions & 2 deletions tests/Server/TextDocument/CompletionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,29 @@ public function testHtmlWithoutPrefix()
], 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));
$items = $this->textDocument->completion(
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,
Expand Down