-
Notifications
You must be signed in to change notification settings - Fork 30.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to create untitled document with specific language id #17917
Comments
No, currently not possible. |
@llali I am not sure I understand the use case actually, if I look at https://github.com/Microsoft/vscode-mssql/blob/dev/src/controllers/untitledSqlDocumentService.ts#L29 you seem to create a untitled resource and open it with a path. Why can you not set the extension of that path in a way that maps to the mode you want? Once you save the file and open it, the mode is also picked based on the extension, so I find it weird to set a different mode first for the untitled and then later you would get a different mode. |
@bpasero the path I created the untitled resource for has an extension which is .sql, so the mode changes to what I want and that's the scenario I needed. Now user can use a command "New SQL query" to create a new untitled document with SQL language mode. I couldn't do that with the untitled document command. Not sure if I did the right way but that was the solution I came up with. Please let me know if there's a better way for it. |
@llali no I think what you do is totally fine, the command you are pointing to is not even an official supported command. I am closing this since you seem to have found a working solution. |
@bpasero my solution works but the result is different than VS code untitled documents, the first difference is that I have to specify a valid path but vs code untitled document doesn't have a path and user can specify the path to save it later. Also I have to do the same logic as vs code does to figure out the name of the file. it would be nice it there's an open API which both can use. |
Got it, valid request. |
After discussion in #18591 one idea is to:
|
Continues in #12283 |
Is it possible to create an untitled document using 'workbench.action.files.newUntitledFile' command for specific language id? I'm using openTextDocument passing the vscode.Uri.parse('untitled:' + filePath) which filePath has the extension I want but I have to give it a full path which is different than the Untitled documents using the newUntitledFile command.
The text was updated successfully, but these errors were encountered: