feat: Enhance file creation in codeBlockHandler
- Add detailed JSDoc comments for createAndOpenFile function - Refactor createAndOpenFile to streamline document creation and opening - Improve readability by adding in-line comments for clarity
This commit is contained in:
parent
75df05c64d
commit
e087bc9586
@ -105,10 +105,18 @@ export async function replaceCodeBlockToFile(message: any, panel: vscode.Webview
|
|||||||
await applyCodeFile(message.content, message.fileName);
|
await applyCodeFile(message.content, message.fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建并打开一个新文件
|
||||||
|
* @param message 包含要创建文件的语言和内容的对象
|
||||||
|
* - language: 文件的语言
|
||||||
|
* - content: 文件的内容
|
||||||
|
*/
|
||||||
export async function createAndOpenFile(message: any) {
|
export async function createAndOpenFile(message: any) {
|
||||||
const document =await vscode.workspace.openTextDocument({
|
// 根据提供的语言和内容创建一个新的文档对象
|
||||||
language:message.language,
|
const document =await vscode.workspace.openTextDocument({
|
||||||
content: message.content
|
language:message.language, // 设置新文档的语言
|
||||||
});
|
content: message.content // 设置新文档的内容
|
||||||
await vscode.window.showTextDocument(document);
|
});
|
||||||
|
// 在编辑器中打开并显示这个新创建的文档
|
||||||
|
await vscode.window.showTextDocument(document);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user