Vscode: Renaming a javascript file causes (lots of) unrelated files to be updated

Created on 15 Jun 2018  路  5Comments  路  Source: microsoft/vscode

Issue Type: Bug

If a file is renamed in my javascript project almost all files (including those in node_modules) are opened and have their imports changed. The majority of these are unaffected by the rename, and the resulting changes are incorrect.

For example:

# /src/.../query.js
import moment from 'moment';
import 'moment-timezone';
import { runQuery } from './adapters/asyncQuery';

becomes:

# /src/.../query.js
import moment from '../../../../../Library/Caches/typescript/2.9/node_modules/moment/moment../../../Library/Caches/typescript/2.9/node_modules/moment/moment';
import '../../../../../Library/Caches/typescript/2.9/node_modules/@types/moment-timezone/indexLibrary/Caches/typescript/2.9/node_modules/@types/moment-timezone/index';
import { runQuery } from '@/api/adapters/asyncQueryuery';

after renaming a test file that does not reference/import it at all.

Note that not only are the imports replaced with references back to the types, but the local import to asyncQuery is also changed to asyncQueryuery.

I have confirmed this still happens with code-insiders --disable-extensions, so it seems to be part of the build. It started happening yesterday (14th of June).

VS Code version: Code - Insiders 1.25.0-insider (7dc9539a421c9c33e57e2ce0b718f183bb44c756, 2018-06-15T05:12:05.222Z)
OS version: Darwin x64 17.6.0


System Info

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz (4 x 3100)|
|GPU Status|2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled|
|Load (avg)|3, 2, 3|
|Memory (System)|16.00GB (5.38GB free)|
|Process Argv|/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron -psn_0_229432|
|Screen Reader|no|
|VM|0%|

*duplicate javascript upstream

Most helpful comment

(n.b. for anyone else coming across this, deleting the setting key: "javascript.updateImportsOnFileMove.enabled": "always", will allow you to switch off the auto-move import, which stops the error.)

All 5 comments

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

Duplicate of https://github.com/Microsoft/TypeScript/issues/24914

Try upgrading to typescript@next by following these instructions: https://code.visualstudio.com/docs/languages/typescript#_using-newer-typescript-versions

I've updated to typescript@next and this is still happening... maybe upstream hasn't updated yet. I'll try again tomorrow with the next insider build.

(n.b. for anyone else coming across this, deleting the setting key: "javascript.updateImportsOnFileMove.enabled": "always", will allow you to switch off the auto-move import, which stops the error.)

Confirmed that the altering unrelated files is fixed by @next now that the latest build is Version 3.0.0-dev.20180616.

However the presumably related butchering of imports is still happening, which I think is reported as #52022.

Was this page helpful?
0 / 5 - 0 ratings