简体   繁体   中英

How to open a tab containing the provided string in Visual Studio Code

I'm working on an extension for Visual Studio Code, and I want to open a new tab containing some text I'll provide. I thought of using vscode.window.showTextDocument but it takes a TextDocument as input and I can't find how to create a TextDocument from a provided string. Any help?

I don't believe VSCode allows the creation of TextDocuments from strings. One way of obtaining a TextDocument is to create a temporary file from the provided string, possibly in your extensions directory so that the user isn't bothered by it, and then use the openTextDocument method on the file, which would return a TextDocument.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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