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

improvement: Add case keyword completion #5346

Merged
merged 1 commit into from Jan 25, 2024

Conversation

jkciesluk
Copy link
Member

connected to #5339

@ckipp01
Copy link
Member

ckipp01 commented Jun 16, 2023

You're so fast @jkciesluk! 🚀

@jkciesluk jkciesluk linked an issue Jun 23, 2023 that may be closed by this pull request
@jkciesluk jkciesluk requested a review from tgodzik June 23, 2023 13:09
@@ -24,6 +24,7 @@ class CompletionCaseSuite extends BaseCompletionSuite {
|}""".stripMargin,
"""|case None => scala
|case Some(value) => scala
|case
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if people would find it useful, this is suggested as a last option, so going down is almost the same amount of button clicks as just writing case.

I would rather suggest this if we weren't able to suggest anything else.

How will this behave in the case that is in the linked issues?

Option(1).map{
  c@@
  case Some(a) =>
}

it would be awesome if None was suggested. Having just case would also be nice, but that would be a minimum I would expect to show up.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it already suggests None:
image

Are you thinking about suggesting only not covered cases?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should only show a single case if nothing else is shown to the user. Otherwise it's not that useful.

I think it already suggests None:

Do we have a test case for that? I thought this not working was the issue raised?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought this not working was the issue raised?

I believe the issue was raised because there was no case completions at all, but this happened because there was no extending classes, just objects with unapply, which we don't check (maybe we could, by looking through object in scope with unapply method and correct argument?).

Do we have a test case for that?

No, I will add it.

I think we should only show a single case if nothing else is shown to the user.
Sure, we can do that

@jkciesluk jkciesluk force-pushed the case-keyword-comp branch 2 times, most recently from f4479ad to 8632397 Compare June 27, 2023 07:52
val label = "case"
val suffix =
if (clientSupportsSnippets) " $0 =>"
else ""
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd add the space after case anyway.

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

LGTM

@tgodzik tgodzik merged commit 0fef9a1 into scalameta:main Jan 25, 2024
26 of 27 checks passed
@jkciesluk jkciesluk deleted the case-keyword-comp branch February 1, 2024 13:53
jkciesluk added a commit to jkciesluk/dotty that referenced this pull request Feb 1, 2024
rochala pushed a commit to scala/scala3 that referenced this pull request Feb 2, 2024
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.

No case completion offered in specific situation
4 participants