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

#22 Check if file exists before calling openTextDocument. #34

Closed
wants to merge 1 commit into from
Closed

#22 Check if file exists before calling openTextDocument. #34

wants to merge 1 commit into from

Conversation

michaelw85
Copy link
Contributor

No description provided.

@michaelw85
Copy link
Contributor Author

2 Tests will fail due to master code. There is another pr open fixing this.

@@ -128,6 +129,11 @@ class ReferenceProvider {
if (!newUriPath.match(/\.js$/i)) newUriPath += '.js';

const newUri = vscode.Uri.file(newUriPath);

if (!fs.existsSync(newUri.fsPath)) {
Copy link
Owner

@anacierdem anacierdem Aug 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a previously suggested solution. Instead of slowing down response with a sync call, it would be better to find a faster solution.

In fact we are using vscode API properly and handle the rejection. But vscode still throws a [uncaught exception]: [object Object].

Maybe we should report this.

A quick fix will be a try-catch block IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that in my previous PR and could not suppress the error with a try catch hence this solution. I also tried looking into the vscode api documentation as you said its handled as expected. If you really think this (drastically) slows down the plugin I would just leave this bug for now as a known issue.

Copy link
Owner

@anacierdem anacierdem Aug 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the information. I don't think it is critical, but why add a few ms to the critical path? I suggest to leave as a known issue and report on vscode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If its not critical I completely agree. Since it's reported and seemed like an easy fix I thought lets apply the change.

Copy link
Owner

@anacierdem anacierdem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us just wrap it with a try-catch block.

@michaelw85 michaelw85 closed this Aug 4, 2017
@michaelw85 michaelw85 deleted the 22_check_if_file_exists_before_opening branch August 4, 2017 21:15
@anacierdem
Copy link
Owner

Opened an issue on vscode end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants