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

[vscode] No error message if vscode.open command is invoked with resource that doesn't exist #5667

Closed
tetchel opened this issue Jul 8, 2019 · 8 comments · Fixed by #12284
Assignees
Labels
bug bugs found in the application vscode issues related to VSCode compatibility

Comments

@tetchel
Copy link
Contributor

tetchel commented Jul 8, 2019

In VS Code, if you do vscode.commands.executeCommand("vscode.open" with a file that doesn't exist, you get an error message like the following:

image

It would be nice if theia had the same behaviour.

@tetchel tetchel changed the title No error message if vscode.open command is invoked with resource that doesn't exist [vscode] No error message if vscode.open command is invoked with resource that doesn't exist Jul 8, 2019
@akosyakov akosyakov added bug bugs found in the application vscode issues related to VSCode compatibility labels Jul 9, 2019
@tolusha
Copy link
Contributor

tolusha commented Aug 8, 2019

I've just installed the extension [1] for testing purpose in VS Code.
It doesn't show any error messages above. I guess that error message comes from another place.

[1] https://github.com/tolusha/vscode-test-extensions/blob/master/open-some-file-0.0.1.vsix

@tolusha
Copy link
Contributor

tolusha commented Aug 8, 2019

@tetchel Could you tell what the exact usecase is?

@tolusha tolusha self-assigned this Aug 8, 2019
@tsmaeder
Copy link
Contributor

@tolusha how are you sure the code you think you're executing is even executing? Without some log output or such you might just not executing the command.
However, since we don't have steps to reproduce, I am closing this one. @tetchel feel free to reopen if this is still a problem for you.

@tetchel
Copy link
Contributor Author

tetchel commented Aug 14, 2019

It's still an issue.

In one of my extension's WebViews I have a button which opens a particular file. If that file is missing in VS Code, the user gets an error. If it's missing in Theia, the button appears to not work even though it is executing the command.

The steps to reproduce are just

vscode.commands.executeCommand("vscode.open", vscode.Uri.file("/non-existent-file"));

In VS Code you will see an error message, in theia you will not.

@tetchel tetchel reopened this Aug 14, 2019
@tolusha
Copy link
Contributor

tolusha commented Aug 15, 2019

@tetchel
Thank you. I've updated my test extension [1] and I am able to reproduce the bug.
Obviously VS Code try to create a new file [2] when it isn't found.

[1] https://github.com/tolusha/vscode-test-extensions/blob/master/open-some-file-0.0.1.vsix
[2] https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/contrib/files/browser/editors/textFileEditor.ts#L184

@svenefftinge
Copy link
Contributor

#6290 might be the reason an error is ignored.

vrubezhny added a commit to vrubezhny/theia that referenced this issue Nov 8, 2019
@vrubezhny
Copy link
Contributor

vrubezhny commented Nov 9, 2019

@tolusha's test extension doesn't work anymore as the following check is added for the command parameters at https://github.com/eclipse-theia/theia/blob/master/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts#L79:

if (!URI.isUri(resource)) {
     throw new Error(`Invalid argument for ${VscodeCommands.OPEN.id} command with URI argument. Found ${resource}`);
}

As result of the change the other kind of error is being reported instead of Error: 'file:///bla-bla' has not been found.:

root ERROR [hosted-plugin: 23072] Promise rejection not handled in one second: Error: Invalid argument for vscode.open command with URI argument. Found file:///bla-bla
root ERROR [hosted-plugin: 23072] With stack trace: Error: Invalid argument for vscode.open command with URI argument. Found file:///bla-bla
    at PluginVscodeCommandsContribution.<anonymous> (http://localhost:3000/91.bundle.js:217:39)
    at step (http://localhost:3000/91.bundle.js:155:23)
    at Object.next (http://localhost:3000/91.bundle.js:136:53)
    at http://localhost:3000/91.bundle.js:130:71
    at new Promise (<anonymous>)
    at push.../../packages/plugin-ext-vscode/lib/browser/plugin-vscode-commands-contribution.js.__awaiter (http://localhost:3000/91.bundle.js:126:12)
    at Object.execute (http://localhost:3000/91.bundle.js:208:68)
    at CommandRegistry.<anonymous> (http://localhost:3000/bundle.js:113517:62)
    at step (http://localhost:3000/bundle.js:113303:23)
    at Object.next (http://localhost:3000/bundle.js:113284:53)

@tolusha Could you please confirm that file:///bla-bla is a valid URI that still can be used in the test?

PS: I found that the if (!URI.isUri(resource)) { check doesn't work even for a valid file:// like URI pointing to an existing workspace file.

@tolusha
Copy link
Contributor

tolusha commented Nov 11, 2019

@vrubezhny It used to work
Probably it doesn't path the instance of URI into the command.

vrubezhny added a commit to vrubezhny/theia that referenced this issue Nov 18, 2019
vrubezhny added a commit to vrubezhny/theia that referenced this issue Feb 21, 2020
vrubezhny added a commit to vrubezhny/theia that referenced this issue Feb 28, 2020
vrubezhny added a commit to vrubezhny/theia that referenced this issue Mar 3, 2020
vrubezhny added a commit to vrubezhny/theia that referenced this issue Mar 4, 2020
vrubezhny added a commit to vrubezhny/theia that referenced this issue Mar 6, 2020
vrubezhny added a commit to vrubezhny/theia that referenced this issue Mar 9, 2020
FernandoAscencio added a commit to FernandoAscencio/theia that referenced this issue Mar 7, 2023
This commit finishes imlementations of eclipse-theia#6568
This commit closes eclipse-theia#5667

Signed-Off-By: FernandoAscencio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application vscode issues related to VSCode compatibility
Projects
None yet
6 participants