phptools-docs icon indicating copy to clipboard operation
phptools-docs copied to clipboard

variables are not suggested inside string

Open php4fan opened this issue 1 year ago • 2 comments

To reproduce:

  1. In a PHP file, write this:
<?php
$myvariable = "lorem ipsum";

$string = "Foo bar $myv"; // <<<< I'm still typing, my cursor is after the 'v'

Expected behavior

As you type, it should suggest autocompleting the variable name to $myvariable, just like it does when you are outside of a string.

Observed behavior

Doesn't suggest anything. It seems to be unaware of variable expansion in double-quoted strings in PHP.

php4fan avatar Dec 01 '23 17:12 php4fan

will be implemented, thank you!

jakubmisek avatar Dec 01 '23 19:12 jakubmisek

Currently, in VS Code the code completion popups only when there is at least one letter, and completion is popuped explicitly with a shortcut:

image

It seems VSCode does not let us to trigger completion automatcally upon typing $ in a string.

jakubmisek avatar Dec 04 '23 15:12 jakubmisek

Now it's suggesting variables even inside single-quoted strings:

image

and even though I didn't type a $ in the first place!!!

If I accept the suggestion it adds the $ (that is consistent with giving the suggestion in the first place, but the suggestion makes no sense):

image

php4fan avatar Jul 29 '24 19:07 php4fan

Now it's suggesting variables even inside single-quoted strings:

That seems to be happening only inside of [''], which makes me wonder if it's more related to https://github.com/DEVSENSE/phptools-docs/issues/470

php4fan avatar Jul 29 '24 19:07 php4fan

Thank you for reporting that.

You're right, it seems we popup completion of everything inside ['']

jakubmisek avatar Jul 30 '24 10:07 jakubmisek

Completion of variables inside double-quoted strings implemented -> closing.

The bug with [''] will be closed at https://github.com/DEVSENSE/phptools-docs/issues/470

Thanks!

jakubmisek avatar Jul 30 '24 10:07 jakubmisek

Still fails randomly half of the time

image

image

php4fan avatar Aug 23 '24 17:08 php4fan

I see, let me check what's changed.

jakubmisek avatar Aug 24 '24 14:08 jakubmisek

@php4fan fixed it for the next update, thanks!

jakubmisek avatar Aug 24 '24 15:08 jakubmisek