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

Keep cursor position after 'Convert to named function' #666

Closed
jakweg opened this issue Jul 28, 2022 · 1 comment
Closed

Keep cursor position after 'Convert to named function' #666

jakweg opened this issue Jul 28, 2022 · 1 comment
Labels
💪 Improvement Refactoring doesn't run on a specific case or result could be optimized

Comments

@jakweg
Copy link

jakweg commented Jul 28, 2022

Describe what's missing

When I convert a function to named function it moves my cursor to the end of the function, I would like to keep the cursor at the first line of my function where I used the refactor function. It doesn't happen when converting named to arrow though.

How would it work

Have this arrow function

const foo = () => {
};

Move cursor to "foo"
Convert to named function
Cursor is at the end instead of in "foo"

Expected behavior

I expect the cursor to stay in the first line

Additional information

  • Version of the extension used: v6.14.4
@jakweg jakweg added the 💪 Improvement Refactoring doesn't run on a specific case or result could be optimized label Jul 28, 2022
@nicoespeon
Copy link
Owner

Thanks for the report @JakubekWeg!

I started to dig into this, then I remember that we never implemented "Convert to named function" since VS Code handles it itself (thanks to TS contributions).

You can tell the difference because there is no ✨ ending the command. This is how I distinct Abracadabra's refactorings from others 😁

convert to named function

Thus, I'm afraid this suggestion should be ported to VS Code directly. I did some digging and found that it's declared here: https://github.com/microsoft/TypeScript/blob/a66a1a6e2536cd2cd1965f9030edaedb27d03e2f/src/services/refactors/convertArrowFunctionOrFunctionExpression.ts#L11-L15

I think this is where the suggestion should be made: https://github.com/microsoft/TypeScript/issues?q=is%3Aissue+is%3Aopen+%22convert+to+named+function%22

Hope that helps! Sorry I can't make it work from here 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 Improvement Refactoring doesn't run on a specific case or result could be optimized
Projects
None yet
Development

No branches or pull requests

2 participants