Skip to content
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

Selection-based refactorings should not appear when there is no selection #1605

Closed
DustinCampbell opened this issue Jun 28, 2017 · 0 comments · Fixed by #1606
Closed

Selection-based refactorings should not appear when there is no selection #1605

DustinCampbell opened this issue Jun 28, 2017 · 0 comments · Fixed by #1606

Comments

@DustinCampbell
Copy link
Member

Steps to reproduce

In the following code, place the editor caret after 'false'.

using System;

class C
{
    void M()
    {
        Console.WriteLine(false);
    }
}

Expected behavior

No lightbulb should appear

Actual behavior

A lightbulb appears with Extract Method, Introduce Local, etc.

@DustinCampbell DustinCampbell added this to the 1.12 milestone Jun 28, 2017
DustinCampbell added a commit to DustinCampbell/vscode-csharp that referenced this issue Jun 28, 2017
Fixes dotnet#1605

When calling CodeActionProvider.provideCodeActions(...), VS Code passes the range of the word to the left of the editor caret if there's no selection. This ends up causing refactorings like Extract Method to be offered even when the user hasn't selected any code. Now, we'll check to see if there's actually a selection and use that instead of the range that's given.

To fully fix this issue, I've made several changes in OmniSharp: OmniSharp/omnisharp-roslyn#899. Once that goes in, we'll need to update the version of OmniSharp used by C# for VS Code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant