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

New installation of Preview ignores indentation settings in existing project #4366

Closed
DesiQuintans opened this issue Feb 27, 2019 · 11 comments
Closed

Comments

@DesiQuintans
Copy link

System details

RStudio Edition : Desktop
RStudio Version : 1.2.1303
OS Version      : Windows 7 64-bit
R Version       : 3.5.2

Describe the problem in detail

RStudio Preview does not load indentation settings from projects correctly.

Steps to reproduce the problem

  1. Uninstall RStudio. Use a program like Revo Uninstaller to ensure that all of the user files are deleted.
  2. Install RStudio Preview 1.2.1303 (this issue was also present in earlier 1.2.x Preview releases).
  3. Run RStudio and close any open projects. Note that indentation is set to 4 spaces in global options.
    • 4 spaces is how it was set for me, at least. I can't remember the default setting, but if it wasn't 4 spaces, then RStudio has the added issue of not uninstalling itself cleanly.
  4. Open a new R script (while no project is open) and note that indentation to 4 spaces is working correctly.
  5. Open an existing project and one of the script files in that project (I used .Rmd).
  6. Confirm that all of the lines in the project are correctly indented to 4 spaces.
  7. Try to type a pipeline, like iris %>% [RETURN] plot(). It will only indent to 2 spaces.
  8. Go to the project settings and change the indentation to something else (like 6 spaces).
  9. Indentation will now work to 6 spaces.
  10. Change project indentation back to 4 spaces.
  11. Indentation will now work to 4 spaces.

Describe the behavior you expected

Indentation should be loaded correctly from a project.

@kevinushey
Copy link
Contributor

Do you have project-specific options setting the indentation to two spaces? (Check Tools -> Project Options... -> Code Editing)

You might also want to disable the [ ] Auto-detect code indentation preference.

screen shot 2019-02-27 at 8 51 58 am

@DesiQuintans
Copy link
Author

DesiQuintans commented Feb 27, 2019

No, indentation in the project was set to 4 spaces, that’s what I meant by RStudio ignoring the project settings. I should add that when I saw it was 4 in the project settings, I erased the value, put it on 4 again and saved the project, but that did not fix the bug. Only changing it to a different number, saving it, and then changing it back to 4 fixed it.

I do also have Auto-detect code indentation turned off, but my understanding is that it shouldn’t have mattered anyway, its tooltip said that this should only apply to files that are not part of any project. In any case, having it on or off did not change anything about this bug.

@ronblum ronblum added the bug label Mar 8, 2019
@meystingray
Copy link

Having the same issue: see my post here on Rstudio community

@kevinushey kevinushey added this to the v1.2-patch milestone Apr 22, 2019
@kevinushey
Copy link
Contributor

I'm still not able to reproduce. The project-specific indentation setting appears to take effect as expected.

One possibility: was this a project that was moved or relocated previously? Are there multiple .Rproj files, or just a single one? (wondering if we're somehow selecting the wrong .Rproj file)

@DesiQuintans
Copy link
Author

Hi Kevin,

For me, I never moved the projects from their old locations (and even if I did, that doesn't change the contents of the Rproj file). There is only one Rproj file in each folder, and it contains the right number of spaces:

Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 4
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

@kevinushey
Copy link
Contributor

Unfortunately, we don't have any other reports of this in the wild and cannot reproduce locally so we'll be unable to fix this for v1.2-patch. Moving to v1.3 unless we can get more information.

@kevinushey kevinushey modified the milestones: v1.2-patch, v1.3 Jun 11, 2019
@DesiQuintans
Copy link
Author

That's fair. When I find the issue again I will send the file that's causing it to your team; if it's a rare issue then maybe it's something about my files and some unicode characters I use in them.

@aosmith16
Copy link

I've also been experiencing this issue whenever working in a project for the last few months. I've seen it on two different Windows 7 machines and, as of today, on a Windows 10 machine with RStudio 1.2.1578. I used to get 2 spaces instead of my global setting of 5, and more recently I've gotten 7 spaces (maybe that's 2 + 5?).

However, it looks like disabling the Auto-detect code indentation option fixes this for me. 👍 Hopefully it sticks!

@jmcphers
Copy link
Member

jmcphers commented Dec 2, 2019

Closing this since the original issue was never reproduced. @aosmith16 If you have a reproducible example in which the Auto-detect feature doesn't work as it should, could you open it separately? A zipfile with a project that gets the wrong tab width detected (and applied over a specific tab width set in Project Options) would be very helpful.

@ParadaCarleton
Copy link

I'm having exactly this same problem now.

@WGustafsson
Copy link

WGustafsson commented Sep 6, 2021

This is happening to me as well and has been happening for quite some time. It happens in several projects, on both Windows and Fedora.

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

No branches or pull requests

9 participants