microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.54k stars 1.56k forks source link

Add extract to (existing or new) file #13003

Open Dannykcw opened 2 days ago

Dannykcw commented 2 days ago

Feature Request

Type: Feature Request

There is #1162 that added features to extract code to a function.

Let say I have this file tic-tac-toe.c, and I want to extract the selected functions to board.c since tic-tac-toe.c is getting too big.

It would look similar to something like this Image and even more specifically something like this

The keybind would instead be something like this: select portion of code -> right click -> refactor -> extract to file -> options (if needed) at the top

This is what's on my end when I do select portion of code -> right click -> refactor Image

Unless something with the extension I am using? Afaik it works for js/ts

VS Code version: Code 1.94.0 (Universal) (d78a74bcdfad14d5d3b1b782f87255d802b57511, 2024-10-02T13:08:12.626Z) OS version: Darwin x64 22.6.0 Extension version: v1.22.11 Debugger: lldb-1403.0.17.67 Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100) Compiler: gcc-14 (Homebrew GCC 14.2.0_1) 14.2.0

sean-mcmanus commented 1 day ago

@Dannykcw The latest VS 2022 has a Move Definition Location feature, but it only moves it from the source file to the header file and not to a different file. I'm not sure if they're planning to expand that feature to include other files or not. We might be able to port their implementation for VS Code like what was done for Extract to Function.

Dannykcw commented 1 day ago

@sean-mcmanus, would it ever be possible for the public to submit our PR for this issue? Or is it up to the internal teams/maintainers?

sean-mcmanus commented 1 day ago

@Dannykcw I think the fix would require changes to our closed source cpptools process.