Hi, I'm a language server developer. I am very curious about how to implement the Import-on-Paste function you mentioned above?
Here is my idea, is it feasible? (sorry but reading ts source code is a bit difficult for me)
Before pasting the text in the clipboard into the file, maintain a string of the pasted text in the memory
Compile the new code in this memory
If there is no syntax error, if an undefined symbol error is encountered in the line where the paste is located, try to do automatic completion at the location of the symbol
If there is an automatic completion item that completely matches the text of the symbol, complete the import statement corresponding to this item (the same as the behavior of the user manually selecting this completion item)
Repeat 2 to 5 until there is no such error, or there is no completely matching text
Overwrite the text string in the memory into the file to be pasted
Originally posted by @imbant in #59905