randy3k / radian

A 21 century R console
MIT License
2k stars 76 forks source link

Random syntax errors when executing code from file #385

Open SwamiVT opened 1 year ago

SwamiVT commented 1 year ago

Radian throws syntax errors when executing code with multiple indentations. This only occurs when executing from the file, does not occur when the code is pasted into the terminal. R version is 4.2.1, radian version is 0.6.4, VScode version 1.17.2.
Compressed video attached Error Radian when using VScode.mp4.gz

jibarons commented 1 year ago

Same issue here, running radian 0.64 running in VScode version: 1.73.1 and R version 4.2.1 and 4.2.2.

This runs seamlessly c("a", "b", "c", "d", "e", "f", "g", "f")

But when indenting, it start to throw errors... at some point would seem somewhat random.

c(
  "a", "b", "c", "d",
 "e", "f", "g", "f"
)

With this specific piece I am finding the following error Error: unexpected '}' in: " "e", "f", "g", "f" }". But it does not appear always. Without clear pattern appear and disappears, doesnt matter running selection or runnign chunck.

Before updating to radian 0.64, in radian 0.60 chunck below was running well, now it shows same error as reprex. However, the chunck below it always throws the error.The reprex, sometimes runs well, sometime (many) it does not.

hh_data %>%
  dplyr::select(
    X_uuid,
    hh_size_boys_0_4, hh_size_girls_0_4,
    hh_size_boys_5_10, hh_size_girls_5_10,
    hh_size_boys_11_15, hh_size_girls_11_15,
    hh_size_boys_16_17, hh_size_girls_16_17,
    hh_size_men_18.29, hh_size_women_18.29,
    hh_size_men_30_64, hh_size_women_30_64,
    hh_size_men_65, hh_size_women_65
  )

With my code styling, I cannot use radian with this issue. Here an image of the terminal with the random errors. Code executed running selection: image

facorread commented 1 year ago

On vscode, I switched from radian to rterm and got the same random syntax errors.

jibarons commented 1 year ago

When I run it in rterm i dont get any error...

c(
  "a", "b", "c", "d",
 "e", "f", "g", "f"
)
fmartelg commented 1 year ago

I have similar issues using

Radian 0.6.4 R version 4.2.2 (2022-10-31 ucrt) -- "Innocent and Trusting" Platform: x86_64-w64-mingw32 (64-bit) Version: 1.75.0 (system setup) Commit: e2816fe719a4026ffa1ee0189dc89bdfdbafb164 Date: 2023-02-01T15:23:45.584Z Electron: 19.1.9 Chromium: 102.0.5005.194 Node.js: 16.14.2 V8: 10.2.154.23-electron.0 OS: Windows_NT x64 10.0.22621 Sandboxed: No

Here are some examples of weird behavior. I am working on an Rmd file in VSCode using the R extension. This code runs fine with regular R shell and in R Studio.

First, I put a cursor in the second line below of my Rmd file:

# clear workspaces
rm(list = ls())

I hit Ctrl+Enter. In R Studio, this sends only the line rm(list = ls()) to the console, as expected. But in my setup it sends the line and all comments above it to the console. The output is:

r$> # clear workspaces rm(list = ls())

That might seem innocent enough but I have found the below issue happens depending on what order you execute things. Here is the code in the Rmd file:

# We also know from Mitel's Annual Report that of their broadband customers
# 158,212 are fiber customers, or some 10% of broadband.

n_customers_fiber <- 158212

If I put my cursor on the last line above and hit Ctrl+Enter, then I get:

r$> # We also know from Jazztel's Annual Report that of their broadband customers
    # 158,212 are fiber customers, or some 10% of broadband.

    n_customers_fiber <- 158212
    |'

(note the cursor before the tilde). I would have expected:

r$> n_customers_fiber <- 158212
r$>

Here is another baffling example. I have this code in the Rmd file:

# cable subscriptions increase by age (more disposable income, etc)

setkey(baseline, age)
baseline[, .(has_cable_average = mean(has_cable)), by = age]
setkey(baseline, id_customer)

I put cursor in setkey line and hit Ctrl+Enter, and proceed line by line. Here is what I get:

r$> # cable subscriptions increase by age (more disposable income, etc)

    setkey(baseline, age)

r$> baseline[, .(has_cable_average = mean(has_cable)), by = age]
    ]

Notice the second line fails and there is no longer a prompt for the third line.

dsanchezp18 commented 1 year ago

I am facing the same issue.

nivr commented 8 months ago

Could this be the same issue reported in https://github.com/REditorSupport/vscode-R/issues/1390 ?