Keep cursor position after 'Convert to named function'
jakweg opened this issue ยท 1 comments
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
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 ๐
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 ๐