posit-dev / positron

Positron, a next-generation data science IDE
https://positron.posit.co
Other
2.57k stars 79 forks source link

Variable Pane doesn't know how to format formulas #4119

Open strengejacke opened 3 months ago

strengejacke commented 3 months ago

Positron Version:

Positron Version: 2024.07.0 (system setup) build 2024.07.0-85 Code - OSS Version: 1.91.0 Commit: 9dfa34e1eb5a42ebbd1c1d17b55bef7e7bf0bf1f Date: 2024-07-22T03:21:08.974Z Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Windows_NT x64 10.0.22631

Steps to reproduce the issue:

Run following code, step-by-step:

ff <- "mo(gear)"
ff <- stats::as.formula(paste0("~", ff))
ff

First, the value of ff appears in the Variables view. After converting to formula, the value changes to ??.

https://github.com/user-attachments/assets/6b6d323a-6511-4b01-9134-750a9f03e957

What did you expect to happen?

The value of ff changes to ~mo(gear).

Were there any error messages in the Output panel or Developer Tools console?

No.

juliasilge commented 2 months ago

Notes for when we look at this:

From my perspective the main problem is that formulas and other objects like quosures have length > 1 but base::format() results of length 1:

x <- formula(y ~ a + b + c)
length(x)
#> [1] 3
length(base::format(x))
#> [1] 1

Created on 2024-08-23 with reprex v2.1.1