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

always specify html_file on render() #75

Merged
merged 2 commits into from Oct 13, 2017

Conversation

@yutannihilation
Copy link
Member

commented Mar 12, 2017

On Windows, I am jumped to browsers every time I execute reprex(). This is a bit annoying. This PR is a temporal workaround to let RStudio on Windows use Viwer Pane. Note that, I guess this is up to RStudio and is not the fault of reprex package, but I think we'll need this for a while.

According to this article, we have to place a HTML file in session temporary directory to render it in Viewer Pane:

Note that the Viewer pane can only be used for local web content. This content can either be static HTML files written to the session temporary directory (i.e. files with paths generated by the tempfile function) or a locally run web application.
https://support.rstudio.com/hc/en-us/articles/202133558-Extending-RStudio-with-the-Viewer-Pane

But, currently, RStudio fails to recognize a tempdir is actually a tempdir, confused by the infamous "8.3 short filename". I mean, tempdir() function returns a path in short form like this (given that my username is username),

"C:\\Users\\USERNA~1\\AppData\\Local\\Temp\\RtmpGSN3hM\\"

whereas render() returns the path in the ordinary form like this:

"C:/Users/username/AppData/Local/Temp/RtmpGSN3hM/test_reprex_149c6f644b0d.html"

It seems that RStudio fails to recognize these two are the same.

always specify html_file on render()
This is a temporal workaround to let Rstudio on Windows use Viwer Pane; Otherwise, RStudio fails to recognize a tempdir is actually a tempdir, confused by the infamous "8.3 short form of path".
@yutannihilation

This comment has been minimized.

Copy link
Member Author

commented Mar 12, 2017

By the way, due to the lack of my R programming skill, I couldn't find a good reason to use this if statement... Shouldn't html_file be the same no matter the outfile is specified or not?

@jennybc jennybc merged commit b1f2aef into tidyverse:master Oct 13, 2017

3 of 4 checks passed

codecov/patch 0% of diff hit (target 88.97%)
Details
codecov/project 90.63% (+1.66%) compared to 1286c0e
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jennybc

This comment has been minimized.

Copy link
Member

commented Oct 13, 2017

Thanks! I had to refactor this a bit in subsequent commits to account for other changes. I now pre-compute all filenames that might be needed and copy the html to the tempdir if it's not already there, before viewing. Can you check that I haven't just re-introduced your Windows problem?

@yutannihilation

This comment has been minimized.

Copy link
Member Author

commented Oct 14, 2017

Thanks for the notice :) I confirmed everything works fine on my Windows now. Nice!

image

@yutannihilation yutannihilation deleted the yutannihilation:viewer branch Oct 14, 2017

@jennybc

This comment has been minimized.

Copy link
Member

commented Oct 14, 2017

Yay 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.