Change title of untitled tab in Visual Studio Code

若如初见. 提交于 2020-01-03 13:55:08

问题


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?


回答1:


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;
    // ...
}

Unfortunately, it seems that the readonly attribute isn't reflected in the API docs on the website.



来源:https://stackoverflow.com/questions/45876887/change-title-of-untitled-tab-in-visual-studio-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!