import-js icon indicating copy to clipboard operation
import-js copied to clipboard

Bug: `maxLineLength` breaks some imports

Open codan84 opened this issue 7 years ago • 4 comments

I have set maxLineLength to some large value (say 999) so that all imports are in one line.
Now when I have a file where I want to auto-import, and any of the imports are available from multiple sources, the plugin will ask me from where to import it (as expected).
However, after choosing the source of import, instead of adding it to the line with existing imports from that file, it will remove that line altogether.

codan84 avatar Nov 20 '17 12:11 codan84

Intersting, this only happens when maxLineLength is large?

I’m out on vacation right now, so I can’t do much about this bug. If you have the bandwidth to fix, I’m happy to review a PR from the poolside. ☀️

trotzig avatar Nov 20 '17 19:11 trotzig

It only happens if 2 conditions are met:

  • maxLineLength is set to a value large enough that all imports from given file/module would fit in one line
  • import from that file/module is also available from another source so we get a question asking from which source to import

Now thinking about it I am using this app via Visual Studio Code plugin so it might be possible that it's plugin's fault? I will have to investigate further. I might also work on a fix if I find few minutes spare :) Will keep you updated, enjoy your holidays in the meantime :)

codan84 avatar Nov 20 '17 20:11 codan84

It’s possible but highly unlikely that the line is removed on the visual studio plugin side. All plugins are implemented in a way that hands over most control to the importjs daemon.

trotzig avatar Nov 21 '17 14:11 trotzig

It looks like I was wrong about where this bug is. I've managed to reproduce it with the vscode extension, and I went ahead and filed a report in that project: https://github.com/dabbott/vscode-import-js/issues/6

trotzig avatar Nov 27 '17 09:11 trotzig