Repository: phpactor/phpactor (php)

Issue:
Auto completion doesn't suggest the basics on the first try
Hey here,
I am trying to set up phpactor with monaco-editor but having some issues regarding the auto-completions.
![CleanShot 2024-07-08 at 21 04 52](https://github.com/phpactor/phpactor/assets/61919774/51433d11-bf7e-47ff-9b74-6b6ba9575820)
If you see from the video, it doesn't suggest more auto completions when the file is empty. but as soon as I enter something, even a character like `1` or the first line, it starts working fine. and then again if I make the file empty, it doesn't suggest more.

Pull request description:
fix autocompletion after php tag
fixes #2689

Patch:
diff --git a/lib/Completion/Bridge/TolerantParser/CompletionContext.php b/lib/Completion/Bridge/TolerantParser/CompletionContext.php
index 7fa39df3..d3de79fa 100644
--- a/lib/Completion/Bridge/TolerantParser/CompletionContext.php
+++ b/lib/Completion/Bridge/TolerantParser/CompletionContext.php
@@ -59,7 +59,11 @@ class CompletionContext
         $previous = NodeUtil::previousSibling($node->parent);
 
         if ($previous instanceof InlineHtml) {
-            return false;
+            $phpTag = $previous->scriptSectionStartTag?->getText($previous->getFileContents());
+
+            if ($phpTag === '<?' && $node->getStartPosition() === $previous->getEndPosition()) {
+                return false;
+            }
         }
 
         return


Test patch:
diff --git a/lib/Completion/Tests/Integration/Bridge/TolerantParser/ReferenceFinder/ExpressionNameCompletorTest.php b/lib/Completion/Tests/Integration/Bridge/TolerantParser/ReferenceFinder/ExpressionNameCompletorTest.php
index fe495f88..29ddbb10 100644
--- a/lib/Completion/Tests/Integration/Bridge/TolerantParser/ReferenceFinder/ExpressionNameCompletorTest.php
+++ b/lib/Completion/Tests/Integration/Bridge/TolerantParser/ReferenceFinder/ExpressionNameCompletorTest.php
@@ -283,6 +283,16 @@ class ExpressionNameCompletorTest extends IntegrationTestCase
                 self::assertCount(0, $suggestions);
             }
         ];
+        yield 'after php tag' => [
+            [
+                NameSearchResult::create('class', 'Foobar'),
+                NameSearchResult::create('class', 'Class'),
+            ],
+            '<?php F<>',
+            function (Suggestions $suggestions): void {
+                self::assertCount(1, $suggestions);
+            }
+        ];
         yield 'attribute parameter value outside class' => [
             [
                 NameSearchResult::create('class', 'Xxyz'),