microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.61k stars 28.14k forks source link

Unexcepted oganizeimports in the 'editor.codeActionsOnSave' #136401

Closed cnjimbo closed 2 years ago

cnjimbo commented 2 years ago

Issue Type: Bug

"editor.codeActionsOnSave": { // "source.organizeImports": true, //如果使用多个 import 'xxx' 该选项导致执行错乱 } if you add this config, it will reformat your imports code, and sort the imports, when you use those codes it will not be excepted.

//test.js

import 'bFirstRun' import 'aSecondRun'

after saving your code,

it will be organized as follow, //test.js import 'aSecondRun' import 'bFirstRun'

that is an error run order

VS Code version: Code - Insiders 1.62.0-insider (b3318bc0524af3d74034b8bb8a64df0ccf35549a, 2021-11-03T13:19:17.847Z) OS version: Windows_NT x64 10.0.18363 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz (8 x 1896)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|15.84GB (4.00GB free)| |Process Argv|--crash-reporter-id 757a7464-0600-452b-a84b-7e165104bc56| |Screen Reader|no| |VM|0%|
Extensions (94) Extension|Author (truncated)|Version ---|---|--- svgo|100|2.5.0 html-snippets|abu|0.2.1 add-reference|adr|1.0.2 config-generator|aka|1.0.1 vscode-node-debug-process-picker|apr|1.0.0 turbo-console-log|Cha|2.1.7 npm-intellisense|chr|1.4.0 path-intellisense|chr|2.4.1 gitignore|cod|0.7.0 bracket-pair-colorizer-2|Coe|0.2.1 vscode-svgviewer|css|2.0.0 vscode-eslint|dba|2.2.2 docs-preview|doc|0.3.57 netcore-snippets|dog|3.15.2 es7-react-js-snippets|dsz|3.1.1 EditorConfig|Edi|0.16.4 vscode-npm-script|eg2|0.3.23 pack-javascript|end|1.2.0 prettier-vscode|esb|9.0.0 vscode-install-vsix|fab|1.4.0 auto-rename-tag|for|0.1.9 code-runner|for|0.11.6 dotnet|for|0.0.4 shell-format|fox|7.1.1 html-preview-vscode|geo|0.2.5 codespaces|Git|1.3.4 copilot|Git|1.6.3630 remotehub-insiders|Git|2021.10.270213 json2ts|Gre|0.0.6 vscode-drawio|hed|1.6.2 vscode-git-tags|how|1.4.4 rest-client|hum|0.24.5 pack-vsix|igo|0.0.91 path-autocomplete|ion|1.17.1 search-node-modules|jas|1.3.0 vscode-nuget-package-manager|jmr|1.1.6 svg|joc|1.4.13 volar|joh|0.28.10 vscode-styled-components|jpo|1.6.6 vscode-codemetrics|kis|1.24.0 vscode-github|Kni|0.30.7 ts-extension-pack|loi|0.3.0 i18n-ally|lok|2.8.1 vscode-styled-components-snippets|lXS|1.0.2 yarn-lock-syntax|mar|0.1.3 dotenv|mik|1.0.1 vscode-less|mrm|0.6.3 vscode-docker|ms-|1.17.0 csharp|ms-|1.23.16 vscode-dotnet-runtime|ms-|1.3.0 vscode-edge-devtools|ms-|1.4.0 python|ms-|2021.12.1418235384-dev vscode-pylance|ms-|2021.11.0 jupyter|ms-|2021.10.1001414422 jupyter-keymap|ms-|1.0.0 jupyter-renderers|ms-|1.0.3 remote-containers|ms-|0.205.1 remote-ssh|ms-|0.66.0 remote-ssh-edit|ms-|0.66.0 remote-wsl|ms-|0.58.5 brackets-keybindings|ms-|0.1.1 powershell|ms-|2021.10.2 powershell-preview|ms-|2021.10.3 vscode-typescript-next|ms-|4.6.20211103 debugger-for-edge|msj|1.0.15 color-highlight|nau|2.5.0 vscode-for-node-js-development-pack|nod|2.0.1 vetur|oct|0.35.0 docthis|oou|0.8.2 vscode-yaml-sort|Pas|5.1.2 vscode-versionlens|pfl|1.0.9 material-icon-theme|PKi|4.10.0 bash-debug|rog|0.3.9 auto-version-increment|SBG|1.4.10 vscode-fileutils|sle|3.4.5 vtpw|sno|0.1.2 move-ts|str|1.12.0 stylelint-stzhang|stu|0.1.6 vs-code-node-require|tgr|1.10.2 msbuild-project-tools|tin|0.3.15 vscode-status-bar-format-toggle|tom|3.0.0 errorlens|use|3.4.0 intellicode-api-usage-examples|Vis|0.0.5 vscodeintellicode|Vis|1.2.14 vscodeintellicode-insiders|Vis|1.1.5 gistfs|vsl|0.3.0 nodejs-extension-pack|wad|0.1.9 vscode-todo-highlight|way|1.0.5 change-case|wma|1.0.0 code-debuger|wow|0.1.1 JavaScriptSnippets|xab|1.8.0 five-server|yan|0.0.34 vscode-intelli-refactor|ypr|0.1.2 vscode-proto3|zxh|0.5.4
A/B Experiments ``` vsliv695:30137379 vsins829:30139715 vsliv368cf:30146710 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstes627:30244334 pythontb:30258533 vsc_aacf:30263846 pythonptprofiler:30281269 vshan820:30294714 pythondataviewer:30285072 pythonvsuse255:30319630 vscod805cf:30301675 pythonvspyt200:30323110 vsccppwt:30382699 bridge0708:30335490 pygetstartedt2:30353727 bridge0723:30353136 pythonrunftest32:30365365 pythonf5test824:30361779 javagetstartedt:30350119 pythonvspyt187:30365360 pydsgst2:30361790 vsaa593:30376534 vsc1dsc:30385039 ```
gjsjohnmurray commented 2 years ago

Please use the Start Extension Bisect command to investigate whether the problem is being caused by one of your extensions.

mjbvz commented 2 years ago

It looks like organize imports is working as expected: it sorts the imports alphabetically

If this sorting breaks your code, you should not run organize imports and disable editor.codeActionsOnSave