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

rust-analyzer fill matching arms does not work in theia but works in vscode #13922

Open
hsnoil opened this issue Jul 14, 2024 · 8 comments
Open
Labels
bug bugs found in the application vscode issues related to VSCode compatibility

Comments

@hsnoil
Copy link

hsnoil commented Jul 14, 2024

Bug Description:

When using rust-analyzer extension, the fill match arms does not work on TheiaIDE appimage, but it works fine on vscode. Other rewrites work, just not fill match arms

Steps to Reproduce:

  1. Make sure cargo is installed and rust-analyzer extension
  2. create a new project cargo new test1
  3. Open test1 folder in Theia and put this in src/main.rs:
enum Pet {
    Cat,
    Dog
}

fn main() {
    let pet = Pet::Cat;
    match pet {
        
    }

}
  1. pet in match pet { line should highlight as an error, mouse over it and scroll down to Quick fix... or ctrl+. and click on Fill match arms, nothing happens

Additional Information

It should give this:

match pet {
        Pet::Cat => todo!(),
        Pet::Dog => todo!(),
    }
  • Operating System: Linux
  • Theia Version: 1.51.0
@msujew msujew added bug bugs found in the application vscode issues related to VSCode compatibility labels Jul 15, 2024
@JonasHelming
Copy link
Contributor

Thank you for the report. Could you paste a link to the to extensions on openVSX and ideally also the versions of the extensions you are using?

@hsnoil
Copy link
Author

hsnoil commented Jul 22, 2024

@JonasHelming
Copy link
Contributor

Thanks, you also mention "Cargo" needs to be installed, could you provide the details there, too?

@hsnoil
Copy link
Author

hsnoil commented Jul 23, 2024

Cargo comes with Rust(which is what is also needed):

https://www.rust-lang.org/tools/install

@tsmaeder
Copy link
Contributor

@hsnoil what version of TheiaIDE are you using?

@msujew
Copy link
Member

msujew commented Jul 24, 2024

@tsmaeder In the initial post they mention:

Operating System: Linux
Theia Version: 1.51.0

@hsnoil
Copy link
Author

hsnoil commented Feb 9, 2025

I think I may have narrowed down the problem.

The issue is likely related to doing a set of a SnippetTextEdit

This is the part where it fails:

   const [uri, edits] = unwrapUndefinable(editEntries[0]);
        const editor = await editorFromUri(uri);
        if (editor) {
            edit.set(uri, removeLeadingWhitespace(editor, edits));
            await vscode.workspace.applyEdit(edit);
        }

https://github.com/rust-lang/rust-analyzer/blob/master/editors/code/src/snippets.ts

on vscode the applyEdit returns true, while Theia returns false.

Doing a few tests, if I use a TextEdit, it works (but then you lose templates of the SnippetTextEdit)

Edit:
I was able to find a workaround by modifying rust-analyzer to use insertSnippet instead. But the underlying issue is still that set with SnippetTextEdit and then using applyEdit doesn't work.

@hsnoil
Copy link
Author

hsnoil commented Feb 10, 2025

I notice there are some differences for set between theia and vscode. Not sure if that is the issue as the pc I am on is has too little space which won't let me compile Theia:

 this._edits.push({ _type: FileEditType.Snippet, uri, range: edit.range, edit, metadata });

this._edits.push({ _type: FileEditType.Snippet, uri, range: edit.range, edit, metadata });

this._edits.push({ _type: FileEditType.Snippet, uri, range: edit.range, edit: edit.snippet, metadata, keepWhitespace: edit.keepWhitespace });

https://github.com/microsoft/vscode/blob/32a41e158d04c9777522dc567574f2a74b8f2bf9/src/vs/workbench/api/common/extHostTypes.ts#L944

As you can see, edit should be equal to edit.snippet but it ends up as edit: { snippet: edit.snippet }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application vscode issues related to VSCode compatibility
Projects
None yet
Development

No branches or pull requests

4 participants