Skip to content

Import-on-paste implementation question #60194

Closed as not planned
Closed as not planned
@DanielRosenwasser

Description

@DanielRosenwasser

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)

  1. Before pasting the text in the clipboard into the file, maintain a string of the pasted text in the memory
  2. Compile the new code in this memory
  3. 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
  4. 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)
  5. Repeat 2 to 5 until there is no such error, or there is no completely matching text
  6. Overwrite the text string in the memory into the file to be pasted

Originally posted by @imbant in #59905

Metadata

Metadata

Assignees

Labels

DiscussionIssues which may not have code impactQuestionAn issue which isn't directly actionable in code

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions