我正在尝试创建一个扩展名,该扩展名将始终强制在右侧(vscode.ViewColumn.Two
)中打开文件。
我能做的就是使vscode.workspace.onDidOpenTextDocument
在第二列中打开,但是通过这样做,我在左侧和右侧打开了文件。
vscode.workspace.onDidOpenTextDocument((file) => {
const isTestFile = file.fileName.includes(".test.js");
const isCssFile = file.fileName.includes(".css");
if (isTestFile || isCssFile) {
const showTextDocument = document => vscode.window.showTextDocument(
document,
vscode.ViewColumn.Two
);
return vscode.workspace
.openTextDocument(file.fileName)
.then(showTextDocument);
}
});
我想知道是否可以阻止文件在左侧打开并在右侧强制打开,还是像我在执行的那样只是在右侧打开并关闭左侧的相同文件(没有方法)用于关闭文件)