31

VS Code with Go, the quick fix always give "no code actions available". No matter what's the error or warning, no fix is given.

enter image description here

Is this my config/environment problem or is it a vscode bug/expected? Any help will be highly appreciated!

Dan
  • 918
  • 1
  • 11
  • 16
  • Are you sure there's meant to be quick fixes available for the errors you tested with the language extension you're using? (what language is this?) – Gama11 Mar 29 '19 at 11:13
  • The language is Go, I expect it add a line package xxx in the beginning of the file. Maybe this is too demanding for this extension, but I never see it can fix something. Or can you tell which specific case it can fix, I will check. – Dan Mar 29 '19 at 13:58
  • 1
    This suggests that the Go extension only has quick fixes for missing imports: https://github.com/Microsoft/vscode-go/issues/1484#issuecomment-471829410 – Gama11 Mar 29 '19 at 14:52
  • 2
    I have a similar issue. Shouldn't 'Quick Fix' be able to handle 'blank line contains whitespace' ? – skytaker Apr 05 '19 at 21:43
  • 2
    This ticket suggests it is a widespread problem: [https://github.com/Microsoft/vscode/issues/71579](https://github.com/Microsoft/vscode/issues/71579). It is also affecting me for Python code, I always get "No code actions available" no matter what the problem. – Andrew Medlin Apr 16 '19 at 00:29
  • I have the same problem, any of the proposed solutions worked, however, even though no quick fixes were available, the code action (the icon of a lightbulb) showed the expected quick fix (in my case, an Interface implementation action. – MaxC Sep 06 '22 at 22:10

9 Answers9

17

I have the same problem when using the mouse to select a quick fix.
Instead of using the mouse use hot key, it works on win10:

  1. Place the cursor on the error.
  2. Press Ctrl + .
  3. Use the keyboard to select your fix.
Vic Yu
  • 187
  • 1
  • 4
  • 2
    I have the same problem with Python, but the hot key: 'ctrl+.' doesn't fix it. Any thoughts anyone? – Elegant Code Nov 25 '19 at 19:39
  • 1
    fwiw this is removed by `"key": "cmd+[Period]", "command": "-editor.action.quickFix"` in my macos `keybindings.json` (note my minus to remove and substitute /cmd/ctrl/ for /macos/windows/) – vike Jan 02 '21 at 13:57
  • I had the same problem with C# 6.0.3. The `Ctrl` + `.` worked for me. But it would be great to enable it with the mouse too. – carloswm85 May 20 '22 at 13:54
8

I had the same problem but with C# project and the Omnisharp extension (C# v1.24.0).

VsCode didn't resolve the namespaces, but instead showed the "No code actions available". After some time I stumbled across this GitHub issue https://github.com/OmniSharp/omnisharp-vscode/issues/5029.

After changing the Omnisharp settings via extension settings menu and setting the value

"omnisharp.path": "latest",

I restarted my Omnisharp extension and it finally started giving me proper quick fixes.

Hellaren
  • 422
  • 1
  • 5
  • 15
4

I have restarted the VS Code and the problem has gone.

Denis
  • 302
  • 4
  • 7
1

For me, it was that Omnisharp: Use Modern Net was set to false. It needs to be set to true.

I set it to false in the past to be compatible with an older version of Unity. Now that I am using a newer version of Unity, I installed the Visual Studio Code Editor package in Unity and set the above option to true. That solved the issue after restarting Omnisharp.

Delphoenyx
  • 19
  • 2
0

in my case this was due to duplicate line number in my js file. removing the duplicate line numbers worked for me.

Fiaz Ahmed Ranjha
  • 245
  • 1
  • 6
  • 22
0

In my Python project I solved it by switching to the right python interpreter (I'm using a different virtual environment for every project.

I clicked on the python button (bottom of VS Code UI) and set the proper path within my /path/to/my/project/venv/bin/python:

enter image description here

Now when I'm using the shortcuts I'm able to Add import <some_import>, for example:

enter image description here

My VS Code version: 1.52.1

ItayB
  • 10,377
  • 9
  • 50
  • 77
0

Please run visual studio code as Administrator. For more information check your Output Console. It happen because one of running programs block your omnisharp and it didn't work!

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 23 '22 at 11:06
  • This answer looks promising. Probably if we take a deeper look to the OmniSharp initialization we can find out if there's any fix available there. Here's a code example I've got from my system: https://gist.github.com/carloswm85/8d570b1fbcba3dab6bc57a88d8b17f8b I'm not able to see any problem there, but maybe someone more knowledgeable can see something. – carloswm85 May 20 '22 at 14:04
0

I have this issue and by clicking on the extension panel I see the text shown in front of Omnisharp C# that says reload and this issue has been fixed by clicking on this text, maybe you have more than an extension for the language you code with , if it's doesn't work uninstall one of them and you see this work

Rebwar
  • 413
  • 3
  • 17
-6

Make sure you dont have a badly formatted or empty .sln file.