swarm-lab / editR

A Rmarkdown editor with instant preview
GNU General Public License v3.0
350 stars 30 forks source link

Problem with using saved file (through editR ) #2

Closed nksingh62 closed 9 years ago

nksingh62 commented 9 years ago
  1. I am using editR (in R Studio). I have R 3.1.2 and R studio 0.98. 1062. with latest updated packages. When I open new file say "temp.Rmd" through editR(), it works reactively and server side update as per change in R code in client side. After saving "temp.Rmd" in editR, When I open it again through editR, results of R code do not displayed until I render. After rendering static results are displayed in browser.
  2. After opening "temp.Rmd" in markdown and saving it, ediR opens "temp.Rmd reactively
  3. EditR inserts extra lines in .Rmd files after each saving.
sjmgarnier commented 9 years ago

Thanks for reporting this issue. I cannot reproduce the problem here. What version of editR are you using?

nksingh62 commented 9 years ago

I am using 0.1.2 version of editR on windows 7 (along with Java version 7, update 71 and Firefox version 34.0.5).

sjmgarnier commented 9 years ago

Ok. There has been some changes since then. Can you try the last version currently available?

Here is the code to install it (some dependencies have changed since v1.2):

install.packages(c("shiny", "shinyFiles", "rmarkdown"))

if (!require("devtools")) install.packages("devtools")
devtools::install_github("trestletech/shinyAce")
devtools::install_github("ebailey78/shinyBS")
devtools::install_github("swarm-lab/editR")

library(editR)
nksingh62 commented 9 years ago

Thanks! Results in files saved with editR are displaying reactively in v1.4 but it still inserting extra blank lines in document.

sjmgarnier commented 9 years ago

Where are these extra blank lines added? I can't reproduce it here. Can you also tell me what OS you use? It might be a platform specific problem.

nksingh62 commented 9 years ago

Additional blank lines are inserted after existing new line char in .Rmd file. I am using windows 7 as OS.

sjmgarnier commented 9 years ago

Ok, this is really confusing. Can you post an example that shows this problem?

dpastoor commented 9 years ago

I can try it on my machine later today, but off the top of my head it could be due to behavior of windows newline creation.

@sjmgarnier I looked briefly through the code (nice!), it looks like you are overwriting the md file using cat - correct? This could be a bug in the way cat --> readChar --> cat --> etc. behave on windows.

sjmgarnier commented 9 years ago

@dpastoor This is a good point. Yes, I use cat to overwrite the file when saving it. I don't have a windows machine available so I never got to try the code on windows. I can install a virtual windows machine on my computer later this week.

Oh, and thanks for finding my code "nice!" ;-)

dpastoor commented 9 years ago

I can also give it a try - my work comp is a windows computer @nksingh62 is it possible for you to make a small reproducible example? Eg if I use the default markdown template will it add those line additions?

sjmgarnier commented 9 years ago

@dpastoor It'd be great if you can give it a try. I'm in the process of moving my lab to new facilities and I won't have much time until next week to install a windows virtual machine and find the root of this problem.

nksingh62 commented 9 years ago

I am attaching two files temp3.md q and temp3_after.md. Temp3.md is orginal file. Temp3_after.md is saved version (through edit R).

On Thu, Jan 15, 2015 at 7:47 AM, Simon Garnier notifications@github.com wrote:

@dpastoor https://github.com/dpastoor It'd be great if you can give it a try. I'm in the process of moving my lab to new facilities and I won't have much time until next week to install a windows virtual machine and find the root of this problem.

Reply to this email directly or view it on GitHub https://github.com/swarm-lab/editR/issues/2#issuecomment-70029902.

Webpage:http://independent.academia.edu/NandKishoreSingh Yahoo Mail Account:nk_singh1@yahoo.com

sjmgarnier commented 9 years ago

@nksingh62 GitHub doesn't know how to handle attachments in issue reports (except for images). Can you create a public gist for each of these example files at https://gist.github.com/ and then share the link here?

Thanks for your help.

nksingh62 commented 9 years ago

(1) I think problem is with markdown. When I saw saved file temp3_after.md in "Notepad", it is not showing extra lines. (2) Although I have uploaded both code "temp3.md "and "temp3_after.md" at public gist (https://gist.github.com/nksingh62/959c468ef62ef76478a0) as you suggested but it may not be sufficient to explain the problem because gist editor distort the problem with its own way to handle the newline. I have loaded screenshots and steps as public document ( https://docs.google.com/document/d/1CS1RKBqHbqeePpe0aTlLfW8UtET44wgRkAQAYD61aO4/edit?usp=sharing) so that it may be clear that editR puts some not printable char at end of line for which markdown (and gist editor) is sensitive but "Notepad" (or MS Word) is not snesitive.

On Thu, Jan 15, 2015 at 7:51 PM, Simon Garnier notifications@github.com wrote:

@nksingh62 https://github.com/nksingh62 GitHub doesn't know how to handle attachments in issue reports (except for images). Can you create a public gist for each of these example files at https://gist.github.com/ and then share the link here?

Thanks for your help.

Reply to this email directly or view it on GitHub https://github.com/swarm-lab/editR/issues/2#issuecomment-70091636.

Webpage:http://independent.academia.edu/NandKishoreSingh Yahoo Mail Account:nk_singh1@yahoo.com

nksingh62 commented 9 years ago

I analysed both file format of temp3.md and temp3_after.md files and found that ediR adds an extra end-of-line char (at time of saving) i.e. "/r" in the file "temp3_after.md" which yields to extra line.

dpastoor commented 9 years ago

OK fyi, I have also reproduced this bug on my computer with windows 8.1. I'm going to try an alternate method of saving to see if that works better (@ least on windows systems)

sjmgarnier commented 9 years ago

Thanks @dpastoor. I don't have a windows computer available and won't have the time to install a virtual machine on my mac and linux machines before the end of next week I think. I suspect that cat is the guilty function here, though I'm not sure why and how to fix the problem.

dpastoor commented 9 years ago

fixed! at least in my testing on the template rmd on mac and windows it behaved as expected.

sjmgarnier commented 9 years ago

Ok, thanks. I'll take a look at it as soon as possible.

sjmgarnier commented 9 years ago

I merged @dpastoor fix. It should work fine now. For some reason I had decided deliberately to use cat rather than writeChar, but I can't remember why. We'll see what happens now :-)