microsoft / vscode

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

Auto import breaks already existing imports #218906

Open Profesor08 opened 1 week ago

Profesor08 commented 1 week ago

Type: Bug

Open some react component, type useCallback, wait for autosugestions, press enter.

This Bug is very old, and occurs from time to time, when you hit Enter for autosugestions. Imports added from Quick fix are working fine. I think the script is not taking in count multiline imports, and just places new import on next line after import keyword.

https://github.com/microsoft/vscode/assets/8218016/420b37fc-9e05-4c79-a954-46a8646f3907

VS Code version: Code - Insiders 1.91.0-insider (b36286db80c68b7fdc6bfee2f55e0208c8833dfc, 2024-06-25T09:15:32.698Z) OS version: Windows_NT x64 10.0.22631 Modes:

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 9 3900XT 12-Core Processor (24 x 3793)| |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| |Load (avg)|undefined| |Memory (System)|31.92GB (13.83GB free)| |Process Argv|--crash-reporter-id 15de8306-e8a1-4213-8c02-ebcaa1dda863| |Screen Reader|no| |VM|0%|
Extensions (28) Extension|Author (truncated)|Version ---|---|--- glance|ahk|0.0.8 project-manager|ale|12.8.0 lit-html|bie|1.11.1 vscode-markdownlint|Dav|0.55.0 vscode-eslint|dba|3.0.10 intelli-php-vscode|DEV|0.12.15062 phptools-vscode|DEV|1.48.15635 profiler-php-vscode|DEV|1.48.15635 gitlens|eam|15.1.0 EditorConfig|Edi|0.16.4 prettier-vscode|esb|10.4.0 auto-close-tag|for|0.5.15 auto-rename-tag|for|0.1.10 todo-tree|Gru|0.0.226 path-autocomplete|ion|1.25.0 auto-comment-blocks|kev|1.0.1 dotenv|mik|1.0.1 remote-wsl|ms-|0.88.2 hexeditor|ms-|1.10.0 vscode-extension-auto-import|Nuc|1.4.3 indent-rainbow|ode|8.3.1 vscode-xml|red|0.27.2024053103 vscode-yaml|red|1.15.0 vscode-styled-components|sty|1.7.8 vscode-stylelint|sty|1.4.0 vscode-mdx|uni|1.8.9 highlight-matching-tag|vin|0.11.0 vscode-import-cost|wix|3.3.0 (1 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492:30256197 vsc_aa:30263845 vscod805cf:30301675 vsaa593cf:30376535 py29gd2263:31024238 c4g48928:30535728 2i9eh265:30646982 962ge761:30841072 pythongtdpath:30726887 welcomedialog:30812478 pythonnoceb:30776497 asynctok:30898717 dsvsc013:30777762 dsvsc014:30777825 dsvsc015:30821418 pythonregdiag2:30926734 pythonmypyd1:30859725 h48ei257:31000450 pythontbext0:30879054 accentitlementst:30870582 dsvsc016:30879898 dsvsc017:30880771 dsvsc018:30880772 cppperfnew:30980852 pythonait:30973460 jchc7451:31067543 chatpanelt:31014475 945dj816:31013170 a69g1124:31018687 dvdeprecation:31040973 dwnewjupytercf:31046870 newcmakeconfigv2:31071590 nb_pri_only:31057983 nativerepl2:31071685 ```
mjbvz commented 1 week ago

Please share a small project that demonstrates the issue so we can investigate, either as a GitHub repo or by pasting the file contents here as text. Thanks

Profesor08 commented 1 week ago
import { Btn } from "react-components/Btn";
import {
  Table,
  TableBody,
  TableCell,
  TableHeader,
  TableHeaderCell,
  TableHeading,
  TableItem,
  TableRow,
  TableText,
} from "react-components/Table";

export const Component: FC<{
  isLoading?: boolean;
  isFetching?: boolean;
}> = ({ isLoading, isFetching }) => {
  const [isExpanded, setIsExpanded] = useState(false);

  const onExpandToggle = useCallback(() => {
    setIsExpanded((state) => !state);
  }, []);

  return (
    <div className="container"></div>
  );
};