dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.07k stars 4.04k forks source link

IntelliSense based on characters to the left of the cursor #13594

Open justcla opened 8 years ago

justcla commented 8 years ago

Version Used: 14.0.25414.00 Update 3

Steps to Reproduce: Edit a C# file and attempt to replace a token (method/variable/etc) with the assistance of IntelliSense.

  1. Place cursor at the beginning of a token you want to replace.
  2. Start typing a new token (variable/method/etc)
  3. Activate IntelliSense (Ctrl+Space)

Expected Behavior: IntelliSense suggests tokens that match the new word you are trying to complete (based on all characters to the left of the cursor)

Actual Behavior: IntelliSense presents a large list of all tokens available, with no relation to the characters just typed.

Workaround:

  1. Put a space between the new token and the old token.
  2. Put cursor somewhere in the new token.
  3. Activate IntelliSense.

Actual Behavior: IntelliSense suggests tokens matching the characters just typed. (ie. to the left of the cursor)

Bretttt commented 8 years ago

Coming from Eclipse (where this behavior is implemented) if I could choose one improvement to Visual Studio, this would be it. When I type bool b =, I don't mind every available expression showing on the list, but true and false ought to be at the top.

justcla commented 8 years ago

Hi Brettt. Thanks for your feedback. Your note about true and false appearing at the top of the list is a slightly different issue. Perhaps you could raise that as a separate item (if it does not already exist). That would be "IntelliSense filtering to only the expected type". And I agree, that would be a very valuable feature.

justcla commented 8 years ago

Just to be clear, this issue specifically relates to IntelliSense ignoring all characters to the right of the cursor and only showing options that match with characters in the selected word that appear between the previous whitepace (or other delimiter) and the cursor.

As an example, let's say I have the following code:

var startPosition = 1;
var endPosition = 100;
var currentPosition = startPosition;

and I wish to replace the last line with:

var currentPosition = endPosition;

I could put my cursor on the last line at the beginning of the token "startPosition". If I type the characters "end", my temporary code would look like this:

var currentPosition = end|startPosition; (note: "|" indicates cursor position)

When IntelliSense is invoked, it should offer suggestions based on the characters "end" and completely ignore the characters "startPosition". This would then present "endPosition" as a suggestion. Currently the suggestions are based on the entire text "endstartPosition", which would result in no meaningful matches.

rchande commented 8 years ago

Looks like this was already fixed.

justcla commented 8 years ago

I have tested this with build 15.0.25824.0 and the issue does not appear to be fixed. Re-opening and assigning to rchande.

crimpeline commented 7 years ago

Since upgrading from VS 2012 to 2015 I have this issue and find it to be a major impact on productivity, it basically cripples the ability to copy and paste existing code and then quickly amend it as required by placing the cursor inside an existing token and activating the intellisense list. Instead it is necessary to first completely delete the existing token.

Would it be possible to please get an update on when this will be fixed (i.e. what the 'milestones' mean)?

justcla commented 7 years ago

I'd also be really keen to see a fix for this.

Being able to see some results (any results!) without having to physically separate the trailing characters is a key productivity feature. Otherwise, if you try to type at the start of an existing token, you get nothing at all.

Also, being able to change the IntelliSense filter list by moving the cursor is very useful for discovering variables/methods. It brings more power into the hands of the developer.

justcla commented 7 years ago

Can you please remove the "Resolution-Not Reproducible" tag? See repro steps at the top of the thread. Thanks.

CyrusNajmabadi commented 7 years ago

Hey Ravi, here's a repro for this:

class C
{
    private int foo;

    public C()
    {
        int m_UniqueId_permanent_checkout = 1;

        m_UniqueId_permanent_checkBLABLA
    }
}

Cursor is before the BLABLA part. Hitting ctrl-space produces:

image