Skip to content

Refactoring fails badly on some prefix increments #5568

Closed

Description

Issue Type: Bug

  1. Create a new, empty .c file.

  2. Enter this text:

    int main(void) {
        for (int i = 0; i < a->b[i].c; ++i)
        {
            foo();
        }
    }
  3. Click on i (any instance of it), then press F2 to begin refactoring.

  4. Pick any other name for the variable. (e.g. i2)

  5. Refactor preview shows the error: ++i is incorrectly replaced. (e.g. by i2+i)

  6. Manually add the erroneous refactor (it's unticked by default) and accept, to confirm that the error shows when the change is actually made.

This breaks even worse when renaming multi-character variable names.

The precise breakage seems to depend on how the variable is used; namely, how "complex" the rest of the line before it is. If I have just a bare ++x, on its own on a line, it works fine. If it's at the end of a for loop, it sometimes breaks, in different ways (which vary further based on... possibly both line length and variable name length? not sure). If it's within a one-line if, it sometimes breaks (again, in various ways -- not sure what the correlation is). However, once I find a breaking scenario, I am able to consistently reproduce it.

Apologies if this has already been raised; with all due respect, I'm not going to trawl through a thousand issues.

Extension version: 0.28.1
VS Code version: Code - OSS 1.44.2 (ff915844119ce9485abfe8aa9076ec76b5300ddd, 2020-04-23T19:32:05.786Z)
OS version: Linux x64 5.4.40-1-MANJARO

System Info
Item Value
CPUs AMD Ryzen 9 3950X 16-Core Processor (32 x 2848)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: disabled_software
skia_renderer: disabled_off_ok
video_decode: unavailable_off
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
Load (avg) 1, 1, 1
Memory (System) 15.57GB (9.26GB free)
Process Argv --no-sandbox
Screen Reader no
VM 0%

Activity

  1. sean-mcmanus commented on May 28, 2020

    @sean-mcmanus
    Contributor

    Thanks a lot for reporting this. It should be fixed in the next release.

  2. nic-hartley commented on May 28, 2020

    @nic-hartley
    Author

    Awesome, thanks so much!

  3. added
    fixedCheck the Milestone for the release in which the fix is or will be available.
    on May 28, 2020
  4. locked and limited conversation to collaborators on Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature: RenameLanguage ServiceWorks in VSSo we'd need to fix it for VS Code to reach parity.bugfixedCheck the Milestone for the release in which the fix is or will be available.quick fix

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions