posit-dev / posit-dev/positron

Unexpected indentation behavior for function args on new lines in R scripts

Open
#5,754 7 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: editor area: formatting support
Dominant language
TypeScript
Stars
4.3k
Forks
184
Avg merge
1d 9h
Merged PRs (30d)
195

Description

System details:

Positron and OS details:
Positron Version: 2024.12.0 (Universal) build 96
Code - OSS Version: 1.93.0
Commit: c5ce275dc502f6b15433b271802cb33e1ba5ef68
Date: 2024-11-28T02:47:29.898Z (2 wks ago)
Electron: 30.4.0
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Darwin arm64 22.6.0
Interpreter details:
R version 4.3.2 (2023-10-31) -- "Eye Holes"

Describe the issue:

Howdy! Trying out positron for the first time today. Coming from RStudio, some of the indentation behavior is unexpected:

  • function args don't line up on enter
  • on auto-format (Cmd + I), args on their own lines just get indented by the default (2 spaces), rather than matching the indentation of the prior line's function arg

Steps to reproduce the issue:

(open up a new R script & run the following)

https://github.com/user-attachments/assets/582db4b6-d0d6-45d9-a74d-424ebcaac852

Expected or desired behavior:

Ideally, formatting/indentation would automatically follow RStudio's built-in styling/indentation, with the expected output of:

mtcars %>%
  ggplot(aes(x = qsec,
             y = hp)) +
  geom_point()

I'm a fan of RStudio's built-in styling/indentation, so the only reason that I don't use VSCode for R is because RStudio-style formatting isn't available and there are no plans in REditor to support this. I am not a fan of styler-style formatting, so in an ideal world, positron would mirror RStudio-style formatting for R scripts by default.

It sounds like there is possibly an upcoming release that addresses formatting, so maybe this issue will be out of date shortly.

Thanks for all the work here, really excited to use a single IDE for R/python!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the indentation and Cmd+I auto-formatting behavior in a new R script using the example in the issue, and compare it with the expected RStudio-style output. Done means multiline function arguments align with the preceding argument rather than receiving only the default two-space indentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.