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

Insert right paren after cursor when completing method calls #5935 #5956

Closed
wants to merge 2 commits into from

Conversation

PavitraAgarwal21
Copy link

@PavitraAgarwal21 PavitraAgarwal21 commented Jul 4, 2024

insert a closing parenthesis after the cursor in the Cairo language server.


This change is Reviewable

Copy link
Contributor

@mkaput mkaput left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution! Don't remember to use Reviewable for answering to comments btw :)

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @PavitraAgarwal21)

a discussion (no related file):
Please add tests for this change.

We do not have any completions tests yet, but they should be pretty trivial to add because we have very similar tests for hovers already.

Hover tests are coded here:

cairo_lang_test_utils::test_file_test!(

and they are using snapshot fixtures, example one is here:

The test plan I imagine should look like the issue description I did, i.e. using the cursors mechanism you form a situation of the code before completion, and a situation after it. Then you run the completion request over the before snippet, apply the result and you compare what you got.

Here you have a ton of examples of such tests from IntelliJ Rust codebase: https://github.com/intellij-rust/intellij-rust/blob/c6657c02bb62075bf7b7ceb84d000f93dda34dc1/src/test/kotlin/org/rust/lang/core/completion/RsCompletionTest.kt



crates/cairo-lang-language-server/src/ide/completion/completions.rs line 285 at r1 (raw file):

    let completion = CompletionItem {
        label: format!("{}()", name),
        insert_text: Some(format!("{}()", name)),

This sounds like it always puts the cursor after ), isn't it?

Can you put the cursor before ) if the completed function has any arguments?

See this video on how it's done in RustRover:

Nagranie z ekranu 2024-07-4 o 10.53.56.mov

@mkaput
Copy link
Contributor

mkaput commented Jul 10, 2024

Hey @PavitraAgarwal21! Any progress on this? May I help somehow?

@PavitraAgarwal21
Copy link
Author

Can someone take over this task? I’m currently tied up with other work.

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

Successfully merging this pull request may close these issues.

Insert right paren after cursor when completing funciton/method calls
2 participants