bug? autocomplete replacing next word

in PHPstorm 98.108 I have an issue with the autocomplete handling...

I have some pre-existing code I want to wrap in a function

right now in release 98.108,
if I insert the cursor to the left of the $ and start typing,
Code Complete works, as shown:
   however, once I hit the tab key, it replaces $ThisActiveDoc as shown here:
    it should look like this:

   This happens if I use the tab key, the return key or the enter key.
   I am running the OSX version of PHPStorm. (98.108).
   I did the File-Invalidate Caches after installing it.

  I really like the autopopup feature that was added in 98.91, - if you could change it so it doesn't autoselect the next word, then replace it, that would be helpful.


Comment actions Permalink

Hi Jack,

I will use this code in my reply/message (just random line from one of my files):

error_log(__FILE__, 0);

Now, if I will start typing something like this (the red vertical line represents where cursor is located when I press Ctrl+Space to see autocompletion pop-up):

|error_log(__FILE__, 0);

I have the same behaviour: the next keyword get replaced by the entry from autocompletion list. This will happen ONLY if I hit tab key.The result in this case will be:

strtolower(__FILE__, 0);

However, if I press Enter, then result is quite different:

strtolower()error_log(__FILE__, 0);

I do not think that PhpStorm can or (maybe even) should do what you are expecting (image #3 from your post: -- include the following text after cursor inside the function brackets) -- in my examples you would expect this:

The above autocompletion would be nice indeed, but it's quite difficult for IDE (I would even say impossible) to recognise where you want the following text to be included inside brackets and where you do not want this to be done -- for example, in complex expressions, like this:

$text = strto|$_SERVER['HTTP_USER_AGENT'] .'||' . md5($my_unique_secret);

What the correct answer will be: this

$text = strtolower($_SERVER['HTTP_USER_AGENT'] .'||' . md5($my_unique_secret));

or this?

lower($_SERVER['HTTP_USER_AGENT']) .'||' . md5($my_unique_secret);

No one knows the correct answer except you (the person who invoked autocompletion popup and selected the entry in the list).

You can read help file about how autocompletion works: just press F1, jump to Search tab and type this: Using Suggestion List.

If you want PhpStorm to actually behave in your way (image #3 from your post) -- then you should post a feature request in tracker: http://youtrack.jetbrains.net/issues/WI#newissue=yes

Comment actions Permalink

I think you're describing the nature of my bug report -
pressing enter for me does not behave the way it does for you,
pressing enter and tab do the same thing - they replace the text to the right

That's what I'd like changed/fixed.
(this is on 98.108 on OSX)

the automatic assignment of the ) wasn't part of my request - I apologize if it looked that way from the code - I had put in the ')' by myself manually.

If I can ask, how do you get those separate code sections in your post? I don't see an option to format code in my editor (Could be browser specific - I am using Safari on OSX

Comment actions Permalink

Hmm -- this must be platform specific bug (I'm using Windows 7 and, as you can see, it works fine for me) ... or ... maybe this is some other plugin that messing things up. The Question is: do you have "Extended Code Sense" plugin installed (or any other plugin that is not part of standard distribution (not bundled in)) ?

If this is definitely not a plugin -- then it's a bug for me and you should report it (same link as before).

As for the second part: I have used "Quote" feature (the last button in first row in the bar above this message box -- the one with comment bubble and double quote sign -- just select the text and click on it).

Comment actions Permalink

Hmm, well I just tried it again, and it worked as expected.
So maybe not a bug after all.
Sorry about the false alarm.

The only thing I can think of to explain it is that maybe I didn't invalidate my caches when I thought I did (ie when I installed the 108 release)
Either that or a reboot of the IDE.

Thanks for the weekend assistance!

Comment actions Permalink

@Andriy Bazanov We really appreciate your help here and other threads. The quality and style of your responses is quite impressive.
We'd like to grant you a free personal license for PhpStorm. You'll be contacted via your issue tracker credentials by our PR team.

Comment actions Permalink

Alexey Can this thread be deleted? It does not look like a bug. I'd like to avoid cluttering up your forum with junk.

- Jack

Comment actions Permalink

We prefer to keep it.

Comment actions Permalink

Ok Alexey.

Also Just wanted to let you know how much I love PHP Storm - it has been a huge help to me!

I also watched your video from IPC Spring 2010, which was pretty cool to see a few things in action.

- Jack

Comment actions Permalink

I have this problem too. Any update on this?

Comment actions Permalink


Which bug? Please provide details instead of "me too".

Comment actions Permalink

Autocomplete removes next word

Comment actions Permalink


>Autocomplete removes next word

That's expected / correct behaviour.

In code completion (when completion popup is visible):

  • [Tab] will replace the word under caret with selected entry
  • [Enter] will insert the selected entry without replacing

So use [Enter] instead of [Tab] in such cases.



P.S. Huge thanks for the gif/animation that shows keys pressed -- it adds the context / clarifies things straight away

Comment actions Permalink

Is there any way to re-configure Tab to behave like Enter? Looking at the settings under `Code Completion` does not seem to have an option to do that. Ideas?

UPDATE: found solution.

For those who would want simple completion (no deletion) upon hitting tab - you need to change `Choose Lookup Item` and `Choose Lookup Item and Replace` in Settings | Keymap.


Please sign in to leave a comment.