Skip to content
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

Closed
llali opened this issue Dec 29, 2016 · 8 comments
Closed

Allow to create untitled document with specific language id #17917

llali opened this issue Dec 29, 2016 · 8 comments
Assignees
Labels
api *duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality
Milestone

Comments

@llali
Copy link
Member

llali commented Dec 29, 2016

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.

@bpasero
Copy link
Member

bpasero commented Jan 2, 2017

No, currently not possible.

@bpasero bpasero changed the title Creating untitled document for specific language id Allow to create untitled document with specific language id Jan 2, 2017
@bpasero bpasero added api feature-request Request for new features or functionality labels Jan 2, 2017
@bpasero bpasero removed their assignment Jan 2, 2017
@bpasero
Copy link
Member

bpasero commented Jan 13, 2017

@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 bpasero added the info-needed Issue requires more information from poster label Jan 13, 2017
@llali
Copy link
Member Author

llali commented Jan 13, 2017

@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.

@bpasero
Copy link
Member

bpasero commented Jan 13, 2017

@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 bpasero closed this as completed Jan 13, 2017
@llali
Copy link
Member Author

llali commented Jan 13, 2017

@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.

@bpasero bpasero reopened this Jan 13, 2017
@bpasero
Copy link
Member

bpasero commented Jan 13, 2017

Got it, valid request.

@bpasero
Copy link
Member

bpasero commented Jan 16, 2017

After discussion in #18591 one idea is to:

  • allow to open an untitled file without path by calling openTextDocument(Uri.parse('untitled:'))
  • add a new optional options bag to the method that allows to set a language to use for the document to open (e.g. openTextDocument(uri, options?: { language?: string }))

@bpasero bpasero self-assigned this Jan 17, 2017
@bpasero bpasero added this to the January 2017 milestone Jan 17, 2017
@bpasero
Copy link
Member

bpasero commented Jan 17, 2017

Continues in #12283

@bpasero bpasero closed this as completed Jan 17, 2017
@bpasero bpasero added the *duplicate Issue identified as a duplicate of another issue(s) label Jan 17, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api *duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants