Refactoring part of code in same file is buggy (with generate)

In Cursor (Mac) you can select any part of the code, e.g. $type == “select”, press Cmd+K to generate, and write in input “refactor this part of the code into a new function in the same file”, when you press Enter, the function call will be generated, but the function definition won’t be generated.

But in chat, a very complicated refactoring could easily be done.