Find usages doesn't seem to work if term is selected?

I have this line of code:

newBusinessItems[idIndex++] = group;


Now, if I right click on "_newBusinessItems" and select Find Usages, it
works just fine.

But if I double-click the term to select it, and then while the term
"_newBusinessItems" is selected, it DOESN'T work. It searches through all
my projects and then the cursor just stays where is and nothing else seems
to happen. I have no idea what it's trying to do, really, but it's just not
working. This is fully repeatable on multiple machines and installations.

What's the difference between having a term selected and not selected, when
it comes to Find Usages? Is this just a bug?




3 comments
Comment actions Permalink

Hello Paul,

not sure it can be called a bug, but this behavior is indeed difficult to
comprehend.

First, Find Usages does not take into account what identifier is selected
in the editor
- it only looks at the position of the caret. When you select '_newBussinessItems',
the caret moves
to the end of the selection, so now you have something like this:

newBusinessItems<caret>[idIndex++] = group;

You then invoke Find Usages. It checks that the caret is between the last
letter of '_newBussinessItems'
and '[' and decides that you want to find usages of the indexer denoted
by '[]' (you can easily check this
by using Advanced Find Usages that shows a dialog). So it starts searching
for
usages of the indexer, and this normally takes very long time, because we
basically need to scan each file
where '[]' appear - and it's not a big overestimate to say that '[]' appear
in almost all source files.

You might ask why ReSharper decides that you want to find usages of the indexer,
when you actually mean finding usages
of '_newBussinessItems'. Unfortunately, ReSharper cannot guess that - obviously
you may want to find usages of the indexer as well, and either the caret
position to the left of '[' or to the right of '[' (or both) should allow
you to do that. We decided that the position
to the left of '[' will serve this purpose.

Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

I have this line of code:

newBusinessItems[idIndex++] = group;

Now, if I right click on "_newBusinessItems" and select Find Usages,
it works just fine.

But if I double-click the term to select it, and then while the term
"_newBusinessItems" is selected, it DOESN'T work. It searches through
all my projects and then the cursor just stays where is and nothing
else seems to happen. I have no idea what it's trying to do, really,
but it's just not working. This is fully repeatable on multiple
machines and installations.

What's the difference between having a term selected and not selected,
when it comes to Find Usages? Is this just a bug?



0
Comment actions Permalink

IMO it is a bug. ReSharper should consider selection as well as caret position.
In the example, it should search for indexer only if '[' is selected or there
is no selection at all.

Hello Paul,

not sure it can be called a bug, but this behavior is indeed difficult
to comprehend.

First, Find Usages does not take into account what identifier is
selected
in the editor
- it only looks at the position of the caret. When you select
'_newBussinessItems',
the caret moves
to the end of the selection, so now you have something like this:
newBusinessItems<caret>[idIndex++] = group;

You then invoke Find Usages. It checks that the caret is between the
last
letter of '_newBussinessItems'
and '[' and decides that you want to find usages of the indexer
denoted
by '[]' (you can easily check this
by using Advanced Find Usages that shows a dialog). So it starts
searching
for
usages of the indexer, and this normally takes very long time, because
we
basically need to scan each file
where '[]' appear - and it's not a big overestimate to say that '[]'
appear
in almost all source files.
You might ask why ReSharper decides that you want to find usages of
the indexer,
when you actually mean finding usages
of '_newBussinessItems'. Unfortunately, ReSharper cannot guess that -
obviously
you may want to find usages of the indexer as well, and either the
caret
position to the left of '[' or to the right of '[' (or both) should
allow
you to do that. We decided that the position
to the left of '[' will serve this purpose.
Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

>> I have this line of code:
>>
>> newBusinessItems[idIndex++] = group;
>>
>> Now, if I right click on "_newBusinessItems" and select Find Usages,
>> it works just fine.
>>
>> But if I double-click the term to select it, and then while the term
>> "_newBusinessItems" is selected, it DOESN'T work. It searches
>> through all my projects and then the cursor just stays where is and
>> nothing else seems to happen. I have no idea what it's trying to do,
>> really, but it's just not working. This is fully repeatable on
>> multiple machines and installations.
>>
>> What's the difference between having a term selected and not
>> selected, when it comes to Find Usages? Is this just a bug?
>>
Thanks,
Andrey Simanovsky


0
Comment actions Permalink

I would agree that would make the behavior more intiutive.

I think this would be a worthwhile enhancement/change to 2.0


"Andrey Simanovsky (JetBrains)" <ands@intellij.com> wrote in message
news:41714632546176034199296@news.intellij.net...

IMO it is a bug. ReSharper should consider selection as well as caret
position. In the example, it should search for indexer only if '[' is
selected or there is no selection at all.

>
>> Hello Paul,
>>
>> not sure it can be called a bug, but this behavior is indeed difficult
>> to comprehend.
>>
>> First, Find Usages does not take into account what identifier is
>> selected
>> in the editor
>> - it only looks at the position of the caret. When you select
>> '_newBussinessItems',
>> the caret moves
>> to the end of the selection, so now you have something like this:
>> newBusinessItems<caret>[idIndex++] = group;
>>
>> You then invoke Find Usages. It checks that the caret is between the
>> last
>> letter of '_newBussinessItems'
>> and '[' and decides that you want to find usages of the indexer
>> denoted
>> by '[]' (you can easily check this
>> by using Advanced Find Usages that shows a dialog). So it starts
>> searching
>> for
>> usages of the indexer, and this normally takes very long time, because
>> we
>> basically need to scan each file
>> where '[]' appear - and it's not a big overestimate to say that '[]'
>> appear
>> in almost all source files.
>> You might ask why ReSharper decides that you want to find usages of
>> the indexer,
>> when you actually mean finding usages
>> of '_newBussinessItems'. Unfortunately, ReSharper cannot guess that -
>> obviously
>> you may want to find usages of the indexer as well, and either the
>> caret
>> position to the left of '[' or to the right of '[' (or both) should
>> allow
>> you to do that. We decided that the position
>> to the left of '[' will serve this purpose.
>> Regards,
>> Dmitry Shaporenkov
>> JetBrains, Inc
>> http://www.jetbrains.com
>> "Develop with pleasure!"
>>> I have this line of code:
>>>
>>> newBusinessItems[idIndex++] = group;
>>>
>>> Now, if I right click on "_newBusinessItems" and select Find Usages,
>>> it works just fine.
>>>
>>> But if I double-click the term to select it, and then while the term
>>> "_newBusinessItems" is selected, it DOESN'T work. It searches
>>> through all my projects and then the cursor just stays where is and
>>> nothing else seems to happen. I have no idea what it's trying to do,
>>> really, but it's just not working. This is fully repeatable on
>>> multiple machines and installations.
>>>
>>> What's the difference between having a term selected and not
>>> selected, when it comes to Find Usages? Is this just a bug?
>>>

Thanks,
Andrey Simanovsky

>



0

Please sign in to leave a comment.