在 Visual Studio Code 中更改无标题选项卡的标题 [英] Change title of untitled tab in Visual Studio Code
问题描述
我正在构建一个 VS Code 扩展,其中包括更改 untitled-1
选项卡(未保存的文件)的名称/标题.
我尝试在扩展的调试器控制台中运行以下代码,但它没有反映在编辑器中:
I'm building a VS Code extension which includes changing the name/title of untitled-1
tab (unsaved file).
I tried running the below code in debugger console of extension but it didn't reflect in the editor:
vscode.workspace.textDocuments[0].fileName="myFile"
这是不可能的还是我遗漏了什么?
Is it not possible or am I missing something?
推荐答案
这是不可能的 - 如果您查看 vscode.d.ts
中的API定义,你会看到fileName
声明为 readonly
:
It's not possible - if you check out the source code for the API definition in vscode.d.ts
, you'll see that fileName
is declared as readonly
:
export interface TextDocument {
// ...
readonly fileName: string;
// ...
}
不幸的是,readonly
属性似乎没有反映在 网站上的 API 文档.
Unfortunately, it seems that the readonly
attribute isn't reflected in the API docs on the website.
这篇关于在 Visual Studio Code 中更改无标题选项卡的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!