question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto-import was not triggered automatically in some cases

See original GitHub issue

Environment

  • Operating System: Win/Mac/Linux
  • JDK version: 13/12/8
  • Visual Studio Code version:1.39.2
  • Java extension version:0.51.0

Steps To Reproduce

  1. Make sure java.actionsOnPaste.organizeImports in settings is true.
  2. New Foo.java with codes as below:
import java.io.File;
 
public class Foo {
 
     public static void main(String[] args) {
        File f =new File("A.txt");
    }
}

Result:

  1. If copy the main method to another empty java file Auto-import was not triggered automatically. image

  2. If copy the all class to another empty java file Auto-import was triggered automatically. image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
fbriconcommented, Oct 16, 2019

The feature is expected to work when pasting into an empty file. It seems you’re trying to paste in a file that already has a class definition, so it’s not empty.

Triggering autoimport when pasting in non-empty files might cause some issues eventually, that’s why I’d prefer not to enable it at this time.

0reactions
fbriconcommented, Oct 22, 2019

@leonardofel you can install the latest CI build containing the fix, from https://download.jboss.org/jbosstools/jdt.ls/staging/?C=M;O=D

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto-import doesn't work · Issue #28 · microsoft/pylance-release
It seems that the auto-import functionality is only triggered when the package name ... The auto-import still is not working in some cases....
Read more >
Automatic move of transports not functioning - SAP Community
When the transport is released from DEV, we see it in the queue with a clock icon next to it indicating it is...
Read more >
Auto Import of React Components in Visual Studio Code [closed]
My typescript components weren't autoimporting. From your example I noticed baseUrl wasn't present in my tsconfig. Adding that started populating the auto- ......
Read more >
Auto Import | IntelliJ IDEA Documentation - JetBrains
Unambiguous imports on the fly With this checkbox selected, IntelliJ IDEA adds import statements when you type your code or paste a fragment ......
Read more >
Create chat configuration to auto-import chats
Create a chat configuration to automatically import the chats between the agents and the requesters for additional tables to extend the auto ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found