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

Go-to-definition on continue and break should jump around(?) corresponding statement #51224

Open
DanielRosenwasser opened this issue Oct 19, 2022 · 4 comments
Labels
Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". Experience Enhancement Noncontroversial enhancements Help Wanted You can do this In Discussion Not yet reached consensus
Milestone

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Oct 19, 2022

Similar to #51222 and #51223.

/*END*/while (true) {
  if (Math.random()) /*START*/break;
}
/*END1*/label: while (true) {
  while (true) {
    if (Math.random()) /*START*/break label;
  }
}
/*END2*/
/*END1*/while (true) {
  if (Math.random()) /*START*/continue;
}
/*END2*/
/*END1*/switch (Math.random() < 0.5) {
  case true: /*START*/break;
}
/*END2*/

Given how go-to-definition on return, await, and yield might work, it's tempting to jump up to the top of the corresponding statement.

However, I could also see us jumping to wherever the break or continue itself would jump. That's a bit at odds with the original intent of go-to-definition on return since the point of that was to figure out "who owns the current return statement?"

If someone wants to send a PR and discuss more in that PR, they're welcome to.

@DanielRosenwasser DanielRosenwasser added In Discussion Not yet reached consensus Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Good First Issue Well scoped, documented and has the green light Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". and removed Good First Issue Well scoped, documented and has the green light labels Oct 19, 2022
@DanielRosenwasser DanielRosenwasser added this to the Backlog milestone Oct 19, 2022
@sviat9440
Copy link
Contributor

sviat9440 commented Oct 21, 2022

Both options have a reason to be. Maybe take it out in the config? But then this option should also be applicable for the return for uniformity.

If we still go to the definition on return, then it is more logical to do the same in these cases.

@sviat9440
Copy link
Contributor

sviat9440 commented Oct 21, 2022

Additional test cases:

Should works

/*END*/label: switch (null) {
  case null: {
    test: switch (null) {
      case null: /*START*/break label;
    }
  }
}
/*END*/label: while (true) {
  while (true) {
    if (Math.random()) /*START*/continue label;
  }
}

Should not fail:

label: switch (null) {
  case null: [|/*START*/break|] test;
}

@sviat9440
Copy link
Contributor

okay, my pr is ready. Waiting for closure #51236

@SamB
Copy link

SamB commented Mar 3, 2023

However, I could also see us jumping to wherever the break or continue itself would jump. That's a bit at odds with the original intent of go-to-definition on return since the point of that was to figure out "who owns the current return statement?"

Well, personally I would prefer if go-to-definition on return would go to the call. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". Experience Enhancement Noncontroversial enhancements Help Wanted You can do this In Discussion Not yet reached consensus
Projects
None yet
Development

No branches or pull requests

3 participants