简体   繁体   English

Visual Studio Code追加到现有导入

[英]Visual Studio Code append to existing import

Vscode has an auto import functionality which will append the new imported item to a list if it exists: Vscode具有自动导入功能,该功能会将新导入的项目添加到列表(如果存在):

import { fun1 } from "./utils"

then if I trigger auto-import of fun2 from utils it will look like: 那么如果我从utils触发fun2的自动导入,它将看起来像:

import { fun1, fun2 } from "./utils"

How does it add fun2 to that list? 如何将fun2添加到该列表?

This can be done using a CodeActionProvider (which is what's used for the light bulb feature). 可以使用CodeActionProvider (用于灯泡功能)来完成。 The key here is to create workspace edits that allow manipulating the content of a document (addressed by the given URI). 此处的关键是创建工作空间编辑 ,以允许处理文档的内容(由给定URI寻址)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM