Repository: TypeScript
Issue: Inline variable: does not treat all distributive operators correctly
Labels: Bug,Help Wanted


Type: <b>Bug</b>

1. Create a variable with an operator that is sensitive to the [distributive law](https://www.mathsisfun.com/definitions/distributive-law.html). For example this code in Javascript/Dart: `var foo = 3 - 2;`.
2. Reference the first variable using a distributive operator. Example `var bar = 4 - foo;`
3. Select foo and `inline variable`.

* Actual Result: `var bar = 4 - 3 - 2;`
* Expected Result: `var bar = 4 - (3 - 2);`

Note: I've worded this more generally than just Inline variable breaks for distributing `-` in case there are other cases that break. The Inline variable refactor works correctly for `*`.

VS Code version: Code 1.88.1 (e170252f762678dec6ca2cc69aba1570769a5d39, 2024-04-10T17:34:12.840Z)
OS version: Linux x64 6.5.0-27-generic snap
Modes:

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|AMD Ryzen 9 5950X 16-Core Processor (32 x 3776)|
|GPU Status|2d_canvas: enabled<br>canvas_oop_rasterization: disabled_off<br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>opengl: enabled_on<br>rasterization: enabled<br>raw_draw: disabled_off_ok<br>skia_graphite: disabled_off<br>video_decode: enabled<br>video_encode: disabled_software<br>vulkan: disabled_off<br>webgl: enabled<br>webgl2: enabled<br>webgpu: disabled_off|
|Load (avg)|1, 1, 1|
|Memory (System)|125.71GB (97.87GB free)|
|Process Argv|--no-sandbox --force-user-env --unity-launch --crash-reporter-id 59849d9b-79ea-404b-94df-23fed22783e1|
|Screen Reader|no|
|VM|0%|
|DESKTOP_SESSION|ubuntu|
|XDG_CURRENT_DESKTOP|Unity|
|XDG_SESSION_DESKTOP|ubuntu|
|XDG_SESSION_TYPE|x11|
</details><details><summary>Extensions (23)</summary>

Extension|Author (truncated)|Version
---|---|---
dart-code|Dar|3.86.0
flutter|Dar|3.86.0
vscode-markdownlint|Dav|0.55.0
copilot|Git|1.182.0
copilot-chat|Git|0.14.1
go|gol|0.41.4
openscad-language-support|Lea|1.2.5
vscode-docker|ms-|1.29.0
csdevkit|ms-|1.4.29
csharp|ms-|2.23.15
vscode-dotnet-runtime|ms-|2.0.3
debugpy|ms-|2024.4.0
python|ms-|2024.4.1
vscode-pylance|ms-|2024.4.1
remote-containers|ms-|0.354.0
cmake-tools|ms-|1.17.17
cpptools|ms-|1.19.9
cpptools-extension-pack|ms-|1.3.0
cmake|twx|0.0.17
vscode-gradle|vsc|3.13.5
vim|vsc|1.27.2
clang-format|xav|1.9.0
vscode-proto3|zxh|0.5.5

(1 theme extensions excluded)

</details><details>
<summary>A/B Experiments</summary>

```
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscorecescf:30445987
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
2e7ec940:31000449
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
d34g3935:30971562
fegfb526:30981948
bg6jg535:30979843
ccp2r3:30993541
dsvsc020:30976470
pythonait:31006305
gee8j676:31009558
showvideoc:31016891
dsvsc021:30996838
724cj586:31013169
pythoncenvptcf:31022791

```

</details>

<!-- generated by issue reporter -->