-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix 'window.showTextDocument' to open resources with 'untitled' schema #6803
Conversation
@akosyakov |
I thought that untitled resources should not have physical representation till a user explicitly saved them? If a user just close the editor without saving then there should not be a trace of the file? cc @amiramw @TomHermanSAP @offer8 It would be nice if someone setups simple VS Code extension to manipulate resource with untitled schema. And then run it against VS Code and Theia to make sure that resources are treated the same. Running the sql extension is overkill. |
@@ -221,6 +221,7 @@ export class DocumentsExtImpl implements DocumentsExt { | |||
// return opened document | |||
return document; | |||
} catch (error) { | |||
console.log(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left overs? Should not it be handled by clients since we throw it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, fixed
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
@ShimonBenYair btw i thought @amiramw @TomHermanSAP @offer8 were working on it, please give a notice that you want to work on something which is obviously in discussions to avoid duplicate effort |
@ShimonBenYair is in our team so we are all synced. Sorry for the confusion. |
@amiramw ok, thanks for letting to know. Could you take care about the review please and testing that it is aligned with VS Code interpretation of untitled schema? Don't get why i cannot assign you as a reviewer. I was pretty sure that you are an Eclipse Theia committer. |
Sure |
61d96f6
to
c216481
Compare
After consulting with @amiramw i have fixed it so now when calling the 'vscode.window.showTextDocument' API with 'untitled' schema,the untitled resource will not have physical representation till the user will save it |
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
VS Code uses the save file dialog to let a user to pick the proper file name, why we cannot do the same with https://github.com/eclipse-theia/theia/blob/master/packages/filesystem/src/browser/file-dialog/file-dialog-service.ts#L63? |
@chrisguindon @eclipsewebmaster Some committers don't seem to belong to Eclipse Theia org, for example @amiramw. Is it the issue with sync script or some actions are expected from the committer? |
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
c216481
to
d6052d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still does not behave like in VS Code and create a file with weird name instead of using a file dialog. Is it on purpose or there are some technical limitations to implement it properly?
packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
From what I can tell, @amiramw is a committer on the project: https://accounts.eclipse.org/users/amiramw#tab-projects |
@chrisguindon my issue was resolved after i fixed my github id in eclipse profile |
de302a9
to
3a6ae10
Compare
@amiramw @ShimonBenYair Could you elaborate on it? We have |
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
please use fetch + rebase (not merge) to keep the history straight, please see https://github.com/eclipse-theia/theia/blob/master/doc/pull-requests.md#checklist-commit-history |
In the original issue vscode API was called with uri already so when the untitled document is saved there is no file save dialog. |
@ShimonBenYair @amiramw there is this path: https://github.com/ShimonBenYair/theia/blob/7e2e4afd88d18c7365cee7c03588c0a00600779a/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts#L141-L143 What happens if VS Code extension calls this command Please though address remaining comments before landing. |
@akosyakov it seems that after the below code in the VS Code extension, fileUri contains inline a uri with schema "file".
If we want to be generic to other schemas (inside untitled schema) then we should not hold Does it seem ok with you or untitled resource and file resolved are coupled by definition? |
7e2e4af
to
d86edea
Compare
eb637a7
to
ee339b6
Compare
So maybe I shall remove from the PR the part that tries to handle the tab duplication and open a new issue for it with minor priority ? |
yes, it was my suggestion, we don't affect anything, it still works for you to some extent and we can redesign it in another PR |
Ok i will update the PR |
ee339b6
to
24e86b1
Compare
@akosyakov |
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code-wise it looks good, except one comment
someone has to test that it does what expected, cc @amiramw
@ShimonBenYair Please file an issue for duplicate editors? I think we need a general issue to support untitled editors properly in core. And think about the holistic design instead of trying to fix it as a separate case in the plugin system. |
I will test it later this week. |
24e86b1
to
3ef0192
Compare
@ShimonBenYair Just noticed that not all |
3ef0192
to
ab7573e
Compare
@akosyakov Are you sure i need to implement them on UntitledResource ? What is the 'onDidChangeContents' responsible for ? ( i didn't find any documentation for it and i was not able to stop there when setting a breakpoint) . |
@ShimonBenYair |
ab7573e
to
a49238f
Compare
done |
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
a49238f
to
fd43f72
Compare
packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Outdated
Show resolved
Hide resolved
Fixes eclipse-theia#6565 Signed-off-by: Shimon Ben Yair <[email protected]>
fd43f72
to
7b3771f
Compare
please review again |
@ShimonBenYair just to be clear, i'm not trying to prevent your progress or something like that. Each time when I look I find something like it will leak memory, it will ignore changes on the disk and so on. When I see that it does not break, then I merge. Code looks good now, I'm going to test it and if it is fine I merge it. We have a rule that we don't merge things which were tested only by the author: https://github.com/eclipse-theia/theia/blob/master/doc/pull-requests.md#landing-pr That's why asked someone else to test it. |
Tested, it behaves well, did not find memory leaks and it reacts to changes on the disk as well. The only error was:
It is unrelated to the PR, it would be worth to file a PR to fix it as well. |
@ShimonBenYair opening follow-up issues would be good, about missing commands and duplicate editors for untitled and file schemes for the same path |
Fixes #6565
Signed-off-by: Shimon Ben Yair [email protected]
What it does
Currently "window.showTextDocument" Does Not open Resources With "untitled" Scheme.
i.e. Using the following code :
const fileUri = Uri.parse(
untitled:${uri}).with({ scheme }); await window.showTextDocument(fileUri);
does not open a file in Theia an raises an error.
With changes in this pull request, when calling the above API a file is created and the user can modify and save the file with no problems.
This pull request Fixes #6565 bug.
How to test
Add this SQLTools extension (current version 0.21.5) under your plugins folder in Theia.
sqltools-0.21.5.zip
Create in workspace/theia a new file called "tom.db".
3.Add to User preferences the following values:
{
"sqltools.useNodeRuntime": true,
"sqltools.dependencyManager": {
"autoAccept": true
},
"sqltools.connections": [
{
"name": "sqlite",
"dialect": "SQLite",
"database": "workspace/theia/tom.db"
}
]
}
Click on SQLTools extension.
In "sqlite" linem, click on connect:
When clicking on the "connect" button , code similar to the following is executed :
const uri = vscode.Uri.file(os.homedir + '/newnew.txt'); const fileUri = vscode.Uri.parse(
untitled:${uri}).with({ scheme: 'untitled' }); vscode.window.showTextDocument(fileUri);
I have found some more issues in this code but as their fix is not required for this feature, it is out of the scope of this pull request.
Review checklist
Reminder for reviewers