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

Destructive quick fix #13134

Open
najlkin opened this issue Jan 8, 2025 · 2 comments
Open

Destructive quick fix #13134

najlkin opened this issue Jan 8, 2025 · 2 comments
Assignees
Labels
Feature: Create Declaration or Definition Language Service more info needed The issue report is not actionable in its current state

Comments

@najlkin
Copy link

najlkin commented Jan 8, 2025

Type: Bug

When the quick fix feature is used in a C++ header to generate definition of a method in the associated C++ source code and the source code does not include #include directive for the header file, the quick fix adds this #include line. However, the definition of the method is placed to the position in the source file BEFORE this update, causing that it ends up mixed with some different code typically, making this whole quick fix feature unusable and dangerous.

Extension version: 1.22.11
VS Code version: Code 1.96.2 (fabdb6a30b49f79a7aba0f2ad9df9b399473380f, 2024-12-19T10:22:47.216Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Remote OS version: Linux x64 5.15.133.1-microsoft-standard-WSL2

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz (8 x 2995)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 31.69GB (11.31GB free)
Process Argv --crash-reporter-id 43ccd492-dd51-4b8e-bbd7-fe3d1bb82a37
Screen Reader no
VM 0%
Item Value
Remote WSL: openSUSE-Tumbleweed
OS Linux x64 5.15.133.1-microsoft-standard-WSL2
CPUs 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz (8 x 0)
Memory (System) 15.47GB (13.00GB free)
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
vscrp:30673768
2i9eh265:30646982
962ge761:30959799
pythonnoceb:30805159
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
dvdeprecation:31068756
dwnewjupytercf:31046870
2f103344:31071589
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc1:31192215
cf971741:31144450
iacca1:31171482
notype1cf:31157160
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624

@sean-mcmanus
Copy link
Contributor

@najlkin I haven't seen any dangerous edits occur and I haven't seen users report any. Can you provide an example repro?

@najlkin
Copy link
Author

najlkin commented Jan 8, 2025

It happens to me often and in different files and ever since I started using the VSCode (circa a year ago), so not a very specific bug. As I wrote, just have a source file and a header file, but include the header indirectly, i.e., through #include somewhere else. Write a declaration in the header and let the quick fix feature make the definition. Boom 💣 , it mixes the definition to the existing code probably because it does not take into account the offset in the file caused by the new #include line.
A workaround for me is to set C_Cpp.refactoring.includeHeader from the default always to something else, so the #include line is not added, but that is not a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Create Declaration or Definition Language Service more info needed The issue report is not actionable in its current state
Projects
Status: No status
Development

No branches or pull requests

2 participants