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

Double-click on PHP variable selects more than one #863

Closed
seattledeveloper opened this Issue Nov 13, 2015 · 15 comments

Comments

Projects
None yet
8 participants
@seattledeveloper

seattledeveloper commented Nov 13, 2015

I have places in my code where I will include multiple variables in an output string:

echo "This is a sample $var1$var2$varx output.";

When double-clicking on one of these variables to select it, all three variables (in the example above) are selected instead. It seems that the desired behavior is to just select individual variables.

Thanks in advance!

@mitchell-as mitchell-as added this to the 10.0 milestone Nov 13, 2015

@mitchell-as mitchell-as self-assigned this Nov 13, 2015

@mitchell-as

This comment has been minimized.

Member

mitchell-as commented Nov 13, 2015

We'll have to research this a bit further, as I'm not sure modifying the default double-click behavior is the right way to go.

@seattledeveloper

This comment has been minimized.

seattledeveloper commented Nov 13, 2015

It just seems a leading dollar sign should be a delimiter if you're in a PHP code block (or maybe just in general), but I will defer to your research. Thanks for considering this.

@mitchell-as

This comment has been minimized.

Member

mitchell-as commented Mar 10, 2016

I finally had some time to look into this and came to the conclusion that modifying the default double-click behavior is not a good idea. The only way to go about this is to prevent $ from being considered a word character. As a side-effect, this means that anytime you double click on a stand-alone variable like $foo, only the foo part will be highlighted. From your perspective as a PHP developer, would this be proper behavior?

@seattledeveloper

This comment has been minimized.

seattledeveloper commented Mar 10, 2016

This is a great suggestion. I think it should go out to the group for a vote (if that is even possible).

Personally, I prefer to have the $ not included in the double-click select. The reason being is that I always name local variables the same as my database field names. Here's a case:

$var_name = $my_db_array['var_name'];

When I am copying that line to add a new field name, I need to be careful when selecting text to include or not include the leading $, depending on what I am copying/pasting from/to. What is selected when double clicking the $var_name is different that what is selected when double clicking on the 'var_name'.

I am used to it other editors selecting the exact text "var_name" in both cases. Other developers may disagree with this approach. I definitely don't want to speak for all developers. This is just my personal preference.

Thoughts?

Ed

@Naatan

This comment has been minimized.

Member

Naatan commented Mar 11, 2016

I'm +1 on not including $ in double clicks on vars in PHP files.

Any other PHP devs want to weigh in?

@VeryVito

This comment has been minimized.

VeryVito commented Mar 11, 2016

Personally, I prefer to have the $ included in the selection. The use case of @seattledeveloper is a valid consideration, but I personally find it rarer that I need to remove the symbol than include it. It's a subtle difference, but it is one that I find distracting in practice when switching between Komodo and Brand X IDE.

@Naatan

This comment has been minimized.

Member

Naatan commented Mar 11, 2016

@VeryVito I'm confused, you speak as if this change is already present. Are you saying you "would" find distracting if it were implemented this way?

@Defman21

This comment has been minimized.

Contributor

Defman21 commented Mar 11, 2016

@garak

This comment has been minimized.

garak commented Mar 11, 2016

I think that using $var1$var2$etc is just a bad practice. You should put brackets around your variables.
The current click select behaviour looks fine to me.

@cgchoffman

This comment has been minimized.

Member

cgchoffman commented Mar 11, 2016

I think @Defman21's suggestion negates the need for discussion doesn't it? Add a PHP lang pref to add/remove $ from the known "word characters".

@seattledeveloper

This comment has been minimized.

seattledeveloper commented Mar 11, 2016

I agree. It would be much better to have this as a preference. That way the IDE isn't forcing everyone to the same solution. Thanks @Defman21 for the idea.

@Naatan

This comment has been minimized.

Member

Naatan commented Mar 12, 2016

@mitchell-as is a pref possible? I figured this would be an UDL thing and thus not something that can be dynamic.

@mitchell-as

This comment has been minimized.

Member

mitchell-as commented Mar 14, 2016

I think a pref is possible. I'll let you know otherwise.

@girvo

This comment has been minimized.

girvo commented Mar 22, 2016

In the same way that double-clicking on 'something-quoted', I would expect it to select the word, not the quotes as well. I think double-clicking to select the variable name without the $ would be a good feature for myself as a PHP dev, yes :)

@mitchell-as

This comment has been minimized.

Member

mitchell-as commented Mar 29, 2016

There will be a new "Double-click selects entire variable (including $)" preference in Edit > Preferences > Languages > PHP > Other Options. It will be enabled by default for backwards-compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment