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

Move selected code to new function #2624

Closed
3 tasks done
daxliniere opened this issue Feb 6, 2025 · 1 comment
Closed
3 tasks done

Move selected code to new function #2624

daxliniere opened this issue Feb 6, 2025 · 1 comment
Assignees
Labels
conclusion: duplicate Has already been submitted conclusion: off topic Off topic for this repository topic: code Related to content of the project itself topic: language server Related to the Arduino Language Server type: enhancement Proposed improvement

Comments

@daxliniere
Copy link

Describe the request

It would be fantastic if we could select a block of code, press a keyboard shortcut and the IDE would;

  1. ask user for name of new function (textbox popup),
  2. automatically create a new function with that name,
  3. move that code into the new function,
  4. place a pointer to that function in the original function where the moved code was.

Describe the current behavior

All manual, I'm afaid.

Arduino IDE version

2.3.4 release

Operating system

N/A

Operating system version

N/A

Additional context

No response

Issue checklist

  • I searched for previous requests in the issue tracker
  • I verified the feature was still missing when using the latest nightly build
  • My request contains all necessary details
@daxliniere daxliniere added the type: enhancement Proposed improvement label Feb 6, 2025
@per1234 per1234 self-assigned this Feb 10, 2025
@per1234 per1234 added topic: code Related to content of the project itself topic: language server Related to the Arduino Language Server labels Feb 10, 2025
@per1234
Copy link
Contributor

per1234 commented Feb 10, 2025

Thanks for your suggestion @daxliniere. Arduino IDE actually already has support for the "Extract to function" capability you are requesting:

https://code.visualstudio.com/docs/cpp/cpp-refactoring#_extract-to-method

However, Arduino IDE is mostly only a GUI. The underlying functionalities are provided by various other tools. In this case, the functionality is provided by a tool named Arduino Language Server. It seems that Arduino Language Server does not provide Arduino IDE with whatever it needs for its the "Extract to function" feature to work. For this reason, the non-functional "Refactor..." context menu item was intentionally removed (though you can still access it via the "Command Palette" and keyboard shortcut): #2027

We are tracking the deficiency in Arduino Language Server at arduino/arduino-language-server#156.

For that reason, and since no action is required in the Arduino IDE codebase (beyond reverting #2027), I'll close this issue.

@per1234 per1234 closed this as completed Feb 10, 2025
@per1234 per1234 added conclusion: duplicate Has already been submitted conclusion: off topic Off topic for this repository labels Feb 10, 2025
@per1234 per1234 changed the title FR: Move selected code to new function Move selected code to new function Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: duplicate Has already been submitted conclusion: off topic Off topic for this repository topic: code Related to content of the project itself topic: language server Related to the Arduino Language Server type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

2 participants