Skip to content

Check url in browser#406

Merged
renkun-ken merged 2 commits intoREditorSupport:masterfrom
renkun-ken:browser-check
Sep 13, 2020
Merged

Check url in browser#406
renkun-ken merged 2 commits intoREditorSupport:masterfrom
renkun-ken:browser-check

Conversation

@renkun-ken
Copy link
Copy Markdown
Member

@renkun-ken renkun-ken commented Sep 1, 2020

What problem did you solve?

Closes #371

(If you do not have screenshot) How can I check this pull request?

Following localhost http content it should work:

?get
shiny::runExample("01_hello")

External http content should open in external web browser due to WebView restrictions on external web content:

browseURL("https://google.com")

Local HTML file should open in external web browser due to WebView restrictions on resource location:

tmpfile <- tempfile(fileext = ".html")
writeLines(c("<html>hello</html>"), tmpfile) 
browseURL(tmpfile)

Local non-HTML file should open in vscode editor as text document:

tmpfile <- tempfile(fileext = ".txt")
writeLines("hello", tmpfile)
browseURL(tmpfile)

@renkun-ken renkun-ken requested a review from andycraig September 2, 2020 13:10
@renkun-ken
Copy link
Copy Markdown
Member Author

However, under Remote Development, browsing a HTML file or other files does not work. I'm trying to come up some method to mimic the behavior of browseURL running locally.

@andycraig
Copy link
Copy Markdown
Collaborator

@renkun-ken

However, under Remote Development, browsing a HTML file or other files does not work. I'm trying to come up some method to mimic the behavior of browseURL running locally.

That would be in a separate PR, right? If so, I'll go ahead and review this PR this weekend (without trying it under Remote Development).

@renkun-ken
Copy link
Copy Markdown
Member Author

That would be in a separate PR, right? If so, I'll go ahead and review this PR this weekend (without trying it under Remote Development).

Yes. Currently, I don't think there's a decent way to do that, so I'd rather leave as is at the moment.

@andycraig
Copy link
Copy Markdown
Collaborator

Tested on Windows. Everything works except this one: 'Local HTML file should open in external web browser due to WebView restrictions on resource location'. I get this output:

> browseURL(tmpfile)
VSCode WebView has restricted access to local file.
Opening in external browser...

But nothing happens in the browser. The Google example opens the Google homepage as expected.

@renkun-ken
Copy link
Copy Markdown
Member Author

Everything works except this one: 'Local HTML file should open in external web browser due to WebView restrictions on resource location'.

Thanks for testing. I'll take a look into this. Looks like the normalized path does not work with openExternal?

@renkun-ken
Copy link
Copy Markdown
Member Author

renkun-ken commented Sep 7, 2020

I could reproduce this in a Windows 10 VM. It turns out that env.openExternal(Uri.parse(url)) only works with Uri string like file:///C:/... under Windows. Fixed via 88eeb47.

@andycraig
Copy link
Copy Markdown
Collaborator

Thanks! I will give it a test.

Copy link
Copy Markdown
Collaborator

@andycraig andycraig left a comment

Choose a reason for hiding this comment

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

Tested the updated version on Windows 10, everything works. LGTM.

@renkun-ken
Copy link
Copy Markdown
Member Author

Thanks for testing on Windows!

@renkun-ken renkun-ken merged commit 824fff8 into REditorSupport:master Sep 13, 2020
@renkun-ken renkun-ken mentioned this pull request Sep 28, 2020
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.

browser does not open

2 participants