小编Adi*_*Adi的帖子

如何在vscode API中替换后删除选择

在为 vscode 创建扩展时,我陷入了选择中,现在问题是当我通过 api 替换某些范围的 textEditor 时,它会替换该范围并选择该范围。对于片段,这是一个好主意,但我的扩展要求不是选择替换文本,我在 api 中搜索但没有找到与删除文本选择相关的任何内容(选择发生在文档为空时)

editor.edit((editBuilder)=>{ //editor is an object of active text editor
        editBuilder.replace(textRange,text)   // text = 'dummydummydummy'
    }) //after this I got the following output
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

visual-studio-code vscode-extensions

6
推荐指数
1
解决办法
2101
查看次数