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

Need to handle untitled: URI to support Untitled, unsaved files #3343

Open
byyxx128 opened this issue Mar 22, 2019 · 5 comments
Open

Need to handle untitled: URI to support Untitled, unsaved files #3343

byyxx128 opened this issue Mar 22, 2019 · 5 comments

Comments

@byyxx128
Copy link

If I open an existed C or CPP file, everything is OK. And the context menu is like this:
image

However, if I create a new file and select to C or C++ language mode, the context menu will be like this:
image
And the formatter doesn't work at this time (even though I press Shift+Alt+F).
image

@sean-mcmanus
Copy link
Contributor

It's more than just formatting that isn't working (i.e. no Go to Definition).

Saving the file is the workaround.

I don't see how we could fix this though -- it's looking like a VS Code limitation.

This was referenced Mar 22, 2019
@bobbrow bobbrow modified the milestones: On Deck, Backlog Apr 16, 2020
@bobbrow bobbrow changed the title Formatter Does Not Work If Create New File in VS Code Language features do not all work with Untitled, unsaved files Apr 16, 2020
@akbyrd
Copy link

akbyrd commented May 16, 2020

There is nothing at the VS Code level stopping code folding from working in unsaved files. This works for C/C++ files in my own extension just fine.

@sean-mcmanus sean-mcmanus added the help wanted Can be fixed in the public (open source) repo. label May 16, 2020
@sean-mcmanus
Copy link
Contributor

@akbyrd Our code checks for the scheme == file and languageId == cpp or c before processing files. I don't know how we would get notified that the languageId changed from "plain text" to c or cpp. Also, we may need to change some of the checks to be "|| scheme == untitled".

@akbyrd
Copy link

akbyrd commented May 16, 2020

I'm not experienced with extensions, but I think all I do is register and vscode does the rest.
vscode.languages.registerFoldingRangeProvider('cpp', { provideFoldingRanges });
I don't handle any change events for the language.

To verify I disabled the vscode-cpptools folding, enabled mine, opened a new file, pasted some code, set the language to C++ and a few seconds later it updated. It seems to 'just work'.

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented May 16, 2020

@akbyrd The main issue appears to be in our LSP cpptools process, which isn't written correctly to handle input URIs that are not files. So fixing that seems like it would be a non-trivial amount of work. Changing our documentSelectors and scheme checks in TypeScript is the easy part.

@sean-mcmanus sean-mcmanus removed the help wanted Can be fixed in the public (open source) repo. label May 16, 2020
@Colengms Colengms changed the title Language features do not all work with Untitled, unsaved files Need to handle untitled: URI to support Untitled, unsaved files Feb 11, 2021
@Colengms Colengms modified the milestones: Backlog, Triage Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants