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

Organize Import Code Action on save is not working #14955

Open
Tracked by #13192
eneufeld opened this issue Feb 18, 2025 · 5 comments
Open
Tracked by #13192

Organize Import Code Action on save is not working #14955

eneufeld opened this issue Feb 18, 2025 · 5 comments

Comments

@eneufeld
Copy link
Contributor

Bug Description:

In my workspace I configured the organize import action to run on save of file. This does not trigger.
I also don't see the action in the list of commands when I open the command palette.

Steps to Reproduce:

  1. Open Settings
  2. Set Editor:Code Actions on Save to:
"editor.codeActionsOnSave": {
        "source.organizeImports": "explicit"
    },

Here you see already a warning that "explicit" is not a boolean (the example in the settings is setting the value to "explicit" and vscode wants that, too).
3. Open any ts file which has imports. Change import order to not be alphabetically. Save file.
4. See that imports don't change
5. try to manually call Organize imports using command palette, see no command available

Additional Information

  • Operating System: Ubuntu 22.04
  • Theia Version: 1.58.1
@rschnekenbu rschnekenbu mentioned this issue Feb 13, 2025
68 tasks
@tsmaeder tsmaeder changed the title Organize Import Command is not working Organize Import Code Action on save is not working Feb 19, 2025
@tsmaeder
Copy link
Contributor

Updated title because "Organize Imports" is not a command.

@tsmaeder
Copy link
Contributor

There are a couple of things missing here:

  1. VS Code seems to dynamically update the schema from the code actions. We are simply not doing that.
  2. The "organize imports" command does not show up in the command palette, but it shows up in the "source actions" and the keybindings.
  3. The "organize imports" command can be triggered via the "source actions" context menu
  4. The "organize imports" command cannot be triggered via the shortcut alt-shift-o

I suspect that 2 and 4 are due to context not being set or evaluated properly.

@tsmaeder
Copy link
Contributor

I suspect that the above problems don't just affect "organize imports", but all code action kinds.

@tsmaeder
Copy link
Contributor

We're simple not passing the kinds of provided code actions from the plugins to the editor. Making the connection makes the keybinding for "organize imports" work inside typescript files.

@tsmaeder
Copy link
Contributor

On the implementation side, two more things are missing:

  1. Dynamic updates of the preference schema
  2. Applying code actions on save is not implemented at all Also, instead of having a contribution architecture for save participants like VS Code has, we have a hardcoded "formatOnSave()" method.

tsmaeder added a commit to tsmaeder/theia that referenced this issue Feb 20, 2025
Part of eclipse-theia#14955

Contributed on behalf of STMicroelectronics

Signed-off-by: Thomas Mäder <[email protected]>
tsmaeder added a commit that referenced this issue Feb 21, 2025
Part of #14955

Contributed on behalf of STMicroelectronics

Signed-off-by: Thomas Mäder <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants